Decoding 29-Bit SAE J1939 CAN IDs into Priority, PGN & Source Address
Commercial trucks, agricultural/construction machinery, marine NMEA 2000 vessels, and heavy-duty EV inverters encode routing metadata directly inside the 29-bit extended CAN identifier under SAE J1939-21.
1. Stripping the Vector DBC Bit-31 Extended Flag (0x80000000)
In .dbc files, 29-bit extended frames set unsigned bit 31 (1 << 31 = 2147483648 = 0x80000000) on the BO_ integer ID:
BO_ 2364539904 J1939_EEC1_EngineCtrl: 8 INV
// 2364539904 = 0x8CF00400 --> 29-bit wire CAN ID = 0x0CF00400
2. Exact PDU1 (PF < 240) vs. PDU2 (PF ≥ 240) PGN Formula
uint32_t id29 = raw_dbc_id & 0x1FFFFFFFu;
uint8_t prio = (id29 >> 26) & 0x07u; // Bits 28..26 (0..7)
uint8_t dp = (id29 >> 24) & 0x03u; // Bits 25..24 (EDP + DP)
uint8_t pf = (id29 >> 16) & 0xFFu; // Bits 23..16 (PDU Format)
uint8_t ps = (id29 >> 8) & 0xFFu; // Bits 15..8 (Dest Addr or Group Ext)
uint8_t sa = id29 & 0xFFu; // Bits 7..0 (Source Address)
// Peer-to-peer PDU1 zeroes PS; broadcast PDU2 includes PS in PGN:
uint32_t pgn = (pf < 240u) ? (((uint32_t)dp << 16) | ((uint32_t)pf << 8))
: (((uint32_t)dp << 16) | ((uint32_t)pf << 8) | ps);
Worked example for 0x0CF00400 (EEC1): Priority = 3, PF = 0xF0 (240 ≥ 240 → PDU2 Broadcast), PS = 0x04, PGN = 0x0F004 = 61444, SA = 0x00 (Engine #1).

Frequently Asked Engineering Questions
Why is PS excluded from the PGN when PF is less than 240?
In SAE J1939 PDU1 messages (PF 0..239), the 8-bit PS field carries the target ECU Destination Address rather than a static group extension, so masking PS out keeps the Parameter Group Number constant regardless of which node is addressed.
Inspect, Validate, Diff, Decode & Scrub CAN / AUTOSAR Offline in Your JetBrains IDE
Never paste OEM NDA .dbc or AUTOSAR .arxml signal matrices into browser viewers. CanPrism DBC ARXML Viewer runs 100% air-gapped inside CLion, PyCharm, RustRover, IntelliJ IDEA, Rider, DataGrip, GoLand, and WebStorm with a forever-free core tier and a 14-day [Pro] trial.