簡體   English   中英

如何使用 python 將 CAN 的.blf 數據轉換為.asc

[英]How do I convert .blf data of CAN to .asc using python

我有一個 .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)

到目前為止,我已經嘗試過了。 能夠讀取 BLF 文件,需要按照 per.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()

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM