12-OBD-Speed: watch mode for the unknown PCM DIDs

- After the DID scan, the log page reads the 327 PCM DIDs of unknown meaning
  round after round and logs every change ("W did data"), 3 per request if
  the PCM allows it (reply split with the lengths from the scan)
- tools/make_watch_dids.py generates src/watch_dids.h from the scan logs
- README/CLAUDE.md: scan results, test-drive plan, git remote

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
mangavalkandClaude Opus 5.5 committed 2026-11-18 16:18:52 +01:00
1 parent c9ad39c8ed
commit 970f6a3d64
5 files changed
+220 -6

No files matched your search

+9
View File
@@ -56,6 +56,15 @@ So the values have to be asked from the modules. While logging is on, the OBD ta
supported ones) when the module passes the test `22F1FFF188F1FE`; a hit is re-asked one DID at a time.
`E progress` every 512 DIDs (with ms/DID).
4. Every 2 s `ATSH 7DF` / `ATAR` + `010D` (speed, so the display keeps working, a bit laggy) and `ATRV`.
5. **Watch** (once the scan is done): the 327 PCM DIDs of unknown meaning in `src/watch_dids.h` (generated by
`../tools/make_watch_dids.py` from the scan logs; leaves out F1xx identification, F4xx = mode 01 copies, DExx
tables, D01A text, DD00 clock, DD01 odometer) are read round after round; every change is logged as
`W <did> <data>`, each round as `E round N done, s, changes`. 3 DIDs per request if the PCM allows it
(tested with `22D100D134D137`), the reply is split with the lengths from the scan.
**Scan result (2026-11-12..18, logs `docs/canlog/scan`, `scan2`)**: only the PCM 0x7E0 answers (also with `3E00` and a 1 s
timeout); **389 supported DIDs**, ~175 ms per request, the multi-DID test `22F1FFF188F1FE` timed out (single requests).
Known: F190 VIN, F188 `JB2B-14C204-ADA`, DD01 odometer (0x021676 = 136 822 km), F4xx = mode 01 PIDs.
Page: Start/Stop (remembered), Mark, progress (module, DID, %), modules found, DIDs found, last positive reply,
**Reset scan** (starts over the next time logging runs). While logging the speed page shows `REC <marks>`; a tap on
+91 -3
View File
@@ -5,6 +5,7 @@
#include <algorithm>
#include "can_log.h"
#include "watch_dids.h"
#define RETRY_DELAY_MS 3000
#define IDLE_RETRY_DELAY_MS 30000
@@ -414,6 +415,7 @@ static uint16_t probe_addr = 0; // 0 = not started on this connection
static int probe_new = 0;
static int multi_did = 0; // 0 = not tested, 1 = several DIDs per request work, 2 = one at a time
static uint16_t multi_module = 0; // module multi_did was tested on
static int watch_multi = 0; // watch mode: 0 = not tested (per connection), 1 = 3 per request, 2 = single
static uint32_t progress_ms = 0;
static String hex3(uint16_t v)
@@ -570,6 +572,7 @@ static void scan_setup()
next_scan_obd = 0;
probe_addr = 0;
multi_module = 0;
watch_multi = 0;
progress_ms = millis();
scan_ready = true;
}
@@ -840,6 +843,92 @@ static void scan_did_step()
}
}
// ---------- watch (after the scan): read the unknown PCM DIDs over and over, log every change ----------
// To find the cruise set speed / speed limit: values that only change when the set speed is changed or a
// sign is passed (marks). Up to 3 DIDs per request when the PCM allows it; the reply is split with the
// lengths known from the scan. Log: "W <did> <data>" on every change, "E round ..." per round.
static std::vector<String> watch_last; // last value per WATCH_DIDS entry
static uint32_t watch_index = 0, watch_round = 0, watch_round_start = 0, watch_changes = 0;
static void watch_record(int i, const String &data)
{
if (data == watch_last[i])
return;
watch_last[i] = data;
watch_changes++;
can_log_line("W " + hex4(WATCH_DIDS[i].did) + " " + data);
if (watch_round > 0)
can_log_set_frame(2, "Changed: " + hex4(WATCH_DIDS[i].did) + " = " + data.substring(0, 16));
}
// Reads WATCH_DIDS[i..i+n-1] in one request; false if the reply couldn't be split (then ask one by one)
static bool watch_read(int i, int n, bool &answered)
{
String req = "22";
for (int k = 0; k < n; k++)
req += hex4(WATCH_DIDS[i + k].did);
String r = scan_request(0x7E0, req);
answered = r != "NODATA" && r.length() && r != "?TIMEOUT";
if (!r.startsWith("62"))
return n == 1; // single: nothing more to try; several: retry one by one
int pos = 2;
for (int k = 0; k < n; k++)
{
int len = WATCH_DIDS[i + k].len * 2;
if (r.substring(pos, pos + 4) != hex4(WATCH_DIDS[i + k].did) || (int)r.length() < pos + 4 + len)
return false;
watch_record(i + k, r.substring(pos + 4, pos + 4 + len));
pos += 4 + len;
}
return true;
}
static void watch_step()
{
if (watch_last.empty())
watch_last.resize(WATCH_COUNT);
if (watch_multi == 0)
{
// three 1-byte DIDs: reply "62D10001D13400D13700" if the PCM handles several per request
String r = scan_request(0x7E0, "22D100D134D137");
watch_multi = (r.startsWith("62D100") && r.indexOf("D137") > 0) ? 1 : 2;
can_log_line("E watch multi-DID: " + String(watch_multi == 1 ? "yes" : "no") + " (" + r.substring(0, 24) + ")");
watch_round_start = millis();
}
if (watch_index >= WATCH_COUNT)
{
uint32_t ms = millis() - watch_round_start;
can_log_line("E round " + String(watch_round) + " done, " + String(ms / 1000) + " s, " + String(watch_changes) +
" changes");
can_log_set_frame(1, "Round " + String(watch_round + 1) + ", last " + String(ms / 1000) + " s");
watch_round++;
watch_index = 0;
watch_changes = 0;
watch_round_start = millis();
}
int n = watch_multi == 1 ? std::min<int>(3, WATCH_COUNT - watch_index) : 1;
bool answered;
if (!watch_read(watch_index, n, answered))
for (int k = 0; k < n; k++)
watch_read(watch_index + k, 1, answered);
if (!answered)
{
if (++scan_silent >= 20)
{
scan_silent = 0;
can_log_line("E 7E0 not answering (watch)");
vTaskDelay(pdMS_TO_TICKS(5000));
return;
}
}
else
scan_silent = 0;
watch_index += n;
if ((watch_index & 0x1F) < (uint32_t)n)
can_log_set_phase("Watching PCM: round " + String(watch_round) + ", " + String(watch_index) + "/" +
String(WATCH_COUNT));
}
// One unit of scan work (one request), with speed + voltage every 2 s
static void log_step()
{
@@ -885,9 +974,8 @@ static void log_step()
else
scan_did_step();
break;
default:
can_log_set_phase("Scan finished");
vTaskDelay(pdMS_TO_TICKS(100));
default: // scan finished: watch the unknown DIDs
watch_step();
break;
}
}
+69
View File
@@ -0,0 +1,69 @@
// Generated by tools/make_watch_dids.py from the DID scan logs (docs/canlog) - do not edit.
// PCM (0x7E0) DIDs with unknown meaning that are watched for changes: 327 of 389 supported.
#pragma once
#include <stdint.h>
struct WatchDid
{
uint16_t did;
uint8_t len; // reply data bytes (from the scan)
};
static const WatchDid WATCH_DIDS[] = {
{0x0117, 1}, {0x0118, 2}, {0x0119, 1}, {0x0202, 1}, {0x0300, 4}, {0x0301, 2},
{0x0302, 4}, {0x0303, 4}, {0x0304, 2}, {0x0307, 2}, {0x0308, 2}, {0x0309, 1},
{0x030A, 2}, {0x030B, 1}, {0x0310, 1}, {0x0311, 1}, {0x0315, 2}, {0x0316, 2},
{0x0317, 2}, {0x0318, 2}, {0x0319, 2}, {0x031A, 2}, {0x031B, 2}, {0x031E, 2},
{0x0320, 1}, {0x0324, 2}, {0x032B, 1}, {0x0334, 2}, {0x0338, 2}, {0x033C, 2},
{0x033E, 2}, {0x033F, 2}, {0x0345, 4}, {0x0348, 2}, {0x034E, 2}, {0x0353, 2},
{0x0355, 2}, {0x0356, 2}, {0x0357, 2}, {0x035A, 2}, {0x035D, 4}, {0x035F, 2},
{0x0371, 4}, {0x0382, 1}, {0x0388, 1}, {0x0389, 4}, {0x038A, 1}, {0x038E, 2},
{0x038F, 2}, {0x0390, 4}, {0x0391, 4}, {0x0393, 2}, {0x0394, 4}, {0x03A0, 2},
{0x03A1, 1}, {0x03A7, 1}, {0x03A8, 4}, {0x03A9, 4}, {0x03AA, 4}, {0x03AC, 2},
{0x03AD, 4}, {0x03AF, 1}, {0x03B1, 2}, {0x03B3, 1}, {0x03B5, 2}, {0x03BA, 2},
{0x03BB, 2}, {0x03BC, 2}, {0x03BD, 2}, {0x03C0, 1}, {0x03C7, 2}, {0x03C9, 2},
{0x03CA, 1}, {0x03CD, 1}, {0x03CF, 1}, {0x03D1, 2}, {0x03D3, 2}, {0x03D4, 2},
{0x03D7, 2}, {0x03D8, 2}, {0x03D9, 2}, {0x03DA, 2}, {0x03DC, 2}, {0x03E8, 2},
{0x03EC, 2}, {0x03EF, 2}, {0x03FD, 2}, {0x0403, 2}, {0x0409, 1}, {0x0414, 4},
{0x0416, 4}, {0x0418, 2}, {0x0427, 1}, {0x0429, 2}, {0x045C, 4}, {0x0461, 2},
{0x0462, 2}, {0x0464, 1}, {0x0465, 1}, {0x0466, 2}, {0x046D, 2}, {0x046F, 1},
{0x0470, 1}, {0x0474, 1}, {0x04A9, 4}, {0x04F7, 2}, {0x051B, 2}, {0x0546, 4},
{0x0547, 1}, {0x054B, 1}, {0x054F, 2}, {0x0551, 2}, {0x0552, 2}, {0x0554, 2},
{0x057D, 1}, {0x057E, 1}, {0x0580, 1}, {0x0590, 4}, {0x0591, 4}, {0x0594, 2},
{0x0598, 2}, {0x0599, 1}, {0x059A, 1}, {0x05AB, 2}, {0x05AC, 1}, {0x05AD, 1},
{0x05AE, 1}, {0x05B7, 4}, {0x05B8, 2}, {0x05BB, 4}, {0x05CB, 1}, {0x05E1, 4},
{0x05E2, 1}, {0x05E3, 1}, {0x05E4, 1}, {0x05E5, 4}, {0x05E6, 4}, {0x05E7, 4},
{0x05E8, 4}, {0x05E9, 4}, {0x05FB, 4}, {0x05FC, 2}, {0x05FD, 2}, {0x061B, 2},
{0x0629, 2}, {0x062A, 2}, {0x062E, 2}, {0x062F, 1}, {0x0630, 1}, {0x0639, 2},
{0x063B, 2}, {0x063C, 2}, {0x063D, 2}, {0x063E, 2}, {0x0651, 1}, {0x0654, 1},
{0x0655, 2}, {0x0700, 4}, {0x0703, 4}, {0x0707, 1}, {0x0914, 2}, {0x0915, 2},
{0x0917, 2}, {0x0918, 2}, {0x091A, 2}, {0x091B, 1}, {0x093C, 2}, {0x099B, 2},
{0x09CD, 1}, {0x1126, 1}, {0x1166, 2}, {0x1167, 2}, {0x116B, 2}, {0x1279, 2},
{0x1505, 2}, {0x16D3, 2}, {0x16D4, 2}, {0x16D7, 2}, {0x16D8, 1}, {0x16DC, 2},
{0x1E01, 4}, {0x1E04, 4}, {0x1E09, 2}, {0x1E0A, 2}, {0x1E0C, 1}, {0x1E0D, 1},
{0x1E0E, 1}, {0x1E0F, 1}, {0x1E10, 1}, {0x1E11, 2}, {0x1E12, 1}, {0x1E13, 2},
{0x1E14, 2}, {0x1E15, 2}, {0x1E16, 2}, {0x1E17, 1}, {0x1E18, 4}, {0x1E19, 2},
{0x1E1A, 2}, {0x1E1B, 2}, {0x1E1C, 2}, {0x1E1D, 2}, {0x1E23, 1}, {0x1E28, 1},
{0x1E29, 2}, {0x1E2A, 2}, {0x1E2B, 2}, {0x1E2D, 2}, {0x1E2E, 1}, {0x1E33, 2},
{0x1E35, 2}, {0x1E36, 2}, {0x1E37, 2}, {0x1E39, 4}, {0x1E3A, 2}, {0x1E3C, 2},
{0x1E3D, 2}, {0x1E46, 1}, {0x1E4D, 2}, {0x1E53, 2}, {0x1E54, 2}, {0x1E55, 2},
{0x1E56, 2}, {0x1E59, 2}, {0x1E5E, 1}, {0x1E60, 1}, {0x1EF8, 2}, {0x1EF9, 2},
{0x1EFA, 2}, {0x2028, 2}, {0x2029, 2}, {0x2872, 2}, {0x2873, 2}, {0x2874, 1},
{0x2B00, 4}, {0x3B40, 4}, {0x9800, 2}, {0x9801, 4}, {0x9863, 1}, {0x9864, 2},
{0x986B, 4}, {0xA45F, 4}, {0xC011, 4}, {0xC012, 4}, {0xC1A3, 4}, {0xD002, 2},
{0xD003, 4}, {0xD005, 4}, {0xD006, 4}, {0xD014, 4}, {0xD015, 4}, {0xD100, 1},
{0xD127, 2}, {0xD134, 1}, {0xD137, 1}, {0xD980, 4}, {0xFD00, 2}, {0xFD01, 2},
{0xFD02, 2}, {0xFD03, 2}, {0xFD04, 2}, {0xFD05, 2}, {0xFD06, 2}, {0xFD07, 2},
{0xFD08, 2}, {0xFD09, 2}, {0xFD0A, 2}, {0xFD0B, 2}, {0xFD0C, 2}, {0xFD0D, 2},
{0xFD10, 2}, {0xFD11, 2}, {0xFD12, 2}, {0xFD13, 2}, {0xFD14, 2}, {0xFD15, 2},
{0xFD16, 2}, {0xFD17, 4}, {0xFD18, 4}, {0xFD19, 2}, {0xFD1A, 2}, {0xFD1B, 2},
{0xFD1C, 2}, {0xFD1D, 2}, {0xFD1E, 2}, {0xFD1F, 2}, {0xFD20, 2}, {0xFD21, 2},
{0xFD22, 2}, {0xFD23, 2}, {0xFD24, 2}, {0xFD25, 2}, {0xFD26, 2}, {0xFD27, 2},
{0xFD28, 2}, {0xFD29, 2}, {0xFD2A, 2}, {0xFD2B, 2}, {0xFD2C, 2}, {0xFD2D, 2},
{0xFD2E, 2}, {0xFD2F, 1}, {0xFD33, 2}, {0xFD34, 2}, {0xFD35, 2}, {0xFD36, 2},
{0xFD37, 2}, {0xFD38, 2}, {0xFD39, 4}, {0xFD3A, 4}, {0xFD40, 2}, {0xFD41, 2},
{0xFD4A, 2}, {0xFD4B, 2}, {0xFD4C, 2}, {0xFD4D, 2}, {0xFD5D, 2}, {0xFD5E, 2},
{0xFD5F, 2}, {0xFD60, 2}, {0xFD61, 2}, {0xFD62, 1}, {0xFD63, 2}, {0xFD64, 4},
{0xFD66, 4}, {0xFE24, 2}, {0xFE25, 2},
};
static const uint16_t WATCH_COUNT = sizeof(WATCH_DIDS) / sizeof(WATCH_DIDS[0]);