Skip to content

Fix: OBD-II reads DTCs the standard way and asks which PIDs exist - #29

Merged
Sherin-SEF-AI merged 1 commit into
mainfrom
fix/obd-ii
Sep 23, 2026
Merged

Sherin-SEF-AI merged 1 commit into
mainfrom
fix/obd-ii

Conversation

@Sherin-SEF-AI

Copy link
Copy Markdown
Owner

Defects, found auditing the diagnostics path against SAE J1979

  1. Read DTC sent only UDS service 0x19. Every OBD-II vehicle answers mode 03 (stored) and 07 (pending); only UDS-capable ECUs answer 0x19. An older car reported no codes because it was never asked in a language it speaks. Now: modes 03 and 07, then 0x19 as a fallback.
  2. Silence was reported as "No DTCs found." If no ECU answered, the tab still said the car was clean. The scanner now records dtc_answered, and the tab says "No ECU answered ... this is not a clean result".
  3. The PID scan never asked what the car supports. It requested every table entry, one timeout each. It now reads the supported-PID masks and requests only those, and stops after one question when nothing speaks mode 01.

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

  • A scripted ECU supporting four PIDs: the scan sends exactly 01 00, 01 20 and the four PIDs, with correct values.
  • A silent bus: one request, then a clear status.
  • DTCs: ["P0133", "P0301 (pending)"] with no UDS request sent; silence gives dtc_answered = False and the tab's not-clean message.
  • Formulas against J1979 worked values, including the signed and four-byte PIDs; every PID decodes zeros inside its declared range.

pytest -q: 721 passed. ruff clean. No real OBD-II capture was available, so validation is against the standard and scripted responders.

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.
@Sherin-SEF-AI
Sherin-SEF-AI merged commit ef3aa63 into main Sep 23, 2026
2 checks passed
@Sherin-SEF-AI
Sherin-SEF-AI deleted the fix/obd-ii branch September 23, 2026 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant