首页 > 解决方案 > 在 Vector CANalyzer 中自动进行 BLF 到 MAT 文件的转换

问题描述

我正在尝试将一堆 BLF 文件自动转换为 Matlab MAT 文件。我在这里发现了一个类似的问题并使用答案开始:

有没有办法在 Vector CANoe 中自动将 BLF 转换为 CSV?

我只想评论那个帖子,但我这里的帐户是新的,所以我不能。

我按照另一个线程中的说明为 CANalyzer 和 BLF/MAT 文件进行了设置。当我运行 BAT 文件时,我在 CANalyzer 的写入窗口中收到错误消息:无法导入系统日志文件“logfile001.blf”

所以问题似乎是 BLF 没有正确导入 CANalyzer。有没有人尝试过这个或对尝试什么有任何建议?我从来没有真正使用过 VBS,所以我很难对代码进行故障排除。

这是我写的代码。对于 BAT 文件:

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

对于 VBS 脚本:

'-----------------------------------------------------------------------------
' 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

如果您将我的答案与其他线程的答案进行比较,您会看到我必须从该行中删除 arg1 信息

src_file=arg1 & "" & arg0

如果我不从那里删除 arg1,那么 CANalyzer 会尝试导入一个 BLF 文件,该文件还包括文件名中的文件夹名称,并使脚本崩溃。我认为这可能会导致问题

Set Logging = App.Configuration.OnlineSetup.LoggingCollection(1)

因为那条线似乎参考

arg1=args.Item(1)

任何帮助,将不胜感激。

标签: file-conversioncanalyzer

解决方案


推荐阅读