本文介绍了有没有办法在Vector CANoe中自动将BLF转换为CSV?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的第一种方法是使用



此消息被证明是很隐秘的,所以我不知道确实有什么问题,除了写文件有些麻烦。事情是,我真的不需要 CANoe 为我写书,只要我能掌握 BLF



所以我想到的另一个想法是将 BLF 附加为离线在CANoe'a Configuration 窗口中,保存配置并从脚本开始测量。这样,我将数据保存在 Trace 窗口中(默认情况下限制为4000个事件,但是我认为应该可以编辑),但是到目前为止,还没有找到一种方法



我觉得应该有一些更简单的方法来做到这一点。毕竟,在 CANoe 中有记录文件转换对话框,逻辑上的方法是使用COM界面以某种方式访问​​该对话框。我只是似乎看不到它写在文档中的任何地方。



任何帮助将不胜感激。

解决方案

您可以使用以下脚本通过CANoe或CANalyzer的自动化来自动进行文件格式转换。该解决方案由Windows批处理文件和 VisualBasicScript 文件组成。
批处理文件 convert_this_folder.bat 必须双击启动。它包含以下行,该行为该批处理文件所在的文件夹中的所有BLF日志文件调用其他脚本:

  / F %% x在('cd')中为%% i在(* .blf)中做c:\windows\system32\wscript.exe canoe_convert.vbs %% i %% x 

VBS脚本 canoe_convert.vbs 包含以下几行:

 '--------------------------- -------------------------------------------------- 
'借助CANoe将通过启动参数传递的文件名转换为ASC文件
'----------------------- -------------------------------------------------- ----
Dim src_file,dst_file,pos

Set App = CreateObject( CANoe.Application)
Set Measurement = App.Measurement
Set args = WScript.Arguments

'读取第一个命令行参数
arg0 = args.Item(0)
arg1 = args.Item(1)

如果测量,然后运行
Mea surement.Stop
End if

Wscript.Sleep 500

'-------------------- -------------------------------------------------- -----
',您必须创建一个空的CANoe配置并在
下面指定路径和文件名'------------------- -------------------------------------------------- --------
App.Open( d:awayawayempty_config.cfg)
'--------------------- -------------------------------------------------- ------
'创建目标文件名并附加.asc-您可以将其更改为CANoe
src_file = arg1&支持的其他文件格式。 和arg0
dst_file = src_file& .asc

设置日志记录= App.Configuration.OnlineSetup.LoggingCollection(1)
设置Exporter = Logging.Exporter

与Exporter.Sources
。清除
.Add(src_file)

结尾
'加载文件
Exporter.Load

使用Exporter.Destinations
。清除
.Add(dst_file)


出口商结束。保存True

应用程序。退出
设置出口商=无
设置日志记录=否
设置应用程序=否
设置args =否
设置度量=否

您需要做什么:


  1. 创建一个空的CANoe配置并保存。
  2. 将此空配置的路径和文件名输入到VBS文件中(在视觉上标记插入位置)

  3. 将所有日志文件复制到转换为2个脚本文件所在的目录。

  4. 如果打开,请关闭CANoe。

  5. 通过双击convert_this_folder.bat开始批量转换。对于启动的每个文件,将转换文件并关闭CANoe。这是通过COM自动化
    完成的。整个转换过程可能需要花费
    的时间,在此期间请不要打扰您的PC,不要执行
    的其他任务。

脚本文件附在下面。
您可以通过在VBS文件中将 CANoe.Application替换为 CANalyzer.Application来将脚本调整为CANalyzer。



可以按以下方式调整转换类型:
.BAT文件中的源文件类型:change .BLF更改为支持的请求的源文件格式
.VBS文件中的目标文件类型:将.ASC更改为支持的请求的目标文件格式。


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"
logging = can.BLFReader(filename)
for msg in logging:
    print(msg)

but that resulted in an error that I reported to the developer. BLF format is proprietary and somewhat secret so I understand supporting it in an open-source library can be problematic.

So then I looked into doing it using a solution provided by Vector: COM, but so far haven't been able to come up with a solution.

(The code snippet below is in vbscript as that's what used in CANoe docs, but I also have Python scripts doing exactly the same using win32com)

So first I tried with this:

Dim app, measurement, loggings, logging, exporter, expfilter
Set app = CreateObject("CANoe.Application")
Set loggings = app.Configuration.OfflineSetup.LoggingCollection
loggings.Add("D:\path\dummy3.blf")
Set logging = loggings(1)
Set exporter = logging.Exporter
Set expfilter = exporter.Filter
exporter.Load

For Each symbol In exporter.Symbols
  expfilter.Add(symbol.FullName)
Next

For Each message In exporter.Messages
  expfilter.Add(Message.FullName)
Next

expfilter.Enabled = True

Dim dests
Set dests = exporter.Destinations
dests.Clear
dests.Add("D:\path\dummy3.csv")

exporter.Save True

And that works at least inasmuch that BLF is loaded into Exporter object and I can read FullName property of all its Symbol and Message objects and also I'm sure the path added to its Destinations collection is OK (at least I can read it after adding), but then it all falls flat at the last line with the error below:

This message proves to be rather cryptic so I don't know really what's wrong apart from that there's some trouble with writing a file. The thing is I don't really need CANoe to do the writing for me as long as I can get my hands on the data contained in BLF somehow.

So the other idea I head was to attach the BLF as an offline source in CANoe'a Configuration window, save the config and start a measurement from a script. That way I have the data in a Trace window (limited to 4000 events by default, but I believe that should be editable), but so far haven't found a way to get to it using the COM interface.

I have a feeling there should be some easier way to do this. After all there's Logging File Conversion dialog in CANoe and the logical way would be to access that somehow using COM interface. I just don't seem to able to see that written anywhere in the docs.

Any help would be much appreciated.

解决方案

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 donevia COM automation. The whole conversion process might take sometime, please leave your PC alone during that time and do not performother 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 formatDestination file type in the .VBS file: change .ASC to the supported requested destination file format.

这篇关于有没有办法在Vector CANoe中自动将BLF转换为CSV?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-23 01:24