需要一些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")
请看看message
type of python-can
。
例子:
如果要打印数据字段中的字节数,请使用
print(recvMsg.dlc)
如果要打印第一个数据字节,请使用
print(recvMsg.data[0])