9 Commits
Author SHA1 Message Date
serversdownandClaude Opus 5.5 b3aff4ed66 feat(micromate): get_setup() -- the setup block decoded, checksum-verified, and read off a real unit
MicromateClient.get_setup() reads SUB 0x1A once and returns a MicromateSetup:
record mode, sample rate, histogram interval, pre-trigger, stop mode, record
time, auto-stop, active sensors, trigger sources, the three geophone trigger
levels, mic type and (linear) mic trigger, job number, scaled distance, and
the four notes.  MEASURED FIELDS ONLY -- everything graded inferred or
unknown in the reference stays in .raw.

micromate/setup_block.py holds the decode as pure functions (no I/O), plus
crc_ok(): one checksum rule for 0x1A, 0x08 and 0x2E.  A failed checksum
raises SetupChecksumError (a ProtocolError) unless verify=False; a short
block raises either way.

Two things the decoder gets right that a naive one would not:
- the mic comes from channel block 4 (the ACTIVE mic), never blocks 5/6,
  which hold the stored settings of whichever mic is NOT fitted;
- distance and charge weight convert back with the unit's own 3.2808 and
  2.21, so 45 lb entered on the unit reads 45.0, not 44.89.

TESTS: 69 new.  15 real fixtures (2,103 B each) -- 14 UM20147 reads from the
10-17/10-19 keypad passes, chosen so every field takes at least two values,
plus UM12947's read from Thor's 9-24 capture (other firmware line).
Expected values are what the operator read off the unit's screen, never the
decoder's own output.  Fixtures force-added, per the tests/fixtures/
convention.  Full suite 541 passed; the 16 pre-existing failures
(test_bw_ascii_report.py 15, test_event_file_io.py 1) are unchanged.

VERIFIED ON HARDWARE: bridges/mm_client_check.py now prints the decoded
setup; against UM20147 every line matched the unit's screen (Brian, 10-19).

Also: the scratch harness uses the library checksum and checks all three
blocks; mm_client_check's stale labels fixed (0x06 content[4:8] is the
likely monitor-log count, not "unexplained"; 11.0BD is no longer "the first
one this code has met").

No codec, store or DB change; no backfill.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
2026-10-19 18:20:25 -04:00
serversdownandClaude Opus 5 67de2c18da fix(tooling): mm_client_check reported THOR's request count, not its own
The download line computed `size // 1024` -- THOR's chunk size -- while the
download used the 16 KB default.  So a 72,560 B event that took 5 requests was
printed as "71 chunks", and I nearly read a working 16 KB download as a broken
1 KB one.  A diagnostic that misreports what it did is worse than one that says
nothing.

Now prints the real count and the size used: "5 req @ 16384 B".

Verified by counting the frames in a capture of that run: 5 x SUB 0x5A at
offsets 0x4000 0x4000 0x4000 0x4000 0x1b70, summing to exactly 72,560.  That is
also the FIRST time the 16 KB chunk size has run through the real download loop
on hardware -- previously only the probe had issued 16 KB single requests, and
the loop itself had only been exercised at 1024 B against THOR's frames and at
16 KB against simulated responses.

Also recorded: USB identification for the Micromate's own ports.  Its PC port is
2504:0300 (Instantel Inc. MICROMATE COM PORT), appearing as CDC-ACM, against
0403 FTDI and 067b Prolific for the USB-A host-port cables.  Address it by
/dev/serial/by-id/ and not /dev/ttyACM<n>, because the number moves whenever
another CDC-ACM device appears -- which has already cost a session aimed at a
TMI-Seismo MCU by mistake.

And: passing one through to a Proxmox guest hot-plugs with no VM restart via
`qm set <vmid> -usb0 host=2504:0300`.  UM20147 is now on tmi-dev (10.0.0.44)
this way, which means the unit can be driven from the dev VM directly instead of
relaying commands.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ru8Lg9HkkYvX9VWWo65SmL
2026-10-14 12:46:01 -04:00
serversdownandClaude Opus 5 338ce4fea7 docs(series4): CORRECTED -- cellular cost is NOT independent of payload
I had it as "~0.65 s per round trip, independent of payload size", and based
design advice on it ("minimise round trips, not bytes").  The first claim is
wrong and the second is too strong.

