7a7398243b
- diag probe: add mode 03 (diag dtc), BMW KWP on 0x6F1 with extended addressing (diag ident, diag bmw), read-only service whitelist (1A/18/21/22), MAX_PAYLOAD 64->384, full hex+ascii dump of BMW replies - tools/diag_session.py: one-session probe runner, logs into wiki/raw/ - wiki: Route A results (11 mode-01 PIDs, rpm/coolant cross-checked, mode 09 silent), Route B verified (0x6F1 [12] -> 0x612), 1A 86 ident with VIN prefix WBANC92090 (E60 530d), DTCs P0101/P0113/P0500/P0545/P0030 (disconnected-sensor swap leftovers), open-questions #2/#7 updated Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
62 lines
2.4 KiB
C++
62 lines
2.4 KiB
C++
/*
|
|
* Diagnostic Probe Module
|
|
*
|
|
* The ONLY place this firmware transmits on the PT-CAN. Sends single OBD-II
|
|
* (SAE J1979 / ISO 15031-5) requests on the functional address 0x7DF and
|
|
* reassembles the ISO 15765-2 replies from 0x7E8..0x7EF, to find out whether
|
|
* the DDE answers generic OBD on this bus and which PIDs it offers — the first
|
|
* step of wiki/pages/obd-diagnostic-polling.md ("Route A").
|
|
*
|
|
* Strictly on demand: nothing is sent unless a `diag ...` console command asks
|
|
* for it, one request is in flight at a time, frames go out single-shot (no
|
|
* retransmit storms if nobody ACKs), and requests are refused while another
|
|
* tester (a scan tool on 0x7DF / 0x7E0..7 / 0x6F1) has been seen recently.
|
|
*
|
|
* Console (USB serial, same line reader as `cfg`):
|
|
* diag pids scan the mode-01 supported-PID bitmaps (00, 20, 40, ...)
|
|
* diag pid <hex> one mode-01 request, e.g. `diag pid 0C` (rpm)
|
|
* diag dtc mode 03 — stored generic DTCs
|
|
* diag vin mode 09 PID 02 — VIN (identifies the donor)
|
|
* diag ecu mode 09 PID 0A — ECU name string
|
|
* diag ident [addr] BMW KWP `1A 80` ECU identification on 0x6F1 (default 12 = DDE)
|
|
* diag bmw <addr> <hex...> raw BMW-addressed request; read-only services only
|
|
* diag status counters, responders seen, tester-guard timer
|
|
* diag help
|
|
*
|
|
* BMW requests use ISO 15765 extended addressing: TX on 0x6F1 with byte 0 =
|
|
* target ECU address, reply on 0x600+address with byte 0 = 0xF1. Allowed
|
|
* services are whitelisted in sendBmwRequest(): 1A (ident), 18 (DTCs),
|
|
* 21/22 (read data) — never session control, resets, or writes.
|
|
*
|
|
* Every frame we send is echoed on the console as
|
|
* CANTX,<ts_ms>,<id_hex>,0,<dlc>,<data_hex>
|
|
* — the same shape as CANRAW — so a capture holds both halves of every exchange.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <Arduino.h>
|
|
#include "driver/twai.h"
|
|
|
|
namespace DiagProbe {
|
|
|
|
/** Create the state mutex. Call once in setup(), before the CAN task starts. */
|
|
void init();
|
|
|
|
/**
|
|
* Execute one console line beginning with "diag".
|
|
* @return true if the line was a diag command (even if it was rejected)
|
|
*/
|
|
bool handleCommand(const char* line);
|
|
|
|
/** Timeouts and scan sequencing. Call from loop(). */
|
|
void tick();
|
|
|
|
/**
|
|
* Feed every received CAN frame here (called from the CAN task). Cheap for
|
|
* IDs outside the diagnostic range.
|
|
*/
|
|
void onFrame(const twai_message_t& m);
|
|
|
|
} // namespace DiagProbe
|