- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个包含多个 CAN 总线消息的 .blf 文件,我可以像这样使用 python-can 读取该消息
import can
can_log = can.BLFReader("./test.blf")
for msg in can_log:
print(msg)
根据 python-can 文档,标准 .blf 文件的 header 有 144 个字节,包含整个记录本身的开始和结束时间戳。
我想直接读取这个开始和结束时间戳,可以吗?
我知道我也可以使用 msg.timestamp 从第一条消息中读取时间戳,但它与我想要提取的开始时间戳略有不同。
最佳答案
来自 source code python 可以:
[...]
class BLFReader(object):
"""
Iterator of CAN messages from a Binary Logging File.
Only CAN messages and error frames are supported. Other object types are
silently ignored.
"""
def __init__(self, filename):
self.fp = open(filename, "rb")
data = self.fp.read(FILE_HEADER_STRUCT.size)
header = FILE_HEADER_STRUCT.unpack(data)
#print(header)
assert header[0] == b"LOGG", "Unknown file format"
self.file_size = header[10]
self.uncompressed_size = header[11]
self.object_count = header[12]
self.start_timestamp = systemtime_to_timestamp(header[14:22])
self.stop_timestamp = systemtime_to_timestamp(header[22:30])
[...]
您可以这样使用 start_timestamp 和 stop_timestamp :
can_log.start_timestamp
关于python - 读取.blf CAN文件的 header ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56293298/
我有一个包含多个 CAN 总线消息的 .blf 文件,我可以像这样使用 python-can 读取该消息 import can can_log = can.BLFReader("./test.blf"
我正在查看这段代码: http://lxr.free-electrons.com/source/arch/x86/include/asm/bitops.h 静态内联无符号长__ffs(无符号长字) {
我的第一个方法是使用 python-can (因为它在 2.0.0 版本中添加了对解析 BLF 文件的支持)如下所示: import can filename = "logfile.blf" logg
我有来自 Vector 软件的 blf 格式的 CAN 数据。为了进一步调查,我想使用 python 将其转换为 csv 格式。 到目前为止我的进步: import can filename = "t
这类似于 this question ,但我想最终得到一个新的 BLF 文件而不是 .csv 文件。我这样做是为了删除 BLF 文件中损坏的对象,该对象阻止我将其导入 Vector 的软件。我想有一种
我是一名优秀的程序员,十分优秀!