Every measurement behind it had a SMALL payload -- 59 B status, 266 B setup
records, 1024 B download chunks.  With the byte term small and similar across all
of them, per-command cost looked constant.  It was a narrow-range fit
extrapolated past its evidence.

Measured against a 14,176 B single response on UM12947 over an RX55:

  1,024 B   0.67 s      8,192 B   3.59 s
  2,048 B   1.22 s     14,176 B   6.25 s
  4,096 B   2.13 s

  t ~ 0.21 s + bytes / 2,350   -- fits within +/-11% over a 14x size range

The old 0.65 s figure was right FOR A 1 KB RESPONSE and is that model evaluated
at 1 KB.  Round trips still cost (0.21 s each; 24 of them for a setup walk is
still 16 s), but bytes cost more than round trips on anything over ~500 B, and
that reverses the advice: for STATUS work minimise commands, for DOWNLOADS the
floor is throughput and batching does not beat it.

So the 16 KB chunk size is a ~30% win, not 14x.  UM20147's 72,560-byte event is
~46 s at THOR's 1024 B and ~32 s at 16,384 B, because ~31 s of it is bytes on the
wire.  Still worth keeping -- 30% faster, and 14x fewer requests is 14x fewer
chances for a link to drop mid-download -- but the earlier "~3.2 s" projection
was wrong and is withdrawn.

Corrected in all four places it had propagated: the protocol reference, the
CHUNK_SIZE comment, the probe's verdict, and mm_client_check's banner.  The probe
now also prints a net time per measurement, since its raw timings include the
idle gap while the control reads to frame completion -- comparing them directly
was misleading.

Also confirmed in the same run: 16 KB-class responses survive a cellular PAD.
1,024 / 2,048 / 4,096 / 8,192 / 14,176 B all arrived in one frame, byte-identical,
over an RX55.  14,176 B is UM12947's largest event so the ceiling itself was not
reached, but a 14 KB response crossing the PAD intact is what needed proving.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ru8Lg9HkkYvX9VWWo65SmL
2026-10-02 15:09:38 -04:00
serversdownandClaude Opus 5 0cfec2f098 tooling(micromate): --event selects what to download, incl. 'largest'
The tool downloaded only the first event, which on UM20147 is a 4,796 B
histogram -- so it could not reach the 72,560 B event that is the whole point of
the uint32 chunk-offset change.

--event takes a key in hex, 'first', 'largest' or 'all'.  'largest' is the one
worth running on an unfamiliar unit, since it is what exercises offsets past
64 KB; the output flags any event over 64 KB as carrying into params[1], and
prints the chunk count so a 71-chunk walk is visible as such.

Selected events are downloaded from inside iter_events(), so the chain cursor
sits where THOR's would -- non-selected events are walked past without a
download, which the browse walk already attests is fine.

Also: connect() returning nothing now prints a hint rather than just a bare
timeout.  /dev/ttyACM* numbering shifts whenever another CDC-ACM device is
plugged in, and this cost a debugging session when the tool was aimed at a
TMI-Seismo MCU instead of the Micromate.  `ls -l /dev/serial/by-id/` names each
device and is stable, so the hint says so.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ru8Lg9HkkYvX9VWWo65SmL
2026-10-01 16:04:21 -04:00
serversdownandClaude Opus 5 15be9eafdb tooling(micromate): exercise the event chain, and test the 0x06 count candidate
mm_client_check now drives the step-4 client methods rather than the protocol
layer directly -- list_events(), iter_events(), get_event() and decode_error()
-- so a bench run exercises the code that will actually be used.

Prints each ref with the filename it would be stored under, and reports the PVS
self-check result per event.  The download uses iter_events(), which reproduces
THOR's interleaved order.

Adds the 0x06 test: reads storage range BEFORE the chain walk, prints
content[0:4] as the candidate event count and content[4:8] as the unexplained
companion value, then reports AGREES or DISAGREES against the chain length.
Two samples on one unit said the count is right; a third value from a different
unit either confirms it or kills it, and the tool now answers that in one run.

