In short
J1939 splits long messages into 7-byte packets. A TP.CM frame (PGN 60416) announces the message, and TP.DT frames (PGN 60160) carry the data. BAM broadcasts without a handshake; RTS/CTS sends to one ECU with flow control.
Best for: Engineers decoding J1939 logs or writing J1939 software who meet messages longer than 8 bytes
A classical CAN frame carries 8 bytes. Some J1939 messages are longer: a DM1 with three fault codes is 14 bytes, and a VIN is 17 characters. J1939 sends these with its transport protocol, defined in SAE J1939-21. In a log, it looks like a burst of frames with IDs ending in EC and EB instead of the PGN you were looking for.
Two PGNs do all the work
| Frame | PGN | Hex | Job |
|---|---|---|---|
| TP.CM (connection management) | 60416 | 0xEC00 | Announces, controls, and ends a transfer |
| TP.DT (data transfer) | 60160 | 0xEB00 | Carries the data, 7 bytes per packet |
The PGN of the real message, for example DM1 (65226), never appears in the CAN ID. It is written inside the TP.CM frame. That is why searching a log for FECA misses multi-packet DM1 messages.
A transfer can carry up to 1785 bytes: 255 packets of 7 bytes.
BAM: broadcast to everyone
BAM (Broadcast Announce Message) sends a long message to all ECUs. There is no handshake: the sender announces the message, then sends the packets.
Here is a DM1 with two faults (10 bytes) from the engine at address 0x00:
1CECFF00 [8] 20 0A 00 02 FF CA FE 00 TP.CM BAM
1CEBFF00 [8] 01 04 FF 6E 00 00 03 64 TP.DT packet 1
1CEBFF00 [8] 02 00 01 01 FF FF FF FF TP.DT packet 2
The ID 1CECFF00 reads as priority 7, PGN 0xEC00 (TP.CM), destination 0xFF (everyone), source 0x00.
The BAM frame:
| Byte | Value | Meaning |
|---|---|---|
| 1 | 20 | Control byte 32 = BAM |
| 2–3 | 0A 00 | Message size, 10 bytes, low byte first |
| 4 | 02 | Number of packets |
| 5 | FF | Reserved |
| 6–8 | CA FE 00 | PGN of the message, 65226 (0x00FECA), low byte first |
Each TP.DT frame starts with a sequence number from 1, followed by 7 data bytes. The last packet is padded with FF. Joining the data and cutting it to 10 bytes gives:
04 FF 6E 00 00 03 64 00 01 01
That is the DM1 payload: lamps 04 FF, then fault 6E 00 00 03 (SPN 110, FMI 0) and fault 64 00 01 01 (SPN 100, FMI 1). The DM1 guide explains how to read those bytes.
BAM senders leave a gap between data packets, typically about 50 ms, so slower receivers can keep up. A 10-packet BAM therefore takes about half a second.
RTS/CTS: a connection to one ECU
When a message goes to one specific ECU, J1939 uses a connection with flow control:
Sender Receiver
| --- TP.CM RTS (size, packets) ---> |
| <-- TP.CM CTS (send 2, start at 1) - |
| --- TP.DT 1 -----------------------> |
| --- TP.DT 2 -----------------------> |
| <-- TP.CM CTS (send 2, start at 3) - |
| --- TP.DT 3 -----------------------> |
| --- TP.DT 4 -----------------------> |
| <-- TP.CM End of Message Ack ------- |
The receiver controls the pace. It can ask for a few packets at a time, ask for a packet again, or send a CTS that allows zero packets to pause the transfer.
The TP.CM control byte says which frame it is:
| Control byte | Hex | Frame |
|---|---|---|
| 16 | 0x10 | RTS: request to send |
| 17 | 0x11 | CTS: clear to send |
| 19 | 0x13 | End of message acknowledgement |
| 32 | 0x20 | BAM |
| 255 | 0xFF | Connection abort |
In RTS/CTS frames, the CAN ID carries the destination address instead of FF. A request to send from the tester at 0xF9 to the engine at 0x00 uses an ID like 1CEC00F9.
| Frame | Bytes 2–5 | Bytes 6–8 |
|---|---|---|
| RTS | Size (2 bytes), packets, max packets per CTS | PGN |
| CTS | Packets allowed, next packet number, 2 reserved | PGN |
| End of message ack | Size (2 bytes), packets, reserved | PGN |
| Abort | Reason, 3 reserved | PGN |
Which one is used when
| BAM | RTS/CTS | |
|---|---|---|
| Destination | All ECUs (0xFF) | One ECU |
| Handshake | None | RTS, CTS, acknowledgement |
| Flow control | Fixed gaps between packets | Receiver decides |
| Lost packet | Message is lost; wait for the next broadcast | Receiver asks again |
| Typical use | DM1 with several faults, broadcast data | Requests and replies between two ECUs |
J1939-21 requires an ECU to support one BAM session and one RTS/CTS session at the same time.
Reassemble BAM messages in Python
This class follows BAM transfers per source address and returns the full message when the last packet arrives. Feed it every frame from a log or a live bus.
TP_CM, TP_DT = 0xEC00, 0xEB00
def pgn_of(can_id: int) -> int:
pdu_format = (can_id >> 16) & 0xFF
pdu_specific = (can_id >> 8) & 0xFF if pdu_format >= 240 else 0
return ((can_id >> 24) & 0x3) << 16 | pdu_format << 8 | pdu_specific
class BamReassembler:
def __init__(self):
self.sessions = {}
def feed(self, can_id: int, data: bytes):
"""Returns (pgn, source, payload) when a BAM message is complete, otherwise None."""
pgn, source = pgn_of(can_id), can_id & 0xFF
if pgn == TP_CM and data[0] == 0x20: # BAM announcement
self.sessions[source] = {
"pgn": data[5] | data[6] << 8 | data[7] << 16,
"size": data[1] | data[2] << 8,
"packets": data[3],
"next": 1,
"data": bytearray(),
}
elif pgn == TP_DT and source in self.sessions:
session = self.sessions[source]
if data[0] != session["next"]: # lost or repeated packet
del self.sessions[source]
return None
session["data"] += data[1:8]
session["next"] += 1
if session["next"] > session["packets"]:
del self.sessions[source]
return session["pgn"], source, bytes(session["data"][:session["size"]])
return None
reassembler = BamReassembler()
frames = [
(0x1CECFF00, bytes.fromhex("200A0002FFCAFE00")),
(0x1CEBFF00, bytes.fromhex("0104FF6E00000364")),
(0x1CEBFF00, bytes.fromhex("02000101FFFFFFFF")),
]
for can_id, data in frames:
result = reassembler.feed(can_id, data)
if result:
pgn, source, payload = result
print(pgn, hex(source), payload.hex(" "))
Output:
65226 0x0 04 ff 6e 00 00 03 64 00 01 01
The session is keyed by source address because two ECUs can broadcast at the same time. If a packet is missing, the message is dropped; for BAM that is the correct behaviour, since nobody can ask for a resend.
For RTS/CTS you also need to send CTS and acknowledgement frames, so use a J1939 stack rather than a passive decoder. On Linux, the kernel's J1939 sockets handle both kinds of transfer for you, and in Python the can-j1939 package does the same on top of python-can.
Debugging tips
- The PGN you want never appears. Look for
ECandEBframes from the same source. The PGN is in bytes 6–8 of the TP.CM frame. - The data looks shifted by one byte. You kept the sequence number. Drop byte 1 of every TP.DT frame.
- The last bytes are
FF. That is padding. Cut the joined data to the size in the TP.CM frame. - Transfers abort. Check for missing packets, or a receiver that cannot accept another session from that sender while one is still running.
Frequently asked questions
What is the maximum message size in J1939?
1785 bytes with the J1939-21 transport protocol: 255 packets of 7 bytes. J1939 on CAN FD (J1939-22) uses a different transport with larger frames.
What is the difference between BAM and RTS/CTS?
BAM broadcasts to all ECUs with no handshake, so a lost packet means a lost message. RTS/CTS opens a connection to one ECU, which controls the pace and can ask for missing packets.
Why do I see EC and EB frames in my J1939 log?
They are transport protocol frames. EC is TP.CM, which announces and controls a long message, and EB is TP.DT, which carries its data. The real PGN is inside the TP.CM frame.
References
DBC Utility
One desktop app for DBC files and CAN recordings.
One-time $34 · Windows & Linux · Files stay on your computer