diff --git a/docs/micromate_protocol_reference.md b/docs/micromate_protocol_reference.md index a814bf0..1513fdf 100644 --- a/docs/micromate_protocol_reference.md +++ b/docs/micromate_protocol_reference.md @@ -1242,6 +1242,70 @@ round-tripped: read the active config, modify, write it back. ✅ **The write half was observed on 2026-09-24** — see *The write path* below, which confirms the round-trip: the written block is the read block, 91% byte-identical. +### Inside `0x1A`: six 48-byte channel blocks (UM20147, 2026-10-15) + +⚠ **Read the grades before the table.** This came from **one setup on one +unit**, and the three grades below are not interchangeable. The repo's own +retraction trail — the `0x0C` float from a single sample, the cost model fitted +to sub-1 KB responses, offset detector v1 — is all from treating the third grade +as the first. + +ASCII landmarks place six channel labels at `content[1708]` with a **stride of +exactly 48**: `Tran`, `Vert`, `Long`, `Mic`, `LMic`, `SMic`. (`Mic` is 3 +characters, so a 4+-printable scan misses it and the stride appears to be 96 +across that gap.) + +**MEASURED — these bytes are in the dump:** + +| offset | Tran / Vert / Long | Mic / LMic | SMic | +|---|---|---|---| +| `+0` | label, null-padded | label | label | +| `+24` f32 BE | **3.1030800342559814** | 0.022503 | 73.0 | +| `+34` | `"in."` | `"psi"` | `"dB"` | +| `+38` f32 BE | 1.0 | 0.0205945 | 60.0 | +| `+42` | `"/s."` | `"(L)"` | `"(A)"` | +| `+46:48` | **Tran/Vert `00 01`, Long `00 00`** | `00 00` | `00 00` | + +Tran, Vert and Long blocks are **byte-identical except `+47`**. + +**🔑 MEASURED — `+24` carries the geophone scale, and it independently confirms +`_GEO_LSB_IPS`:** + + channel+24 = 3.1030800342559814 + / 10000 = 0.00031030800342559815 + documented _GEO_LSB_IPS = 0.000310308 → agree to 1.1e-8 + 10.0 / 3.10308 = 3.222605 V full scale + × 10,000 counts/V = 32226.05 counts → the documented figure exactly + +This matters because `_GEO_LSB_IPS` was previously pinned **only by statistical +inference** — intersecting 991,415 rounding constraints from Thor's CSV exports +(`docs/idf_protocol_reference.md`). **The unit reports the same number in its +own config block.** Two independent derivations agreeing to eight digits. +It is also almost exactly half Series III's `6.206053` (ratio 1.99997; the +residual is S3's rounded display value, not a real difference). + +**INFERRED, one setup / one unit — plausible, not established:** + +- that `+24` *is* the calibration constant, rather than another field that + happens to hold the same number (the arithmetic proves the number, not the + field's purpose) +- that `+46:48` is a per-channel enable or trigger-source flag. It is the only + byte separating three otherwise identical blocks, which is suggestive and + nothing more. + +**GUESSED — do not build on these:** + +- `+4` as a uint32 "channel type" (reads 1 / 1 / 1 / 2 / 2 / 9 across the six). + Six observations from a single setup, correlating with channel kind. That is + the entire basis. +- `+8:24` as eight uint16 BE values. Geo reads 74, 10, 40, 21, 1275, 525, 3, 0; + mic reads 200, 50, 10, 10, 1500, 500, 5, 0. Field boundaries unverified — the + uint16 split is an assumption, not a reading. + +**To promote any of the above:** the diff loop settles it. Change one setting, +see which of these offsets moves. A field whose purpose is guessed and which +never moves when the matching setting changes is simply wrong. + ## The write path — observed end to end (2026-09-24) ⚠ **We have still never sent a write command to a unit.** Thor did every write diff --git a/scratch/mm_config_diff.py b/scratch/mm_config_diff.py index f2f7b25..1da762c 100644 --- a/scratch/mm_config_diff.py +++ b/scratch/mm_config_diff.py @@ -56,9 +56,25 @@ from minimateplus.transport import TcpTransport # noqa: E402 SNAP_ROOT = Path(__file__).resolve().parent / "mm_config_snaps" +# Content starts at data[11]; the reference documents fields as content[N], so +# every changed offset is reported both ways to save a subtraction per finding. +CONTENT = 11 + # Block name -> the protocol method that reads it. 0x1C is included on purpose: # it is the one block whose volatility is already known (it carries the clock), # so it doubles as a positive control that the volatile pass is working. +# Bytes that are KNOWN volatile from the field layout, seeded regardless of +# whether they happened to move during the sample window. An empirical noise +# floor only catches what moves WHILE sampling: a four-read pass over eight +# seconds sees the sub-second tick and the seconds byte and silently misses +# minutes, hours and the date, which then surface later as fake "findings". +# 0x1C content[2:10] is day/month/year/tick/hour/min/sec; content starts at 11. +# Memory-free (content[40:44]) is deliberately NOT masked -- it moves only when +# the unit actually records, which is a thing worth being told about. +KNOWN_VOLATILE = { + "1C_monitor_status": list(range(11 + 2, 11 + 10)), +} + BLOCKS = { "1A_compliance": "read_compliance_config", "2C_call_home": "read_call_home_config", @@ -157,17 +173,21 @@ def cmd_volatile(mm: MicromateClient, serial: str, n: int) -> None: if len(a) != len(b): print(f" {name}: LENGTH CHANGED {len(a)} -> {len(b)} -- that is itself a finding") moved |= {i for i in range(min(len(a), len(b))) if a[i] != b[i]} - volatile[name] = sorted(moved) + volatile[name] = sorted(moved | set(KNOWN_VOLATILE.get(name, []))) print() for name, offs in volatile.items(): size = len(snaps[0][name]) + seeded = set(KNOWN_VOLATILE.get(name, [])) + observed = set(offs) - seeded if not offs: print(f" {name:20s} {size:5d} B STABLE -- every byte held still") else: - pct = 100.0 * len(offs) / size - print(f" {name:20s} {size:5d} B {len(offs):4d} volatile ({pct:.1f}%) {offs[:16]}" - + (" ..." if len(offs) > 16 else "")) + note = f"{len(observed)} observed" + if seeded: + note += f" + {len(seeded)} seeded from the known clock layout" + print(f" {name:20s} {size:5d} B {len(offs):4d} volatile ({note})") + print(f" {'':20s} {offs[:20]}" + (" ..." if len(offs) > 20 else "")) out = SNAP_ROOT / serial / "volatile.json" out.parent.mkdir(parents=True, exist_ok=True) @@ -199,12 +219,79 @@ def cmd_diff(serial: str, a_label: str, b_label: str) -> None: print(f"\n{name} — {len(runs)} changed run(s)" + (f", {noise} volatile bytes ignored" if noise else "")) for off, run in runs: - print(f" @{off:5d} (0x{off:04x}) {run} B " + print(f" @{off:5d} (0x{off:04x}) content[{off - CONTENT:d}] {run} B " f"{a[off:off + run].hex()} -> {b[off:off + run].hex()}") for line in _interps(a, b, off, run): print(f" {line}") +def cmd_watch(mm: MicromateClient, serial: str, interval: float, + duration: float) -> None: + """Poll the config blocks and report each change as it lands. + + A round trip per setting means walking to the unit and back for every + field. This instead lets one person stand at the keypad changing settings + one at a time while every change is timestamped here, so a whole session is + one pass. Each distinct state is also saved as `watch-NNN`, so the + sequence can be re-diffed offline afterwards without the unit. + """ + vpath = SNAP_ROOT / serial / "volatile.json" + vol = json.loads(vpath.read_text()) if vpath.is_file() else {} + if not vol: + print("⚠ no volatile.json -- run `volatile` first.\n") + + print(f"watching every {interval:g}s" + + (f" for {duration:g}s" if duration else " until Ctrl-C")) + print("change ONE setting at a time on the unit's keypad; each change is") + print("timestamped below and saved as watch-NNN.\n") + + prev = read_all(mm) + save(serial, "watch-000", prev) + print(f"[{time.strftime('%H:%M:%S')}] baseline captured (watch-000)") + for k, v in sorted(prev.items()): + print(f" {k:20s} {len(v):5d} B") + print() + + n, t0 = 0, time.monotonic() + try: + while not duration or time.monotonic() - t0 < duration: + time.sleep(interval) + cur = read_all(mm) + hits = [] + for name in sorted(set(prev) & set(cur)): + a, b = prev[name], cur[name] + ignore = set(vol.get(name, [])) + if len(a) != len(b): + hits.append((name, None, len(a), len(b))) + continue + runs = _runs(a, b, ignore) + if runs: + hits.append((name, runs, None, None)) + if not hits: + continue + n += 1 + label = f"watch-{n:03d}" + save(serial, label, cur) + print(f"[{time.strftime('%H:%M:%S')}] CHANGE #{n} ({label})") + for name, runs, la, lb in hits: + if runs is None: + print(f" {name}: LENGTH {la} -> {lb} (a length change is a finding)") + continue + print(f" {name} — {len(runs)} run(s)") + for off, run in runs: + a, b = prev[name], cur[name] + print(f" @{off:5d} (0x{off:04x}) content[{off - CONTENT:d}] {run} B " + f"{a[off:off + run].hex()} -> {b[off:off + run].hex()}") + for line in _interps(a, b, off, run): + print(f" {line}") + print(flush=True) + prev = cur + except KeyboardInterrupt: + print("\nstopped.") + print(f"{n} change(s) recorded; snapshots watch-000..watch-{n:03d} under") + print(f" {SNAP_ROOT / serial}") + + def main() -> int: p = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) @@ -215,6 +302,9 @@ def main() -> int: s.add_argument("label") v = sub.add_parser("volatile", help="find bytes that move with nothing changed") v.add_argument("-n", type=int, default=4) + w = sub.add_parser("watch", help="poll and report each change as it lands") + w.add_argument("--interval", type=float, default=2.0) + w.add_argument("--duration", type=float, default=0.0, help="0 = until Ctrl-C") d = sub.add_parser("diff", help="diff two saved snapshots") d.add_argument("a") d.add_argument("b") @@ -243,6 +333,8 @@ def main() -> int: print(f" {k:20s} {len(v2):5d} B") elif a.cmd == "volatile": cmd_volatile(mm, serial, a.n) + elif a.cmd == "watch": + cmd_watch(mm, serial, a.interval, a.duration) elif a.cmd == "diff": cmd_diff(serial, a.a, a.b) finally: