【问题标题】:cantools.database.errors.Error: Standard frame id is more than 11 bitscantools.database.errors.Error:标准帧 id 超过 11 位
【发布时间】:2021-06-22 20:16:00
【问题描述】:

我使用 cantools python 包来解码 canbus 消息。我使用我创建的 dbc 文件进行测试。我复制了一个示例文件。当我使用像 419358976 这样的 can id 时,我收到错误消息。但是对于像 350 这样的更小的罐头 ID,它可以工作。 cantools 是否会因扩展帧 ID 而失败?我如何让它工作?

我的扩展 ID 失败的代码如下:

db = cantools.database.load_file('.\\src\\test\\resources\\j1939.dbc')
print(db.decode_message(419358976,b'\xff\xff\xff\xc0\x0c\xff\xff\xff'))

错误:cantools.database.errors.Error: Standard frame id 0x18fee900 is more than 11 bits in message EEC1.

【问题讨论】:

    标签: python-3.x can-bus socketcan python-can


    【解决方案1】:

    我找到了我的问题的答案。像 419358976 这样的罐头 ID 是扩展 ID。因此,为了将该 id 映射到 dbc 文件中的 id,我需要将另一个 32 位十六进制数 8000 0000 添加到 hex can id。然后将该结果十六进制数转换为十进制数并将其用作 dbc 文件中的 id 字段。之后它可以完美运行。上面的错误信息消失了

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-08-12
      • 1970-01-01
      • 2020-02-19
      • 1970-01-01
      • 2012-08-17
      相关资源
      最近更新 更多