mickeyl / LTSupportAutomotive

An iOS / watchOS / macOS support library for OBD2, VIN-Decoding, and more.
MIT License
212 stars 59 forks source link

Wrong conversion of DTC codes to ASCII #6

Closed thdankert closed 6 years ago

thdankert commented 6 years ago

When DTCs are received (eg. as a result of a mode 03 request), they are converted from the native ELM327 format to SAE format, as defined in the ELM data sheet.

However, this conversion does not correctly convert received DTCs with hex characters. The error lies in function -(NSString*)dtcCodeForA:(uint)A B:(uint)B, which tries to convert all received values back to ASCII numbers.

Example: DTC = P2B4A is received via ELM327 as 2B4A, but the function returns the following:

[pid dtcCodeForA:0x2B B:0x4A] = "P2;4:"

; and : are A and B (ASCII hex lower nibble), respectively.

I'll provide a push request shortly - the received characters should be passed through as-is.

mickeyl commented 6 years ago

Thanks for reporting this issue! Would it be possible to add a log from a car that returns such a DTC?

thdankert commented 6 years ago

Hi mickeyl,

I don't have the log available (it's from a yet unreleased car), but when debugging this issue, I used your "OBD II Expert" app in simulator mode and used the vehicle "Mercedes-Benz GL-Class...". This also produced DTCs with hex codes in them.

Please see the corresponding pull request for more details.

thdankert commented 5 years ago

@JRJian You're commenting on a closed issue - is your code snippet related to this (my) fix, or is this something else? (If so, please create a separate issue, and attach sample responses to verify the described behaviour)