[英]How do I convert .blf data of CAN to .asc using python
I have a.blf file, I have to convert that to a.asc file so that my ASCREADER is able to read the data.我有一个 .blf 文件,我必须将其转换为 a.asc 文件,以便我的 ASCREADER 能够读取数据。
from can.io.blf import BLFReader
blf_file = "/home/ranjeet/Downloads/CAN/BLF_Files/input.blf"
with BLFReader(blf_file) as can_log:
for msg in can_log:
print(msg)
I've tried this so far.到目前为止,我已经尝试过了。 Able to read BLF File, need to write data as per.asc file
能够读取 BLF 文件,需要按照 per.asc 文件写入数据
Very similar to my other answer you should read your blf file in binary mode then write the messages in the asc one:与我的其他答案非常相似,您应该以二进制模式读取 blf 文件,然后在 asc 中写入消息:
import can
with open(blf_file, 'rb') as f_in:
log_in = can.io.BLFReader(f_in)
with open("file_out.asc", 'w') as f_out:
log_out = can.io.ASCWriter(f_out)
for msg in log_in:
log_out.on_message_received(msg)
log_out.stop()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.