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 had 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.