0

我正在编写一个 python 程序来生成以下格式的 canbus 数据。

<0x18eeff01> [8] 05 a0 be 1c 00 a0 a0 c0

我为此使用 python-can 库并尝试读取上述消息格式。我无法弄清楚 <0x18eeff01> 表示的第一种格式是什么?我不知道我将如何在输出中产生它。


try:
    for i in range(0,200):
        msg=bus.recv(timeout=1)
        print("------")
        data = "{} [{}]".format(msg.channel,msg.dlc)
        for i in range(0,msg.dlc):
            data += " {}".format(msg.data[i])
        print(data)
        #Timestamp, Prio, PGN,src,dest, len, data



except can.CanError:
    print ("error")
finally:
    bus.shutdown()
f.close()````

Following is the output of this code:

````[8] 05 a0 be 1c 00 a0 a0 c0````

How can I produce whole string of the data as mentioned earlier?
4

1 回答 1

1

0x18eeff01 是十六进制形式的仲裁 id。您可以使用 msg.arbitration_id 获取它。 看这里

于 2020-06-13T17:38:48.310 回答