opendbc icon indicating copy to clipboard operation
opendbc copied to clipboard

DBC files don't follow the spec

Open msalau opened this issue 5 years ago • 4 comments

Hello,

I tried to open the DBC files from the repo with CANdb++ Editor (the original tool used to create such files) and it fails. The reason for this is that the files (or the generator) don't follow the spec. Most of parsers found on Internet don't enforce order of statements in DBC files, but the original editor does.

The spec is not disclosed officially, so most of information is gathered through reverse engineering.

I know of 2 parsers that do enforce ordering of sections like the original editor does:

  1. https://bitbucket.org/tobylorenz/vector_dbc (reads data into C++ structures)
  2. https://github.com/msalau/dbc-parser (just prints scanned info to stdout)

The second one is mine, so I can help with it.

The original DBC parser expects the following ordering (all the sectional are optional if not stated otherwise):

  1. VERSION
  2. NS_ : ...
  3. BS_: (mandatory)
  4. BU_: (mandatory)
  5. VAL_TABLE_
  6. BO_ and SG_
  7. CM_
  8. BA_DEF_
  9. BA_DEF_DEF_
  10. BA_
  11. VAL_

Sections may not mix. There are few more sections not listed here, but their use is less widespread.

Hope that helps.

Regards, Maksim

msalau avatar Mar 28 '19 07:03 msalau

BTW,

As I understood, some comments are used to preprocess files (e.g. CM_ "IMPORT _honda_2017.dbc"). There is another mechanism to put statements into DBC files that will be ignored. Text appearing after // up to the end on line will be ignored by CANdb++. Just like C/C++ style comments. E.g.: // IMPORT _honda_2017.dbc

Regards, Maksim

P.S. Also please note that CM_ "IMPORT _honda_2017.dbc" is not a valid DBC statement disregarding place where it appears. CM_ statements must be terminated with ;

msalau avatar Mar 31 '19 17:03 msalau

@msalau , thanks, I agree that dbc files should be changed to follow a standard. It's not high priority for us to fix it now, but fell free to open a PR to address some/all the inconsistencies you see and we'll merge it in.

rbiasini avatar Mar 31 '19 21:03 rbiasini

Hi @rbiasini

It turned out there is already a PR to fix the issues in generated files: #113

As for the spec, the following document may be found: link It is outdated and incomplete, but covers basic functionality and requirements.

Regards, Maksim

msalau avatar Apr 04 '19 08:04 msalau

I also get error messages when I try to open vw_mqb_2010.dbc , may someone would like to fix this as a Christmas gift? :o)

EDIT: Must be something in the data block starting from line 1237 (BO_ 780 ACC_02: 8 XXX) and the block from line 1310 (CM_ SG_ 173 COUNTERXX "Message not renamed to COUNTER because J533 rate-limiting makes it look like messages are being lost") ...

Clubsport avatar Dec 23 '19 19:12 Clubsport