Skip to content

Supported DBC statements ​

CanViewer reads DBC files with its own parser, parser.ts, into the model in types.ts that every view uses.

Modelled ​

StatementWhat CanViewer reads from it
VERSIONThe version string, shown on the overview
BU_The nodes (ECUs)
BO_Messages: ID (with the extended-frame flag, bit 31), name, DLC, sender
SG_Signals: start bit, length, byte order, signedness, factor, offset, range, unit, receivers, multiplexing (M, m<N>, and m<N>M for extended multiplexing)
BO_TX_BU_Further transmitters of a message
CM_Comments on the network, nodes, messages and signals, multi-line ones included
VAL_A signal's value descriptions
VAL_TABLE_Named value tables
BA_DEF_Attribute definitions: object type, value type (INT, HEX, FLOAT, STRING, ENUM), range, enum values
BA_DEF_DEF_Attribute defaults
BA_Attribute values on the network, nodes, messages and signals; ENUM indexes are resolved to their labels
SIG_VALTYPE_Float (32-bit) and double (64-bit) signals
SG_MUL_VAL_Extended multiplexing: the switch signal and value ranges that activate a signal

Statements that may wrap across lines (CM_, BA_DEF_, BA_DEF_DEF_, BA_, VAL_, VAL_TABLE_ and the other ;-terminated ones) are joined before parsing. The parser accepts UTF-8 and Windows-1252 files (see Encodings).

Recognized, not modelled ​

These statements are valid DBC, but no view shows them. CanViewer counts them and lists them on the overview under Not displayed, instead of reporting them as problems:

NS_, NS_DESC_, BS_, EV_, ENVVAR_DATA_, EV_DATA_, SGTYPE_, SGTYPE_VAL_, BA_DEF_SGTYPE_, BA_SGTYPE_, SIG_TYPE_REF_, SIG_GROUP_, SIGTYPE_VALTYPE_, BA_DEF_REL_, BA_DEF_DEF_REL_, BA_REL_, BU_SG_REL_, BU_EV_REL_, BU_BO_REL_, CAT_DEF_, CAT_ and FILTER.

That covers environment variables, signal types and groups, relation attributes (attributes on a node-signal or node-message pair) and categories.

What becomes a problem ​

Anything else is reported as a parse problem with its line number, and the rest of the file loads normally:

  • a statement CanViewer does not know (unrecognized statement);
  • a statement it knows but cannot read (malformed …), such as an SG_ line that does not follow the grammar, or a signal with an invalid start bit or length;
  • a reference to something that does not exist (… references unknown …), such as a CM_, VAL_, BA_ or SIG_VALTYPE_ statement for a signal, message or node the file does not define;
  • a second message with an ID that is already taken (comments and attributes attach to the first).

Tested against real-world files ​

The corpus suite, corpus.test.ts, parses 58 DBC files from carmakers: the databases of commaai/opendbc and joshwardell/model3dbc, from Toyota, Tesla, BMW, Mercedes, VW, Ford, GM, Hyundai, Mazda, Chrysler, Volvo, PSA, Nissan, Rivian and more. Every file must parse without problems, except for a pinned list of genuine inconsistencies in the upstream files (comments that name signals which were renamed or removed). What the parser makes of each file is pinned in corpus-baseline.json, including a SHA-256 of the whole parsed model, so any change to how a file parses fails the suite.

Totals over the corpus:

Corpus total
Files58
Messages4,167
Extended (29-bit) messages448
CAN FD messages413
J1939 parameter groups0
Signals33,651
Multiplexor signals61
Multiplexed signals1,891
Signals with extended multiplexing (SG_MUL_VAL_)18
Float and double signals (SIG_VALTYPE_)0
Signals with value descriptions6,427
Signals with a comment1,272
Nodes395
Value tables958
Attribute definitions284
Files with parse problems7
Parse problems36

The statements that occur in the corpus but are not modelled:

StatementFilesStatements
BS_5353
NS_5353

Features the corpus has few or none of (see the totals) are covered by examples/demo.dbc and the parser's unit tests, parser.test.ts.