我有一个.blf文件,我必须将其转换为.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)
到目前为止我已经试过了。能够读取BLF文件,需要根据.asc文件写入数据
与我的另一个答案非常相似,你应该以二进制模式读取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()