Diag scans: 22 D1xx refuted, 21 xx session-locked; add diag raw toggle + scanner
- diag probe: `diag raw on|off` console command (mutes CANRAW during scans) - tools/diag_scan.py: identifier-space sweeper via `diag bmw` - findings: whole 22 D1xx block NRCs (clipping identifiers wrong for this DDE); 21 xx sparse - 21 20 = O_269962, measurement blocks gated behind diagnostic session / security access -> Launch capture is the path to live data - wiki: route-b source page + obd-diagnostic-polling updated, raw scan logs Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -226,7 +226,7 @@ Settings persist across power cycles via ESP32 NVS (Non-Volatile Storage):
|
||||
|
||||
### Diagnostic probe (`diag` console)
|
||||
|
||||
`src/modules/diag_probe.cpp` is the only code allowed to call `CANDriver::transmit()`. It sends single diagnostic requests and reassembles the ISO-TP replies, on two routes: generic OBD-II on `0x7DF` (replies `0x7E8..0x7EF`) and BMW-addressed KWP2000 on `0x6F1` with target byte (replies `0x600`+addr, extended addressing). Commands: `diag pids` (supported-PID bitmap scan), `diag pid <hex>`, `diag dtc` (mode 03), `diag vin`, `diag ecu`, `diag ident [addr]` (KWP `1A 80`), `diag bmw <addr> <hex...>` (raw, whitelisted), `diag status`. One request in flight, single-shot frames, refused for 3 s after any foreign tester frame (`0x7DF`, `0x7E0-7`, `0x6F1`); read-only services only — generic 01/03/09, BMW `1A`/`18`/`21`/`22` (whitelist enforced in `sendBmwRequest()`), never session control or writes. Transmitted frames are echoed as `CANTX,` lines in the same format as `CANRAW,`. Console lines that `cfg` does not recognise are passed to it via `Tunables::setExtraCommandHandler()`. Background and test procedure: `wiki/pages/obd-diagnostic-polling.md`.
|
||||
`src/modules/diag_probe.cpp` is the only code allowed to call `CANDriver::transmit()`. It sends single diagnostic requests and reassembles the ISO-TP replies, on two routes: generic OBD-II on `0x7DF` (replies `0x7E8..0x7EF`) and BMW-addressed KWP2000 on `0x6F1` with target byte (replies `0x600`+addr, extended addressing). Commands: `diag pids` (supported-PID bitmap scan), `diag pid <hex>`, `diag dtc` (mode 03), `diag vin`, `diag ecu`, `diag ident [addr]` (KWP `1A 80`), `diag bmw <addr> <hex...>` (raw, whitelisted), `diag raw on|off` (CANRAW mute for scans), `diag status`. One request in flight, single-shot frames, refused for 3 s after any foreign tester frame (`0x7DF`, `0x7E0-7`, `0x6F1`); read-only services only — generic 01/03/09, BMW `1A`/`18`/`21`/`22` (whitelist enforced in `sendBmwRequest()`), never session control or writes. Transmitted frames are echoed as `CANTX,` lines in the same format as `CANRAW,`. Console lines that `cfg` does not recognise are passed to it via `Tunables::setExtraCommandHandler()`. Background and test procedure: `wiki/pages/obd-diagnostic-polling.md`.
|
||||
|
||||
### ESP-NOW link
|
||||
|
||||
|
||||
@@ -603,6 +603,7 @@ static void help() {
|
||||
print("diag ecu mode 09 PID 0A - ECU name");
|
||||
print("diag ident [addr] BMW KWP `1A 80` ECU identification (default addr 12 = DDE, reply 0x612)");
|
||||
print("diag bmw <addr> <hex...> raw BMW request on 0x6F1, read-only services only (1A/18/21/22)");
|
||||
print("diag raw on|off CANRAW frame logging (off = clean console during scans)");
|
||||
print("diag status counters, responders, tester guard");
|
||||
print("Sends on 0x7DF / 0x6F1 only, one request at a time; refused while a scan tool is polling.");
|
||||
}
|
||||
@@ -673,6 +674,13 @@ bool handleCommand(const char* line) {
|
||||
if (!strcmp(argv[1], "ecu")) { sendRequest(0x09, 0x0A); return true; }
|
||||
if (!strcmp(argv[1], "dtc")) { sendRequest(0x03, -1); return true; }
|
||||
|
||||
if (!strcmp(argv[1], "raw") && argc == 3) {
|
||||
bool on = !strcmp(argv[2], "on");
|
||||
CANDriver::setRawLogging(on);
|
||||
print("[diag] CANRAW logging %s", on ? "on" : "off");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!strcmp(argv[1], "ident")) {
|
||||
uint8_t target = BMW_ADDR_DDE;
|
||||
if (argc >= 3) target = (uint8_t)strtol(argv[2], NULL, 16);
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
"""Scan a BMW KWP identifier space via A's `diag bmw` console command.
|
||||
|
||||
Sends one read-only request per identifier value (00..FF), waits for the
|
||||
probe's reply line, and prints a summary of everything that answered
|
||||
positively. Full console stream goes to wiki/raw/diagscan-<timestamp>.log.
|
||||
|
||||
Usage:
|
||||
python tools/diag_scan.py COM10 21 # scan `21 xx` (readDataByLocalIdentifier)
|
||||
python tools/diag_scan.py COM10 22D1 # scan `22 D1 xx` (readDataByCommonIdentifier)
|
||||
python tools/diag_scan.py COM10 22D1 40 60 # optional sub-range [0x40..0x60)
|
||||
"""
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
import time
|
||||
|
||||
import serial
|
||||
|
||||
port = sys.argv[1]
|
||||
space = sys.argv[2].upper() # "21" or "22D1"
|
||||
lo = int(sys.argv[3], 16) if len(sys.argv) > 3 else 0x00
|
||||
hi = int(sys.argv[4], 16) if len(sys.argv) > 4 else 0x100
|
||||
|
||||
raw_dir = os.path.join(os.path.dirname(__file__), "..", "wiki", "raw")
|
||||
log_path = os.path.join(raw_dir, time.strftime("diagscan-%%s-%Y%m%d-%H%M%S.log") % space)
|
||||
log = open(log_path, "wb")
|
||||
|
||||
s = serial.Serial(port, 115200, timeout=0.05)
|
||||
print("port open, waiting for boot...")
|
||||
time.sleep(4)
|
||||
s.reset_input_buffer()
|
||||
|
||||
hits = []
|
||||
|
||||
|
||||
def txn(cmd, wait_s=1.5):
|
||||
"""Send one diag command, return the probe's reply lines."""
|
||||
s.write((cmd + "\n").encode())
|
||||
s.flush()
|
||||
log.write(("\n>>> %s\n" % cmd).encode())
|
||||
end = time.time() + wait_s
|
||||
pending = b""
|
||||
replies = []
|
||||
done = False
|
||||
while time.time() < end and not done:
|
||||
chunk = s.read(4096)
|
||||
if not chunk:
|
||||
continue
|
||||
log.write(chunk)
|
||||
pending += chunk
|
||||
while b"\n" in pending:
|
||||
line, pending = pending.split(b"\n", 1)
|
||||
text = line.decode("utf-8", "replace").rstrip()
|
||||
if "[diag]" in text:
|
||||
replies.append(text)
|
||||
if "<- 0x" in text or "no reply within" in text or "refused" in text:
|
||||
done = True
|
||||
return replies
|
||||
|
||||
|
||||
try:
|
||||
txn("diag raw off", wait_s=1.0)
|
||||
for v in range(lo, hi):
|
||||
if space == "21":
|
||||
cmd = "diag bmw 12 21 %02X" % v
|
||||
label = "21 %02X" % v
|
||||
else:
|
||||
cmd = "diag bmw 12 22 %s %02X" % (space[2:], v)
|
||||
label = "22 %s %02X" % (space[2:], v)
|
||||
replies = txn(cmd)
|
||||
got = [r for r in replies if "<- 0x" in r]
|
||||
if not got:
|
||||
replies = txn(cmd) # one retry if the line got mangled
|
||||
got = [r for r in replies if "<- 0x" in r]
|
||||
if not got:
|
||||
print("%s (no reply)" % label)
|
||||
continue
|
||||
r = got[-1]
|
||||
if "7F" in r and "negative" not in r.lower() and "NRC" not in r:
|
||||
pass
|
||||
if re.search(r"7F \d\d [0-9A-F]{2}", r) or "NRC" in r or "negative" in r:
|
||||
# negative response - only note interesting NRCs (not 0x12)
|
||||
if "0x12" not in r and "NRC 0x12" not in r:
|
||||
print("%s NEG: %s" % (label, r))
|
||||
else:
|
||||
print("%s HIT: %s" % (label, r))
|
||||
hits.append((label, replies))
|
||||
time.sleep(0.15)
|
||||
finally:
|
||||
txn("diag raw on", wait_s=1.0)
|
||||
log.close()
|
||||
s.close()
|
||||
print("\n%d positive hits" % len(hits))
|
||||
for label, replies in hits:
|
||||
print("== " + label)
|
||||
for r in replies:
|
||||
print(" " + r)
|
||||
print("log saved: " + os.path.abspath(log_path))
|
||||
@@ -97,3 +97,7 @@ The deferred test-day mission finally executed. `tools/diag_session.py` (new: on
|
||||
## [2026-09-23] ingest | Route B verified, DTCs read, donor identified (E60 530d)
|
||||
|
||||
Second session of the day, no Launch needed. Extended the diag probe (read-only: mode 03 `diag dtc`, BMW KWP `diag ident` / `diag bmw` on 0x6F1 with a 1A/18/21/22 service whitelist; MAX_PAYLOAD 64->384). Results, all on the tapped bus: (1) `diag dtc` read the 5 stored codes - P0101 MAF, P0113 IAT, P0500 VSS, P0545 EGT, P0030 O2 heater - all disconnected-sensor swap leftovers; the "implausible MAF/IAT scaling" flags from the morning are withdrawn (sensor faults). (2) BMW addressing verified live: 0x6F1 [12] -> reply on 0x612; the google-ai clipping's reversed claim is dead. (3) `1A 86` ident (65 B): part numbers 7799764/7799765/7793887, date 2006-03, VIN prefix WBANC92090 -> E60 530d (unverified decode); 22 F190 rejected -> KWP2000 not UDS -> DDE6/EDC16-era. 1A 90 (full VIN) always answers busyRepeatRequest to single-shots. Wrote sources/diag-route-b-2026-09-23.md; updated obd-diagnostic-polling (Route B verified, warning callout resolved), open-questions #2 (donor mostly identified - part-number lookup remains) and #7 (DTCs read), bmw-m57n-engine; raw logs diag-20260923-1241*/1242*/1243*/1245*/1246*.log. Firmware change in src/modules/diag_probe.cpp+.h (design rule kept: still the single transmit path, human-typed, single-shot).
|
||||
|
||||
## [2026-09-23] ingest | Identifier scans: 22 D1xx dead, 21 xx session-locked
|
||||
|
||||
Third session. Added `diag raw on|off` (CANRAW mute) and tools/diag_scan.py (identifier-space sweeper). Scanned `22 D100-D1FF`: every DID NRC 0x12 - the google-ai clipping identifiers are confirmed wrong for this DDE. Scanned `21 00-FF`: hits only at 21 20 (ASCII " O_269962 " - Bosch SW ref candidate), 21 06/08 (byte 0x05), 21 10 (empty); refusals 21 90 busy / 21 91 conditions-not-correct / 21 F0 security-access-denied show the measurement blocks are gated behind a diagnostic session (10 xx) and partly security access (27) - both outside the read-only whitelist by design. Conclusion: blind Route B probing is exhausted; live data needs the capture-with-Launch session. Updated sources/diag-route-b-2026-09-23.md and obd-diagnostic-polling; raw logs diagscan-22D1-*.log + diagscan-21-*.log.
|
||||
|
||||
@@ -64,7 +64,7 @@ The [[dwr-335d-torque-pids]] source is a worked, gauge-checked set of J1979 mode
|
||||
|
||||
## Route B — BMW proprietary (KWP2000 on `0x6F1` → `0x612`) — **VERIFIED WORKING (2026-09-23)**
|
||||
|
||||
First live exchange without any scan tool: `diag bmw 12 1A 86` → 65-byte multi-frame ident from `0x612`, containing DDE part numbers (7 799 764 / 7 799 765 / 7 793 887), a 2006-03 date, and the **VIN prefix `WBANC92090` → E60 530d** `(verified bytes / unverified decode)` — full breakdown in [[diag-route-b-2026-09-23]]. `22 F1 90` (UDS) is rejected: the DDE speaks **KWP2000, not UDS** — pointing at DDE6/EDC16. `1A 90` (full VIN) answers busyRepeatRequest to a single-shot probe. The `0x22 D1xx` live-data identifiers below remain untested — that is the remaining reason to capture with the Launch.
|
||||
First live exchange without any scan tool: `diag bmw 12 1A 86` → 65-byte multi-frame ident from `0x612`, containing DDE part numbers (7 799 764 / 7 799 765 / 7 793 887), a 2006-03 date, and the **VIN prefix `WBANC92090` → E60 530d** `(verified bytes / unverified decode)` — full breakdown in [[diag-route-b-2026-09-23]]. `22 F1 90` (UDS) is rejected: the DDE speaks **KWP2000, not UDS** — pointing at DDE6/EDC16. `1A 90` (full VIN) answers busyRepeatRequest to a single-shot probe. **Same day, identifier scans**: the clipping's `22 D1xx` identifiers are confirmed wrong (whole block NRCs), and a `21 xx` sweep shows the measurement blocks are **gated behind a diagnostic session / security access** (NRC 0x22/0x33) — outside the probe's read-only whitelist by design. **Live data over Route B therefore requires the capture-with-Launch session below**, which will reveal the session setup and the real identifiers together.
|
||||
|
||||
|
||||
This depends on the DDE variant, which is still open ([[open-questions]] #2, [[bmw-m57n-engine]]):
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -48,7 +48,15 @@ Parsed `(verified bytes; field meanings unverified)`:
|
||||
- `1A 90` (dedicated VIN read) — NRC **0x21 busyRepeatRequest** on every try (ignition-only *and* engine running once); a single-shot probe won't get it (KWP expects the tester to retry, possibly within a session). Not needed — `1A 86` gave the prefix.
|
||||
- `22 F1 90` (UDS-style VIN DID) — NRC 0x10: **not a UDS ECU**, KWP2000 only — another DDE6/EDC16-era hint `(unverified)`.
|
||||
|
||||
## Probe behaviour `(repo)`
|
||||
## Third session: identifier scans — live data is session-locked
|
||||
|
||||
Engine idling, `tools/diag_scan.py` (new: sweeps an identifier space via `diag bmw`, CANRAW muted with the new `diag raw off`). Raw: `raw/diagscan-22D1-20260923-155515.log`, `raw/diagscan-21-20260923-155831.log`.
|
||||
|
||||
- **`22 D1 00`–`D1 FF`: nothing.** Every identifier NRCs 0x12 — the [[google-ai-dde7m57-pids]] clipping's `22 D1xx` identifiers (`D10C` boost etc.) are **confirmed wrong for this DDE** `(verified)`. (First scan ran with CANRAW on; its two "hits" are garbled NRC lines.)
|
||||
- **`21 00`–`21 FF`: sparse.** Positive: `21 20` → ASCII **" O_269962 "** (Bosch software reference? — lookup candidate), `21 06`/`21 08` → one byte `05` each, `21 10` → empty reply. Many identifiers ACKed-but-silent.
|
||||
- **The telling refusals:** `21 90` NRC 0x21 (busy), `21 91` NRC 0x22 (conditions not correct), `21 F0` NRC **0x33 security access denied**.
|
||||
|
||||
Conclusion `(verified behaviour, unverified interpretation)`: the DDE's measurement blocks exist but are **gated behind a diagnostic session** (KWP `10 xx` startDiagnosticSession, possibly plus `27` securityAccess for some) — both deliberately outside the probe's read-only whitelist. Blind probing has hit its safe limit; **the Launch capture is now the only sensible next step for live data**: it will reveal the session setup *and* the identifiers, and then replaying them is an informed decision instead of a guess.
|
||||
|
||||
Multi-frame TX flow control on `0x6F1` with extended addressing worked first try; `MAX_PAYLOAD` had to grow 64 → 384 (the first `1A 86` capture clipped at 192 mid-VIN). All requests single-shot, whitelisted read-only services (`1A`/`18`/`21`/`22`), zero TX failures once the bus was awake. Reminder from the first attempt of the day: **a silent bus (ignition off) shows up as "not ACKed by any node" + TWAI bus errors** — check ignition before suspecting wiring.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user