cantools: Can't load DBC file with extended frames

After updating up to 22 version, it was lose ability to load DBC files with extended frames.

import cantools
db = cantools.db.load_file(some_extended_db)

If frame ID has high bit is on, I get assert error on such frame:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "build/bdist.linux-x86_64/egg/cantools/db/__init__.py", line 67, in load_file
  File "build/bdist.linux-x86_64/egg/cantools/db/__init__.py", line 89, in load
  File "build/bdist.linux-x86_64/egg/cantools/db/__init__.py", line 123, in load_string
  File "build/bdist.linux-x86_64/egg/cantools/db/database.py", line 123, in add_dbc_string
  File "build/bdist.linux-x86_64/egg/cantools/db/formats/dbc.py", line 1139, in load_string
  File "build/bdist.linux-x86_64/egg/cantools/db/formats/dbc.py", line 702, in _load_attributes
KeyError: 3221225472

But, if I remove only high bit from frame id, the same dbc successfully loaded.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 29 (2 by maintainers)

Most upvoted comments

@JulianWgs Concerning tests: The attributes test covers this case when PR is merged, I have added such a signal attribute.

Hello @JulianWgs. Thanks for reporting. This bug is waiting for merge (#45) already. It happend due to a missing initialisation when the load_attributes method hit a signal attribute without having a message attribute with the same id before.

If you need a quick fix, just look at PR #45, commit 9b37564, the four lines at the very bottom.