DanielMartensson / Open-SAE-J1939

SAE J1939 protocol free to use for embedded systems or PC with CAN-bus
MIT License
455 stars 164 forks source link

Is There a Method to Programmatically Derive OBD-II P-Codes from SPN, FMI, or Other J1939 Parameters Post-Parsing DTC Messages? #54

Closed Anmolg1102 closed 1 week ago

Anmolg1102 commented 3 weeks ago

I’m currently handling J1939 DM1 and DM2 diagnostic messages and need to map DTCs to corresponding OBD-II P-codes directly, without relying on predefined DTC tables or manual lookup resources. Specifically, I want to know if there's a method or conversion algorithm that can derive the correct P-code based on parsed parameters like SPN (Suspect Parameter Number), FMI (Failure Mode Identifier), or potentially other J1939 parameters.

Has anyone developed a systematic way or heuristic to infer OBD-II P-codes using SPN, FMI, or other available data points in J1939? Any insights or examples of a conversion technique that could dynamically map these values to related P-codes would be very helpful.

Thank you!

DanielMartensson commented 3 weeks ago

@Anmolg1102 Not sure what you mean. But you can read the DM1 or DM2 codes from the message. But it will only give you a number, not a plain text.

If you want to implement and send me a PR, it's welcome. Use the enum .h file inside the project.