The 0x06 read is wrapped in the same step() helper as everything else, so a unit
that does not answer it degrades to a FAILED line rather than aborting the run.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ru8Lg9HkkYvX9VWWo65SmL
2026-09-30 18:48:58 -04:00
serversdownandClaude Opus 5 b55e4e946a verify(micromate): 11.0BD confirmed on hardware -- every inference held
UM20147 read over USB by mm_client_check.py.  The Thor firmware line was
entirely inference until now, and two of its three differences were covered
only by SYNTHESISED test frames.  All three held:

- flags = 0x03 identifies the line -> reported firmware_line="thor".  That is
  only reachable if `10 03` in the flags position destuffs before indexing,
  since 0x03 is ETX -- so the escaped-flags case is confirmed too.
- the model string is shorter -> reported "MM/ISEE/S" exactly.  Anchoring the
  search on b"MM/" rather than a fixed span is what made this work.
- the 0x1C block is 4 bytes longer with the extras TRAILING, so from-the-start
  offsets survive -> battery 3.55 V and a clock correct to the second.

That last one is the one that mattered.  Series III's from-the-end offsets
would have given this unit 577.92 V, which is why mm_client_check watches for
an impossible voltage: it is a free self-check on exactly the inference most
likely to be wrong.

Also clean: serial UM20147, 5 setups (factory.MMB -> test2.mmb), active setup
test2.mmb, 15,000,000 B total and free, 21 reads / 2,165 B in.

"One protocol stack drives the whole fleet regardless of firmware line" -- the
headline finding of 2026-09-23 -- is now demonstrated by a working client
rather than by matching response SUBs.

Test and docstring claims downgraded from inference to confirmed where the
hardware settled them, and left as synthesised-frame notes where it did not:
the BEHAVIOUR is confirmed but raw BD bytes are still not in the repo.

Added --capture DIR to mm_client_check: writes a raw_bw_*/raw_s3_* pair in the
layout scratch/mm_frame_parse.py already reads, so a run on an unfamiliar unit
becomes a test fixture without setting up a relay.  Verified by round-tripping
its own output through that parser: 28 frames, 0 bad checksums.

Still not covered: a download from a BD unit (UM20147 had no events stored, so
the chunk walk remains CB-only), raw BD fixture bytes, a monitoring unit, a
nearly-full buffer, and the inbound call-home session.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ru8Lg9HkkYvX9VWWo65SmL
2026-09-30 13:17:53 -04:00
serversdownandClaude Opus 5 0d6eb1621f verify(micromate): read client works on real hardware, both transports
Run against UM12947 by bridges/mm_client_check.py, read-only, over the USB-B
CDC-ACM port and over the RX55 to TCP :9034.

THE WIRE BYTES ARE IDENTICAL ON BOTH PATHS -- 11,580 B in and 761 B out, to
the byte, with matching identity, state and a 24-entry setup walk.  The
protocol does not care which physical layer it runs over, which is the thing
the modem path needed to prove.

Three findings, one of them a correction to my own prediction:

1. THE MODEM NEEDS FEWER READS, NOT MORE.  36 against USB's 83.  The tool's
   banner claimed the opposite.  The modem coalesces -- it buffers ~1 s then
   forwards one large TCP segment, where CDC-ACM delivers many small chunks.
   That is reassuring rather than alarming: the risk was a frame arriving
   split across reads, and the modem splits LESS than USB does.  Banner fixed
   to state the measured numbers instead of a guess.

2. ~0.65 s PER ROUND TRIP over cellular, independent of payload size.  A
   1,024 B chunk and a 16 B state read cost the same.  list_setups() takes
   16.05 s over the modem against 0.46 s over USB, for 24 commands.

   This is the number that matters for SFM's design: over cellular, minimise
   round trips, not bytes.  Enumerating setups costs 16 s -- cache it, never
   refresh it on a timer.  A 13 KB event is 14 chunks ~ 8.4 s of latency
   against ~0.03 s of data, which makes the unconfirmed single-request 0x5A
   streaming mode worth its two-minute bench test on its own.

