· 5 Min. Lesezeit

Decoding a CAN Log File: IDs, DLC and Intel vs Motorola Endianness

Opening a raw .log file shouldn't require a PhD in binary voodoo. Here is how CAN decoding actually works — byte order, factor/offset, DLC — and where most people get it wrong.

Opening a CAN log file without a DBC is like reading a conversation in a language you don't speak — you can see the words, but not what they mean. Opening one WITH a DBC but the wrong byte order interpretation is like reading it backwards. Either way, you get garbage.

The anatomy of a CAN frame

Every classical CAN frame contains:

  • Arbitration ID: 11 bits (standard, 0–0x7FF) or 29 bits (extended, 0–0x1FFFFFFF). Extended IDs have the IDE bit set.
  • DLC: Data Length Code, 0 to 8 bytes for classic CAN, 0 to 64 for CAN FD (non-linear encoding above 8).
  • Data: the actual payload bytes
  • CRC, ACK, EOF: handled by hardware, not relevant to decoding

In a log file, you typically see something like:

0.000100  1  0100  Rx  d  8  A0 12 00 FF 3C 00 00 00

Timestamp, channel, ID (0x100), direction, d=data frame, DLC=8, then 8 bytes of data.

From raw bytes to physical values

Each signal in the DBC maps to a specific bit range in the data field. To decode:

  • Extract the raw integer value from the specified bits
  • Apply: physical_value = raw_value × factor + offset
  • Check against min/max (engineering range, not encoding range)
  • If a VAL_ table exists, look up the enumeration

Example: EngineSpeed (16 bits, factor 0.25, offset 0), raw value 0x1900 = 6400, physical value = 6400 × 0.25 = 1600 rpm.

Intel vs Motorola byte order: the source of most confusion

This is where most debugging time gets lost. DBC signals specify byte order as `@1` (Intel, little-endian) or `@0` (Motorola, big-endian).

Intel byte order (the more common in modern CAN)

The start bit is the Least Significant Bit (LSB). The signal's bits are numbered in memory order — bit 0 is the LSB of byte 0, bit 7 is the MSB of byte 0, bit 8 is the LSB of byte 1.

For a 16-bit Intel signal starting at bit 0:

  • Byte 0: bits 7-0 → lower byte of the value
  • Byte 1: bits 15-8 → upper byte of the value

Motorola byte order

The start bit is the Most Significant Bit (MSB). The bit numbering in the layout goes from MSB to LSB across bytes in network order. The confusion comes from the DBC convention: for Motorola signals, the 'start bit' field refers to the MSB position in a different numbering scheme, not the same bit grid as Intel signals.

K-Matrix Studio shows you both

The bit layout view in K-Matrix Studio renders every signal's actual bit positions in a color-coded grid — regardless of byte order. You see exactly which bits belong to which signal, in the correct visual position. No mental gymnastics required.

Common mistakes

  • Wrong byte order flag: the signal decodes to a wildly incorrect value, usually way outside the engineering range
  • Off-by-one start bit: adjacent signals overlap or leave unexplained gaps — visible immediately in the bit layout view
  • Unsigned vs signed: a signal reading 65535 when you expect -1 is a sign extension issue — check the +/- flag after the bit count

If your decoded values look wrong, open the bit layout. If the bit assignment looks wrong, check the byte order. If the byte order looks right but the value is still off, check the factor and offset. In that order.