Python-Can Bus,只抓取字节?

问题描述 投票:-1回答:1

需要一些Python-can的帮助。目前,我的代码只是接收2秒延迟的数据,因此shell不会泛滥。

我如何过滤信息,只是这样我可以使用收到的字节来解释信息?此刻它给了我一切。

import can
import time

bus = can.interface.Bus(bustype='nican', channel='CAN0', bitrate=1000000)

recvMsg = bus.recv(timeout=None)
while(recvMsg is not None):
    print (recvMsg.)
    time.sleep(2)
else:
    print ("None")
python filtering protocols can-bus
1个回答
0
投票

请看看message type of python-can

例子:

如果要打印数据字段中的字节数,请使用

print(recvMsg.dlc)

如果要打印第一个数据字节,请使用

print(recvMsg.data[0])
© www.soinside.com 2019 - 2024. All rights reserved.