I'm trying to automate my conversion of a bunch of BLF files into Matlab MAT files. I found a similar question on here and used the answer to get started:
Is there a way to automate BLF to CSV conversion in Vector CANoe?
I would just comment on that thread, but my account here is new so I can't.
I followed the instructions in the other thread to set it up for CANalyzer and BLF/MAT files. When I run the BAT file I get an error in the Write window of CANalyzer that says: System Logging file 'logfile001.blf' could not be imported
So the issue seems to be that the BLF isn't getting imported into CANalyzer properly. Has anyone tried this before or have any suggestions on what to try? I've never really used VBS so I'm having a hard time troubleshooting the code.
Here's my code as I have it written. For the BAT file:
for /F %%x in ('cd') do for %%i in (*.blf) do c:\windows\system32\wscript.exe canalyzer_convert.vbs %%i %%x
For the VBS script:
'-----------------------------------------------------------------------------
' converts the filenames which are passed via startup parameter to MAT files with the help of CANalyzer
'-----------------------------------------------------------------------------
Dim src_file, dst_file, pos
Set App = CreateObject("CANalyzer.Application")
Set Measurement = App.Measurement
Set args = WScript.Arguments
' read first command line parameter
arg0=args.Item(0)
arg1=args.Item(1)
If Measurement.Running Then
Measurement.Stop
End If
Wscript.Sleep 500
'---------------------------------------------------------------------------
' you have to create an empty CANalyzer configuration and specify the path and file name below
'-----------------------------------------------------------------------------
App.Open("c:\CANalyzer\empty_config.cfg")
'-----------------------------------------------------------------------------
' create destination file name and append .mat -- you could change this to different file format that is supported by CANalyzer
' next line has to be cut down to src_file="" & arg0 or src_file=arg0 to avoid adding folder name to file name, but this script still crashes
src_file=arg0
dst_file=src_file & ".mat"
Set Logging = App.Configuration.OnlineSetup.LoggingCollection(1)
Set Exporter = Logging.Exporter
With Exporter.Sources
.Clear
.Add(src_file)
End With
' Load file
Exporter.Load
With Exporter.Destinations
.Clear
.Add(dst_file)
End With
Exporter.Save True
App.Quit
Set Exporter = Nothing
Set Logging = Nothing
Set App = Nothing
Set args = Nothing
Set Measurement = Nothing
If you compare mine to the answer from the other thread, you'll see I had to remove the arg1 info from this line
src_file=arg1 & "" & arg0
If I don't remove arg1 from there, then CANalyzer tries to import a BLF file that also includes the folder name in the file name and crashes the script. I think it may be causing problems with
Set Logging = App.Configuration.OnlineSetup.LoggingCollection(1)
because that line appears to reference
arg1=args.Item(1)
Any help would be appreciated.