如何编写一个命令来生成特定格式的canbus数据?

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

我正在编写一个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?
python can-bus socketcan
1个回答
1
投票

0x18eeff01是十六进制形式的仲裁ID。你可以用msg.arbitrage_id来获取它。请看这里

© www.soinside.com 2019 - 2024. All rights reserved.