CAN Bus Log Decoder for DBC Files
Operator: Abdulla Al Fahad. How tools are built and checked
A CAN log is a list of identifiers and eight to sixty-four bytes each, and every number you care about is hiding in a bit field of those bytes. A DBC file says where: engine speed starts at bit 0, 16 bits, little endian, 0.25 rpm per count. This page applies one or several DBC files to a candump, Vector ASC, PEAK TRC or SavvyCAN log, shows each signal's range and last value, plots up to four of them over time, tells you which identifiers the DBC does not describe, and checks the DBC itself for bits that overlap or run past their frame.
Key features
- Logs in candump -l, candump screen, Vector ASC, PEAK TRC and SavvyCAN GVRET CSV formats, including remote frames, error frames and CAN FD frames
- Several DBC files merged into one message list
- Intel (little-endian) and Motorola (big-endian) signals, signed and unsigned, with factor and offset, up to 64 bits wide
- Value tables, so a raw 3 is shown as Drive when the DBC says so, and 32-bit float and 64-bit double signals
- Multiplexed signals, including multiplexors that are themselves multiplexed and extended multiplexing ranges
- J1939 priority, PGN and source address from 29-bit identifiers, and matching of J1939 messages by PGN
- Per-identifier counts, rates, minimum and maximum period, error-frame count, an estimated bus load and a list of identifiers missing from the DBC
- A DBC check, long and wide CSV exports of the decoded signals, and a filtered candump file
Log formats, DBC features and bit numbering
A candump -l file has lines like (1436509052.249713) can0 123#DEADBEEF, with ## for CAN FD and #R for a remote frame; an eight-digit identifier is read as extended. Vector ASC files are recognised by their base line or by a data line, with identifiers in hex unless the header says dec. PEAK TRC lines are read with their millisecond time offsets, and SavvyCAN GVRET files by the Time Stamp, ID, Extended, Bus, LEN and D1 columns, with the time in microseconds. BLF and MF4 logs are not read.
A log can hold up to 2 million frames and 120 MB of text. Lines that cannot be read are counted and the first one is quoted, so a wrong format shows up as a number, not as silence. Times are shown from the first frame, whatever the log's own clock.
In a DBC the message line BO_ gives the identifier, name, length and sender, and each SG_ line gives a signal's start bit, length, byte order (@1 Intel, @0 Motorola), sign, factor and offset. An identifier with its top bit set marks a 29-bit frame. VAL_, SIG_VALTYPE_, SG_MUL_VAL_ and the ProtocolType and VFrameFormat attributes are used; everything else in the file is ignored, and the file is never rewritten.
How it works
For an Intel signal the start bit is its least significant bit, and bits count upward through the bytes. For a Motorola signal the start bit is the most significant bit, bits run downward inside a byte, and after bit 0 of a byte the next bit is bit 7 of the following byte. A signal whose bits do not all lie inside the frame decodes to nothing rather than reading past the data.
Multiplexed signals are active only when the multiplexor has the matching value. With extended multiplexing each signal lists the multiplexor and the value ranges it listens to, and a multiplexor that is itself multiplexed is resolved first.
When this helps
- A test engineer plots EngineSpeed and CoolantTemp for a drive cycle: at 6.23 s the example shows 2,146.75 rpm and 79 degC with the gear in Drive.
- A calibration engineer edits a DBC and runs the check: a new 12-bit Intel signal at bit 56 of an 8-byte message is reported as reaching beyond the message, before it is flashed anywhere.
- A diagnostics engineer sees 0x7DF in the unknown table, one frame with the data 02 01 05 00 00 00 00 00, and recognises an OBD-II request for coolant temperature.
- A truck telematics developer turns on PGN matching: a CCVS message defined with source address 0 is decoded for frames from source addresses 0x00 and 0x33 and with priorities 3 and 6.
- A student exports the SensorMux message as a wide CSV and gets one row per frame with blank cells for the signals whose multiplexor value did not select them.
Opening a file
- Drop the DBC files, then the log, or load the example.
- Check the summary for the format, the duration and how many lines were skipped.
- Open the identifier table and look for rows marked not in the DBC.
- Choose a message in the signal browser and tick up to four signals to plot.
Example
The page's example: a ten-second synthetic log made with its own three-message DBC
DBC: EngineData 0x100 (Intel signals), VehicleSpeed 0x200 (Motorola signals), SensorMux 0x300 (multiplexed). Log: 1,601 frames.Identifier table and one decoded frame
0x100 EngineData: 1,000 frames at 100.00 Hz, 10.00 ms period
0x200 VehicleSpeed: 500 frames at 50.00 Hz
0x300 SensorMux: 100 frames at 10.00 Hz
0x7DF: 1 frame, not in the DBC. Estimated bus load at 500 kbit/s: 3.56%
First EngineData frame 80 0C 2D 6E 00 00 00 00: EngineSpeed 800.00 rpm, ThrottlePos 18.00 %, CoolantTemp 70 degC, GearState 0 (Park)Tips for best results
- Tick the identifiers you want in the identifier table and download them as a candump file to hand a colleague just those messages.
- A message whose rate shows as 10.00 Hz with a maximum period far above 100 ms has dropped frames or a busy bus; the minimum and maximum period columns make that visible.
- If a signal reads sensibly in one tool and wrongly here, compare the byte order first. A DBC that says @0 means Motorola with the start bit at the most significant end, a convention some viewers display differently.
- Merge the DBC for the vehicle and the DBC for an add-on device by loading both; a duplicate identifier between them is reported by the check.
Limits
The bus load is a nominal figure: 47 plus 8 bits per data byte for a standard frame and 67 plus 8 for an extended one, with no bit stuffing and no allowance for error frames. CAN FD frames are counted the same way, so their load is only a rough figure.
A raw value above 2^53 loses its low bits, because the numbers are doubles. Signals that wide are rare, but a 64-bit counter will show rounding.
PEAK TRC and Vector CAN FD line formats vary between versions. The parser accepts the common layouts, reads a PEAK TRC identifier of up to four hex digits as standard and longer ones as extended, and counts anything else as skipped, but a file in an unusual layout should be checked against the skipped count.
Logs from several buses decode by identifier only. If two buses use the same identifier for different messages, their signals are mixed in the plots.
The check reports overlapping bits only for signals that can be present together, so two signals of different multiplexor values may share bits without a finding, as they should.
Common errors and how to fix them
- This does not look like a candump, Vector ASC, PEAK TRC or SavvyCAN CSV log.
- Open the file in a text editor and check its first lines; a BLF or MF4 file is binary and must be converted to ASC or candump first.
- The log has more than 2,000,000 frames. Cut it into parts.
- Split the file by time, or filter it to the identifiers of interest with the tool that recorded it.
Best practices
- Keep the DBC under version control with the vehicle software version it matches, since a decoded value is only as right as the file.
- Check the unknown identifiers before blaming a signal definition: a message the DBC lacks often explains a missing signal.
- Read the skipped-line count after every load; a few skipped lines are headers, thousands mean a format the parser did not understand.
- Plot a signal against the raw bytes of one frame at least once, to be sure the byte order is the one you meant.
Bit numbering, with two worked frames
VehicleSpeed has the signal Speed : 7|16@0+ with a factor of 0.01. Motorola numbering starts at bit 7 of byte 0, so the two bytes 12 34 give 0x1234 = 4,660 and a speed of 46.60 km/h. An Intel signal 0|16@1+ with a factor of 0.25 reads the same bytes the other way round: 34 12 is 0x1234, which is 1,165 rpm.
A Motorola signal 52|12@0+ starts at bit 4 of byte 6, takes bits 4 to 0 of that byte and then bits 7 to 1 of byte 7. With bytes 1A BC that is 0x1A in the top five bits and 0xBC shifted right by one, 26 × 128 + 94 = 3,422.
What the DBC check reports
The check lists duplicate identifiers and message names, a standard frame with an identifier above 0x7FF, signals that reach beyond the message length, signals of zero or over 64 bits, a factor of zero, float and double signals that are not 32 and 64 bits wide, multiplexed signals without a multiplexor, several multiplexors in one message and overlapping signals. Each finding names the message and signals, so you can fix it in the file.
Frequently asked questions
Was the bit extraction checked?
Decoding was checked on hand-worked cases. A Motorola 16-bit signal at start bit 7 with bytes 12 34 gives 4,660, the 12-bit signal crossing from byte 6 to byte 7 gives 3,422, a signed Intel 12-bit field of 0xFF0 gives -16, and a 32-bit float with bytes 00 00 C0 3F gives 1.5. An encoder written independently of the decoder and run on 2,281 random Intel and Motorola signals returned every value. J1939 identifiers decode as 0x18FEF100 to priority 6, PGN 65,265 and source address 0, and 0x0CF00400 to PGN 61,444. No comparison with cantools or Vector tools was run.
Can it write a DBC file?
No. It reads DBC files and reports on them but never changes or saves them.
Why is a signal missing from the plot list?
Only signals that were decoded at least once can be ticked. A multiplexed signal whose multiplexor value never occurs in the log, or one that lies outside the frames' length, has no samples.
What does PGN matching change?
Without it a frame is matched to the DBC only if its full identifier is equal. With it, and when the DBC marks messages as J1939, priority and source address are ignored, so the same PGN from different ECUs decodes with one definition.
Are a standard and an extended frame with the same number the same message?
No. A standard 0x123 and an extended 0x00000123 are different identifiers and each is matched to its own DBC message. The identifier table marks extended identifiers with an x.