3. THERE IS A RECORD-TYPE FIELD: 0x0C content[11], 0x07 waveform, 0x08
   histogram.  The reference says no type field is known and that the type
   must be carried out of the chain walk.  Found by diffing the six bench
   events' 0x0C records against their known types -- exactly one byte
   separates the groups and is constant within each -- then confirmed by
   predicting the right suffix for 6 of 6 on a blind re-run.

   Six events split 4/2 is thin evidence for a byte that could be a counter or
   a channel count, so it is recorded as a strong candidate, not settled, and
   mm_client_check keeps a fallback: it tries the other suffix on failure and
   says when the guess was wrong.

   Also flagged: the reference's claim that the type comes from SUB 0x0A's
   length is not visible in the download capture, where 0x0A is a standalone
   monitor-log walk after the last chain entry, not a per-event probe.

END TO END: all six bench events assembled by read_event_file() from captured
0x5A responses decode with the existing codec -- 4 waveforms at 12,288 /
12,288 / 12,288 / 8,192 samples and 2 histograms.  No new codec work needed;
/db/import/idf_file ingests a directly downloaded event unchanged.

Not covered: 11.0BD (still pure inference), a monitoring unit, a nearly-full
buffer, and the inbound call-home session.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ru8Lg9HkkYvX9VWWo65SmL
2026-09-29 14:13:36 -04:00
serversdownandClaude Opus 5 f7d9a1d9cb tooling(micromate): drop the pyserial dependency from mm_client_check
Hit on the bench: mint-mac has no pyserial, and `pip install pyserial` is
refused outright by PEP 668 (externally-managed-environment) on Mint 22 /
Ubuntu 24.04 / Debian 12.  A field diagnostic that needs a pip install on a
locked-down host is one you cannot run at the moment you need it -- which is
exactly when this tool is for.

Replaced minimateplus.SerialTransport with a ~30-line stdlib `termios` port,
the same approach bridges/mm_link.py and scratch/fake_unit.py already take in
this repo.  Runs on a stock Python 3 anywhere.

Not a general SerialTransport replacement: no flow control, no parity options,
Linux/macOS only.  Enough for a Micromate, which is 8N1 with no handshaking.

Verified end to end against a fake unit on a pty, dribbling responses in
64-byte pieces: 194 reads for 10,958 B, identity/state/setup-walk all correct,
and a 4,076 B event downloaded across 4 chunks at the exact expected length.

Also clarified --baud in the help: it applies to the USB-A/FTDI path, and is
ignored by the USB-B "PC" port, which is CDC-ACM and negotiates its own rate.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ru8Lg9HkkYvX9VWWo65SmL
2026-09-29 14:06:55 -04:00
serversdownandClaude Opus 5 c7ffdab570 tooling(micromate): mm_client_check -- exercise the read client on real hardware
Read-only: POLL, SERIAL, state, monitor status, the setup walk, and optionally
one event download.  Never writes, erases, or changes monitoring state.

Exists because everything in micromate/{framing,protocol,client}.py is
verified against captures taken over USB on one firmware line (11.0CB).  Two
things that cannot be verified that way:

- The modem path.  An RX55/RV55 buffers up to ~1 s before forwarding, so one
  logical response arrives as many small reads.  The client reads to frame
  completion rather than using read_until_idle's idle-gap detection, which
  should be strictly more robust for this -- but that needed proving.
- The 11.0BD firmware line, which reports flags=0x03, a shorter model string,
  and a 0x1C block 4 bytes longer.  All inference from one 2026-09-23 sweep
  whose captures never landed in the repo.  The tool says so loudly when it
  meets one, and flags an impossible battery voltage as the signature of the
  from-the-end offset bug.

Run it over both paths and diff; anything differing beyond timings is a
finding.  It counts reads and bytes per transport, because a higher read count
for the same bytes IS the buffering, made visible.

Smoke-tested against a scripted TCP unit replaying captured response bytes in
37-byte dribbles: 289 reads to carry 10,958 B, every frame reassembled, a
4,076 B event downloaded across 4 chunks with the assembled length exact.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ru8Lg9HkkYvX9VWWo65SmL
2026-09-28 20:30:11 -04:00