Files
ESP32-S3-Touch-LCD-5B/wiki/pages/obd-diagnostic-polling.md
T
julian 974082cb3e Add diag console probe (OBD-II mode 01/09 on 0x7DF); wiki: diagnostic polling, two sources
Firmware:
- CANDriver::transmit(): the single sanctioned transmit path (single-shot,
  echoed as CANTX lines, TX_FAILED alert counted); CAN-task warnings now take
  the serial lock
- DiagProbe module: `diag pids` supported-PID bitmap scan, `diag pid <hex>`,
  `diag vin`, `diag ecu`, `diag status`; ISO-TP reassembly with flow control;
  one request in flight, refused for 3 s after any foreign tester frame
- Console dispatch chained via Tunables::setExtraCommandHandler()
- CLAUDE.md and docs/UART_PROTOCOL.md updated

Wiki:
- New page obd-diagnostic-polling (broadcast vs polled, 0x6F1->0x612 addressing,
  Route A generic OBD PID table, Route B, test-day procedure, firmware probe)
- New sources: google-ai-dde7m57-pids (clipping, unverified, 0x612 direction
  contradicted), dwr-335d-torque-pids (thread + raw/BMW 335d.csv decoded)
- Clippings/ folder added to the schema (Obsidian Web Clipper, treated as raw/)
- bmw-m57n-engine, can-bus-integration, open-questions, index, log updated
2026-09-21 19:51:49 +02:00

10 KiB
Raw Blame History

type, tags, updated
type tags updated
concept
can-bus
dde
egs
diagnostics
kwp2000
uds
obd
design-decision
2026-09-21

OBD / Diagnostic Polling

