0

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.

Doug
  • 1
  • 1
  • 2
  • Can you import the BLF into CANaylzer manually? – MSpiller Jan 22 '20 at 15:52
  • Yes, normally if I want to convert a BLF file to MAT format, I just use CANalyzer to do it. It has a built in file conversion tool that works well, but I haven't found a way to automate it. It can be time consuming when you have hundreds of files to convert. – Doug Jan 22 '20 at 17:39
  • Where is _logfile001.blf_ located? In the directory of the batch? In the directory of the CANalyzer config? – MSpiller Jan 24 '20 at 09:00
  • Thank you M. Spiller. That was exactly the problem. My config file and folders were in a separate location and I didn't know that wouldn't work. I could see CANalyzer finding the file, but it wasn't able to load it. But now I have a new issue. The .blf file is 2400 KB, but when it's converted to .mat it's only 2KB and the data is missing. Anybody have any ideas for what I could try next? – Doug Jan 29 '20 at 17:51
  • I added DBC (database) files to the CANalyzer config. The way CANalyzer is normally used you need those DBC files to view the CAN traffic. Adding the DBCs results in a MAT file that is just over 2000KB. If I convert the same file using the same DBCs and the CANalyzer log file conversion tool, the MAT file ends up being 4500KB. Now I need to figure out what the difference is. – Doug Jan 29 '20 at 23:26
  • I know there are two ways to export data from CANalyzer and I'm not sure which one these two lines of code in the VBS script are calling: `Set Logging = App.Configuration.OnlineSetup.LoggingCollection(1) `Set Exporter = Logging.Exporter Is there a way to know what other commands I could use in these lines? – Doug Jan 30 '20 at 00:16

0 Answers0