4

I am trying to figure out how to add comments to a .dbc file, but the DBC specification doesn't seem to address this.

I tried adding // and it seems to work, but I don't want to rely on undefined behaviour.

Ken Lin
  • 986
  • 1
  • 8
  • 22
  • I believe it's parens with an asterisk --- IE `(* Comment here *)` -- Not answering until you verify lol -- It's been a while since I worked with anything CanBus – Zak Feb 12 '20 at 21:14
  • It is clearly defined here: http://read.pudn.com/downloads766/ebook/3041455/DBC_File_Format_Documentation.pdf on page 2. The question is not clearly on-topic for SO being essentially a configuration file, and not code. – Clifford Feb 12 '20 at 22:32
  • 1
    @Clifford *being essentially a configuration file, and not code* -- While technically you are correct, think of them as plain text DLL files etc .. Even though it is called a configuration file, it acts like a programming language to help the program run. Conversely, a `php.ini` file or `my.cnf` file aren't programming languages either, but there are plenty of questions (with upvotes I might add) that positively contribute to the SO community – Zak Feb 13 '20 at 16:50

1 Answers1

2

I haven't found any way to add comments at arbitrary locations in a DBC file (the (* ... *) notation is only for comments in the documentation describing the DBC file syntax), but based on the example at the end of http://read.pudn.com/downloads766/ebook/3041455/DBC_File_Format_Documentation.pdf I determined that you can at least put explanatory comments in the comments section of the database itself, using the CM_ notation:

CM_ "This is an explanatory comment that must appear together with all the other
dbc object comments, but may span multiple lines within the quotes";
ncoghlan
  • 40,168
  • 10
  • 71
  • 80
  • Updated [link](https://github.com/stefanhoelzl/CANpy/blob/master/docs/DBC_Specification.md#cm_). CM_ has to be used after the Message and Signal definition. BDC editors (like CANdb++) might not open if the comments is not in the right section – lui Mar 10 '23 at 14:50