Why some values never appear on the sniffer, how a scan tool gets them, and what it would take for Controller A to do the same. Several pages have linked here since July (can-id-candidates, open-questions #7); the page was created on the google-ai-dde7m57-pids ingest, 2026-09-21.

Broadcast vs polled

  • The DDE and EGS broadcast only what other modules need to run the car: rpm, coolant, gear, gearbox temp, torque, pedal, battery… — the verified list is in can-id-candidates.
  • Not broadcast (verified by absence on our own bus): manifold boost (AIP_ENG on 0x1D0 is barometric), MAF, rail pressure, injection quantity, fault codes. The Launch scanner shows them because it polls the ECU and displays the answers.
  • Consequence: a listen-only display can never show these. Getting them means transmitting requests on the PT-CAN.

How a tester talks to the DDE on this bus

E60-generation BMWs use one shared diagnostic ID pair with an ECU address in the first payload byte (BMW's extended-addressing variant of ISO 15765):

Direction CAN ID First payload byte Then Evidence
Tester → any ECU 0x6F1 target address (DDE = 0x12, EGS = 0x18 (unverified)) len, service, data (source: dieslg8 via can-id-candidates)
ECU → tester 0x600 + address → DDE 0x612, EGS 0x618 0xF1 len, service + 0x40, data same
  • What the user saw (2026-09-21): 0x612 appears on the tapped bus only while the Launch is connected. That is the DDE answering — consistent with the table. The requests should be present in the same capture as 0x6F1; the user's recollection of "0x6F2" is almost certainly 0x6F1.

Warning

The google-ai-dde7m57-pids clipping states the opposite (0x612 = request, 0x6F2 = response). Two sources (dieslg8's working code on a real M57, and the 0x6xx = ECU-address convention) against one uncited AI summary: we go with tester 0x6F1 → DDE 0x612 until our own capture shows the pair. Nothing is verified until then.

  • Generic EOBD (0x7DF functional / 0x7E0 physical → reply 0x7E8, mode 01) is a second, standard route (unverified) — early E60s served EOBD over K-line, later ones over CAN. See the next section: it is the cheaper experiment and needs no BMW knowledge.

Route A — generic OBD-II mode 01 (try this first)

The dwr-335d-torque-pids source is a worked, gauge-checked set of J1979 mode-01 PIDs from an M57 diesel (a 2009 335d, DDE7.3). They are ECU-agnostic by design, so whichever subset our DDE supports can be read with standard frames and no reverse-engineering:

Request on 0x7DF Reply on 0x7E8 Value
02 01 00 06 41 00 A B C D bitmap of supported PIDs 01–20 (then 01 20, 01 40, 01 60 for the next blocks)
02 01 05 03 41 05 A coolant A − 40 °C
02 01 0B 03 41 0B A manifold absolute pressure, A kPa — clips at 255 kPa, below full boost
02 01 0C 04 41 0C A B rpm (A·256+B)/4
02 01 0F / 01 46 03 41 xx A intake / ambient air temp A − 40 °C
02 01 10 04 41 10 A B MAF (A·256+B)/100 g/s
02 01 33 03 41 33 A barometric A kPa
02 01 5E 04 41 5E A B fuel rate (A·256+B)×0.05 L/h
02 01 70 0A 41 70 A B C D E … boost actual (D·256+E)×0.03125 kPa — 2007+ J1979 diesel PID, likely absent on an EDC16 (unverified)
02 01 73 / 78 / 7A / 83 — exhaust pressure / EGT / DPF ΔP / NOx — same caveat; DPF/SCR rows are meaningless on an M57N anyway
  • First test = the 01 00 bitmap query. One frame on 0x7DF with the engine running (no scan tool attached) answers both open points at once: does this DDE speak EOBD on the PT-CAN at all, and which PIDs does it offer. No reply → the DDE serves EOBD on K-line (or not on this bus) and only Route B remains.
  • Implemented on Controller A (2026-09-21) (repo) as the diag console command — see Firmware: the diag probe below. The whole test is diag pids typed on the USB console.
  • Route A cannot give fault codes beyond generic mode 03 DTCs (P0xxx) — BMW-specific codes need Route B.

Route B — BMW proprietary (KWP2000 / UDS on 0x6F1 → 0x612)

This depends on the DDE variant, which is still open (open-questions #2, bmw-m57n-engine):

DDE ECU Typical fitment Ediabas group Diagnostic layer
DDE6.x Bosch EDC16C31/C35 E60/E61 M57N 2003–07 (our likely donor) D60M57D0 / D62M57B0 KWP2000 on CAN (unverified)
DDE7.3 Bosch EDC17CP09 E90 335d / E70 35d (M57N2, NA market) D73N57C0 KWP2000 on CAN, UDS variant exists (unverified)
  • The clipping's identifiers (22 D1 0C boost, 22 D1 1E rail, 22 D1 14 MAF, 22 D1 06 injection) are (unverified) and uncited — do not implement from them. The Ediabas result names (STAT_LADEDRUCK_IST_WERT, STAT_RAILDRUCK_IST_WERT, STAT_LUFTMASSE_WERT, STAT_EINSPRITZMENGE_AKTUELL_WERT, STAT_KUEHLMITTELTEMPERATUR_WERT, STAT_MOTORDREHZAHL_WERT) are real and are the right search terms.
  • The reliable route needs no guessing: capture while the Launch is on its live-data page (procedure below). The exact request bytes and the reply layout come for free, for whatever variant is in the car.

Procedure: capture with the Launch polling

  1. Start the board's raw logger (CANRAW stream, see can-bus-integration) with the Launch connected; open the Launch's live-data page for boost or rail pressure; blip the throttle twice.
  2. Filter the log to 0x6F1 and 0x612 (also keep 0x7E0/0x7E8 and 0x618 if they show up).
  3. Pair each 0x6F1 request with the 0x612 reply that follows. In the reply, the byte after the length is the service + 0x40 (0x62 for a 0x22 request, 0x61 for 0x21); the identifier is echoed next; the data bytes follow. Match the bytes that move with the throttle to the values the Launch displayed.
  4. Open the Launch's ECU identification page and note the variant string — closes open-questions #2.
  5. File the log in raw/, write a source page, promote whatever pairs were seen to (verified).

Firmware: the diag probe (repo, 2026-09-21)

Controller A now has one transmit path onto the PT-CAN: CANDriver::transmit(), called only by src/modules/diag_probe.cpp. It sends nothing on its own; every frame is typed by a human on the USB console.

Command What it sends What it prints
diag pids 02 01 00 on 0x7DF, then 01 20, 01 40… as long as the engine ECU advertises the next block each block's supported PIDs, then a per-responder summary with names (coolant, rpm, MAP, MAF, boost 70, EGT 78…)
diag pid <hex> one mode-01 request raw reply bytes + a decoded value for the PIDs in the Route A table
diag vin mode 09 PID 02 the VIN as text — identifies the donor (open-questions #2)
diag ecu mode 09 PID 0A the ECU name string
diag status nothing request/reply/timeout counters, responders seen, tester-guard timer

Safety rules baked in: one request in flight at a time; frames are single-shot (no retransmit storm if nobody ACKs, the failure is just counted); refused for 3 s after any foreign tester frame (0x7DF, 0x7E0–7, 0x6F1), so it cannot collide with the Launch; only services 01 and 09, never session control or writes; multi-frame replies are reassembled with a standard flow-control frame (30 00 00) to the responder's physical ID. Every transmitted frame is echoed as CANTX,<ts>,<id>,0,<dlc>,<hex> next to the CANRAW lines, so a saved console log holds both halves of every exchange.

Test-day procedure (Route A probe)

  1. Engine running, Launch unplugged (the probe refuses to send for 3 s after any tester frame, and the Launch keeps polling while attached).
  2. Laptop on the 5B's USB, console at 115200 with the output saved to a file, e.g. from the repo root:
    pio device monitor -p COM11 --quiet > diag-<date>.log
    
    (or any terminal with logging on). The CANRAW stream keeps running; the diag lines and CANTX echoes land in the same file.
  3. Type diag pids. Read the summary line — four possible outcomes:
    • "NOT ACKED - no other node saw it" → wiring or bus problem, not an ECU answer. Check the CAN terminal block, the 120 Ω switch (off), and that CANRAW lines are still flowing.
    • "ACKED but NO REPLY on 0x7E8-0x7EF" → the DDE does not answer generic OBD-II on this bus (EOBD on K-line, or not at all). Route B only.
    • Reply from 0x7E8 listing PIDs → Route A works. Continue with step 4.
    • Replies from 0x7E8 and 0x7E9 → the EGS also answers generic OBD; note which PIDs it claims.
  4. If Route A works: diag pid 0C (rpm — proves a live read), diag pid 05 (coolant — cross-check against the 0x1D0 value on the Driveline screen), diag pid 70 (does the boost PID exist on this ECU?), diag pid 0B (does 1-byte MAP clip?), then diag vin and diag ecu.
  5. diag status once at the end (counters, tester guard), then stop the monitor.
  6. Copy the log into raw/, write a sources/ page with the supported-PID list and the VIN, update this page (Route A verified / refuted) and open-questions #2 and #7.

Beyond the probe (repo)

  • A continuous poller (Route A or B) would reuse the same transmit path with a fixed request list: one request per ≥100 ms, one identifier at a time, only while no scan tool is connected, never a session-control or write service. Still a design decision: a request storm or a malformed frame can disturb the DDE/EGS, and diagnostic sessions can change what an ECU broadcasts.
  • Protocol v2 dropped the fault_codes field in favour of the alert bitmap (dual-controller-architecture); polled values would need new DATA fields.
  • The same request path would also be the only way to read DTCs (service 0x18/0x19, variant-dependent) → open-questions #7.

can-id-candidates · can-bus-integration · bmw-m57n-engine · google-ai-dde7m57-pids · listen-and-send-pid-arduino · open-questions