Not applicable
Nov 09, 2013
11:21 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Nov 09, 2013
11:21 AM
I developed a parser for .dbc files that can use a set of templates to output a subset of contained information into arbitrary formats.
The information it is currently able to output:
The possible output contains all the relations between databases, ECUs, Signal Groups, Messages, Signals etc.; this is very useful to generate documentation.
The (well documented) script can be found here:
https://github.com/lonkamikaze/hsk-libs/blob/master/scripts/dbc2c.awk
Download link: https://raw.githubusercontent.com/lonkamikaze/hsk-libs/master/scripts/dbc2c.awk
The set of templates I use can be found here:
https://github.com/lonkamikaze/hsk-libs/tree/master/scripts/templates.dbc2c
It contains templates to generate static code to read and write signals from and to character arrays (useful for 8-bit platforms). The generated code looks like this:
It can handle Intel and Motorola style signals as well as signed and unsigned signals.
In order to run the script an AWK interpreter is required. GNU AWK (default in many GNU/Linux distributions, very slow!), nawk (default on OS-X and BSDs) and mawk (default on Ubuntu GNU/Linux, very fast, available for Windows) are supported.
The script is released under the beerware do-anything-you-please license.
https://github.com/lonkamikaze/hsk-libs/blob/master/LICENSE
What I'd like to see in return are any of your .dbc's that cause problems with the script. If so desired I can guarantee confidential treatment.
kamikaze@bsdforen.de
GPG fingerprint: FDCD7B3A84C0FE21E21FF1E767BD05D6DCBF78A6
The information it is currently able to output:
- Databases (multiple .dbc files can be combined)
- ECUs
- Signal Groups
- Messages
- Signals
- Timeouts (an ECU → Signal relation)
The possible output contains all the relations between databases, ECUs, Signal Groups, Messages, Signals etc.; this is very useful to generate documentation.
The (well documented) script can be found here:
https://github.com/lonkamikaze/hsk-libs/blob/master/scripts/dbc2c.awk
Download link: https://raw.githubusercontent.com/lonkamikaze/hsk-libs/master/scripts/dbc2c.awk
The set of templates I use can be found here:
https://github.com/lonkamikaze/hsk-libs/tree/master/scripts/templates.dbc2c
It contains templates to generate static code to read and write signals from and to character arrays (useful for 8-bit platforms). The generated code looks like this:
12290 /**
12291 * Get signal FCU_BRAKE_BALANCE from buffer.
12292 *
12293 * @param buf
12294 * The can message buffer containing the signal
12295 * @return
12296 * The raw signal
12297 */
12298 #define GET_FCU_BRAKE_BALANCE(buf) (0 \
12299 | ((-((buf[2] >> 1) & 0x01)) << 18) \
12300 | ((+((buf[0] >> 0) & 0xff)) << 0) \
12301 | ((+((buf[1] >> 0) & 0xff)) << 😎 \
12302 | ((+((buf[2] >> 0) & 0x03)) << 16) \
12303 )
12304
12305 /**
12306 * Set signal FCU_BRAKE_BALANCE in buffer.
12307 *
12308 * @param buf
12309 * The can message buffer to add the signal to
12310 * @param val
12311 * The raw value to set the signal to
12312 */
12313 #define SET_FCU_BRAKE_BALANCE(buf, val) { \
12314 buf[0] &= ~(0xff << 0); \
12315 buf[0] |= (((val) >> 0) & 0xff) << 0; \
12316 buf[1] &= ~(0xff << 0); \
12317 buf[1] |= (((val) >> 😎 & 0xff) << 0; \
12318 buf[2] &= ~(0x03 << 0); \
12319 buf[2] |= (((val) >> 16) & 0x03) << 0; \
12320 }
It can handle Intel and Motorola style signals as well as signed and unsigned signals.
In order to run the script an AWK interpreter is required. GNU AWK (default in many GNU/Linux distributions, very slow!), nawk (default on OS-X and BSDs) and mawk (default on Ubuntu GNU/Linux, very fast, available for Windows) are supported.
The script is released under the beerware do-anything-you-please license.
https://github.com/lonkamikaze/hsk-libs/blob/master/LICENSE
What I'd like to see in return are any of your .dbc's that cause problems with the script. If so desired I can guarantee confidential treatment.
kamikaze@bsdforen.de
GPG fingerprint: FDCD7B3A84C0FE21E21FF1E767BD05D6DCBF78A6
Labels
- Labels:
-
XC800
- Tags:
- IFX
2 Replies
Not applicable
Oct 29, 2015
06:30 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Oct 29, 2015
06:30 AM
Very interesting code!
Do you have any document descriving DBC file format?
thanks
Do you have any document descriving DBC file format?
thanks
Not applicable
Aug 09, 2016
06:33 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Aug 09, 2016
06:33 AM
gauze wrote:I guess I should pick up the habit of checking this forum more often.
Very interesting code!
Do you have any document descriving DBC file format?
thanks
Any way, no I do not have documentation. This is a reverse engineering effort.
The code is written to fail if something unknown is encountered. In the past people have sent me DBC files that make it fail and I've used those to extend the parser.