Is there a way to automate BLF to CSV conversion in Vector CANoe?

后端 未结 1 1893
臣服心动
臣服心动 2021-01-14 12:50

My first approach was using python-can (as it added support for parsing BLF files with 2.0.0 release) like this:

import can

filename = \"logfile.blf\"
loggi         


        
相关标签:
1条回答
  • 2021-01-14 13:16

    You can use the following scripts to automate the file format conversion with the automation of your CANoe or CANalyzer. The solution consists of a Windows batch file and a VisualBasicScript file. The batch file convert_this_folder.bat has to be started by double-click. It contains the following line which calls the other script for all BLF log files in the folder where the batch file is located:

    for /F %%x in ('cd') do for %%i in (*.blf) do c:\windows\system32\wscript.exe canoe_convert.vbs %%i %%x
    

    The VBS script canoe_convert.vbs contains the following lines:

    '-----------------------------------------------------------------------------
    ' converts the filenames which are passed via startup parameter to ASC files with the help of CANoe
    '-----------------------------------------------------------------------------
    Dim src_file, dst_file, pos
    
    Set App         = CreateObject("CANoe.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 CANoe configuration and specify the path and file name below
    '-----------------------------------------------------------------------------
      App.Open("d:awayawayempty_config.cfg")
    '-----------------------------------------------------------------------------
    ' create destination file name and append .asc   -- you could change this to different file format that is supported by CANoe
      src_file=arg1 & "" & arg0
      dst_file=src_file & ".asc"
    
      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
    

    What you have to do:

    1. Create an empty CANoe configuration and save it.
    2. Enter the path and file name of this empty configuration into the VBS file (the place of insertion is marked visually)
    3. Copy all the log files to be converted into the same directory where the 2 script files are located.
    4. If opened, close CANoe.
    5. Start the batch conversion by double-clicking on the convert_this_folder.bat. For each file CANoe is started, the file is converted and CANoe is closed. This is done via COM automation. The whole conversion process might take some time, please leave your PC alone during that time and do not perform other tasks.

    The script files are attached below. You can adjust the scripts to CANalyzer by replacing "CANoe.Application" with "CANalyzer.Application" in the VBS file. The empty CANalyzer configuration has to be created additionally.

    The conversion types can be adjusted as follows: Source file type in the .BAT file: change .BLF to the supported requested source file format Destination file type in the .VBS file: change .ASC to the supported requested destination file format.

    0 讨论(0)
提交回复
热议问题