Fix: OBD-II reads DTCs the standard way and asks which PIDs exist - #29
Merged
Merged
Conversation
Three defects in the diagnostics path, found auditing it against SAE J1979: - Read DTC sent only UDS service 0x19. Every OBD-II vehicle answers mode 03 (stored codes) and 07 (pending); only UDS-capable ECUs answer 0x19. It now asks with 03 and 07 and falls back to 0x19. - When nothing answered, the tab said "No DTCs found." That is false reassurance about a car that was never heard from. The scanner now records whether any ECU answered, and the tab says so. - The PID scan requested every PID in the table, one timeout each, without asking the car. It now reads the supported-PID masks (0x00, 0x20, ...) and requests only those, and stops after one question if nothing speaks mode 01. The table grows from 26 PIDs to 78: bank 2 fuel trims, fuel and rail pressures, eight O2 sensor voltages and equivalence ratios, catalyst temperatures, evaporative system pressures, secondary O2 trims, injection timing, engine torque, odometer. Formulas are J1979's. PID 0x49 was named "Throttle Pos D"; it is Accelerator Pedal Position D. A payload shorter than a PID's answer is refused instead of misread. Tests script an ECU that supports four PIDs and holds one stored and one pending code: the scan sends exactly six requests, the DTC read never reaches UDS, and a silent bus is reported as silent.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Defects, found auditing the diagnostics path against SAE J1979
dtc_answered, and the tab says "No ECU answered ... this is not a clean result".Coverage
26 → 78 mode 01 PIDs, all single-number values with J1979 formulas: bank 2 trims, fuel pressure, rail pressures, O2 sensor voltages and equivalence ratios, catalyst temperatures, evap pressures (signed), secondary O2 trims, injection timing, engine torque, odometer. PID 0x49 renamed from "Throttle Pos D" to Accelerator Pedal Position D. A payload shorter than the PID's answer is refused rather than misread.
Clearing DTCs is unchanged: still UDS 0x14 behind ARM TX. Adding mode 04 would widen a state-changing action, so it is left alone.
Tests
01 00,01 20and the four PIDs, with correct values.["P0133", "P0301 (pending)"]with no UDS request sent; silence givesdtc_answered = Falseand the tab's not-clean message.pytest -q: 721 passed. ruff clean. No real OBD-II capture was available, so validation is against the standard and scripted responders.