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
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* 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 vin mode 09 PID 02 — VIN (identifies the donor)
|
||||
* diag ecu mode 09 PID 0A — ECU name string
|
||||
* diag status counters, responders seen, tester-guard timer
|
||||
* diag help
|
||||
*
|
||||
* 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
|
||||
Reference in New Issue
Block a user