简体   繁体   English

如何使用 python 将 CAN 的.blf 数据转换为.asc

[英]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.

相关问题 如何按照矢量格式使用 python 将 CAN 的 .asc 数据转换为 .blf - How do I convert .asc data of CAN to .blf using python as per vector format 如何使用 python 将 .blf 数据从 CAN 转换为 .csv - How do I convert .blf data from CAN to .csv using python 如何使用python-can修复损坏的.blf文件(来自Vector软件) - How do I fix a corrupted .blf file (from Vector software) using python-can Python 解析包含 CAN-TP Trame (ISO-TP) 的 CAN 日志文件(.asc 或 blf) - Python Parse a CAN log file (.asc or blf) that contains CAN-TP Trame (ISO-TP) Python CAN 日志转换器用于以下日志类型(ASC、BLF、CSV、LOG) - Python CAN Log Converter for the following log types (ASC, BLF, CSV, LOG) 如何使用python将我的字节数据转换为整数? - How do I convert my byte data to integer using python? 为什么我不能在Python中将对象转换为int,如何检查麻烦的数据? - Why can I not convert an object to int in Python and how do I check the troublesome data? 如何使用Python以.asc文件格式读取/提取气候模型数据? - How to read/extract climate model data in .asc file format by using Python? 如何使用 Python 将一系列重复的数据行转换为多条记录的列? - How do I convert a series of repeated data rows into columns of multiple records using Python? 如何使用 Python 脚本将 JSON 数据转换为蛋白质数据库 (PDB)? - How can I convert JSON data to Protein Data Bank (PDB) using Python script?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM