Can you differentiate J1939 from UDS from an unknown message on CANbus

1k Views Asked by At

I'm working on a CAN sniffer/logger for and will connect to ECUs that may send out CANopen, J1939 or UDS. Most often two or even all of them in one session (For what I have understood this is not recommended but this is the case).

I know CANopen (non fd) has an 11-bit identifier unlike J1939 and UDS that uses 29-bit identifier. To sort out the 11-bit is easy but is there any known way to know if an unknown message with 29-bit identifier is UDS or J1939? My guess is no...

I found some code using (29bit_id & 0x70000)==0x70000 to sort it as J1939 but that misses some J1939 and it must be likely that UDS might have these bits set also. Any suggestions?

2

There are 2 best solutions below

0
On

With 29-bit CAN identifiers you can differentiate between UDS and J1939 by checking bits 24 and 25 in the CAN frame ID.

In J1939, this would be the Extended Data Page bit and the Data page bit. If they're both set to 1, then the frame is UDS/Iso15765.

According to SAE J1939-21 (https://www.sae.org/standards/content/j1939/21_201810/)

J1939 PDU

edp-dp

0
On

My take is "you can't". At least not if you want this to work in every case. While you may apply some heuristics (such as whether the 29-bit address matches a well known PGN or whether the payload makes sense considering the PGN definition), vendors can pretty much allocate CAN addresses in the way they want to.