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?
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/)