THOR's watcher (and Blastware's ACH) store every event through
/db/import/idf_file and /db/import/blastware_file, with the paired report.
Storing a download of the same event afterwards overwrote that richer copy:
on Series 4 the file, .h5 and sidecar were rewritten (extensions dropped);
on Series 3 the row lost PVS, project strings and ZC frequencies and was
repointed at a second, review-less file set.
persist_download now looks up (serial, timestamp) first. A row there is
returned as it stands -- inserted false, detail.already_stored true -- with
no store call, no insert_events and no sidecar write. Never merge.
- DownloadedEvent gains `timestamp` (the unit's own event time) and
`record` (Series 4's 0x0C fields); both adapters set them.
- The Series-3 `event is None` guard now runs before backfill/save, with a
message that is true there ("nothing was stored").
- Tests build the watcher's state exactly as the import endpoints do and
prove the row dict, the sidecar bytes and the file mtimes are unchanged.
No schema change, no migration, no codec change.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
get_event() now delegates to fetch_event(), which returns (blob, result).
The same peak-vector-sum self-check applies, so a DecodeMismatch still stops
the bytes from being stored. get_event() keeps its signature and behaviour.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
list_event_headers() walks every event's 0A/1E/0C/1F without starting a 5A.
download_event_by_key() downloads one event in full and walks past the others
without their 5A, stopping once it has it. Both ride two new keyword options on
get_events() (headers_only, only_key); the default path is unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
The /device guard let every non-UM serial through before its held-line
check. FastAPI drops an undeclared `serial`, so `?serial=BE18193` on a
legacy route still ran Series-3 code at an address holding a Series-4
line -- the hole the guard exists to close. Serial-aware routes go
straight to DeviceAccess, which refuses that case itself; everything
else is checked. baud is no longer parsed (it is not in the address
key, and pydantic's coercion made "38400.0" a second way past).
Also, from the same review:
- RingWatchTransport clears its frame state on every write, so a stray
STX on an idle line cannot hide the ring that answers the next request.
- Series4Session.is_open reads _client once; held_serial() calls it
without the unit lock, and a concurrent hang-up between two reads was
an AttributeError (a 500).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
0x06 content[0:4] moves from the bench tool into the client, tested against a real UM20147 read and its chain-walk count. read_unsolicited() reads without sending, for spotting RADIO RING on an idle session.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
Ten tasks, test-first: the is_open fix, two client reads, core types, the
per-unit lock, both adapters, Series-4 sessions with ring safety,
DeviceAccess with the reaper and the contract tests, the endpoints, and a
read-only bench check on UM20147.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
Nothing breaks between phases: the shared models apply when a request names
the unit by serial, and the legacy Series-3 path stays as it is until the
webapp (1c) and watch_unit.sh move over.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
Brian's principle: talking to a Series 3 or a Series 4 unit is identical for
the user; only the serial prefix and each model's settings differ, and the
adapters absorb the rest.
Five places the draft broke it, now fixed: units are named the same way
(serial + address, no-serial kept only as a legacy Series-3 path); one set
of series-neutral response models with series-only fields under `detail`;
one opaque event_id for both; a uniform 501 "not supported for Series N
yet" instead of missing routes; and the webapp brought into scope with the
same screens for both. Adds an adapter table, contract tests that keep the
two adapters honest, and notes that existing Series-3 response shapes move
to the shared models (the webapp updates with them; Terra-View does not
call /device/*).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
Parity of jobs with Series 3 for regular comms and settings (identify,
status, settings, events, download, monitor log, start/stop, call-home
enable/disable, setup push); Series-4 emergency tools deferred. A single
device-access layer: series from the serial prefix, identity confirmed
before any write, a per-unit lock, an 0xA2 opcode guard, read-back
verification of every change, distinct error codes, and an audit table.
Series-4 sessions ("stay on the line") now; Series-3 sessions after a bench
test of MiniMate hangup/DCD behaviour.
Includes the fix list found in the 2026-10-19 inventory, the to-be-added
table, and the RX55 container idea as a parking-lot item.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
Folded into the existing Unreleased sections.
Added: MicromateClient.get_setup() (verified line by line against UM20147's
screen), micromate.setup_block.crc_ok() for 0x1A/0x08/0x2E, the config diff
harness, and the decoded setup in mm_client_check.
Changed: the 0x1A field map; channel blocks 4/5/6 are the active mic and two
stored mic setups; 0x1A reads the edit buffer and a load replaces it
byte-for-byte; the unit's own conversion constants (3.2808, 2.21); 0x08 is
preferences; the geophone scale confirmed from the unit's config; the 0x1C
sub-second tick; the never-write-modem-baud rule; two corrected 16-byte slips;
and the Series III anchor hypothesis, flagged inferred with no code change.
Fixed: the watcher overwriting previous sessions, and two stale bench-tool
labels.
Migration stays None -- additive modules only, no codec/store/DB change, no
TOOL_VERSION bump, no backfill.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
Closes the gap the 10-13 recap named: config blocks were fetched but barely
read. Two keypad passes on UM20147 (10-17, 10-19), every byte that moved
attributed to a setting the operator named, then the map turned into code.
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, trigger levels, mic
type and level, job number, scaled distance, notes. Measured fields only.
Every value matched UM20147's screen.
Findings that shape what comes next:
1. ONE CHECKSUM RULE (CRC-16/AUG-CCITT) covers 0x1A, 0x08 and 0x2E -- a free
integrity check on every config read. Thor's write omits it; the unit
computes it, so it is not a write obligation.
2. LOADING A SETUP REPLACES THE ACTIVE CONFIG BYTE-FOR-BYTE, and 0x1A reads
the keypad's edit buffer live. The name is the only link between a file
and its contents, and even its spelling varies (.MMB / .mmb).
3. THE SIX CHANNEL BLOCKS ARE 3 GEOPHONES + THE ACTIVE MIC + TWO STORED MIC
SETUPS. Read the mic from block 4 only.
4. THE UNIT CONVERTS UNITS WITH ITS OWN CONSTANTS (ft / 3.2808, lb / 2.21).
Convert back with them or 45 lb reads 44.89.
5. 0x08 IS THE PREFERENCES BLOCK; display units live there and never touch
the stored setup values.
6. NEVER WRITE MODEM BAUD OR MODEM TYPE REMOTELY -- the remote link is the
modem port.
INFERRED, Series III, no code changed: S3's 6-byte "stable anchor" sits where
Series IV keeps pre-trigger + stop mode, so an S3 unit in Auto stop mode may
lose it. One Blastware capture in Auto mode settles it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
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
23 more snapshots of UM20147, keypad-driven.
MEASURED: loading a .MMB replaces the active config byte-for-byte -- three
loads, each moving exactly the fields that differ, the loaded block identical
to the file's saved state, no load marker. The setup name's spelling
(.MMB/.mmb) depends on whether it was saved or loaded.
MEASURED: job number [40:42], report flags [39] (0x02 job no., 0x08 scaled
distance; 0x01 unknown); distance [30:34] in metres and charge weight
[34:38] in kg, converted bit-exactly with ft / 3.2808 and lb / 2.21 -- the
firmware's own constants, not the textbook ones. Scaled distance is not
stored. Location confirmed at [144].
MEASURED: 0x08 is the preferences block (display units at content[31]),
not an event index; switching units moves nothing in 0x1A. 0x1A, 0x08 and
0x2E share one checksum rule (N = content[0:2]; CRC over [0:N-2] at
[N:N+2]); 0x2C has none. 0x2C session timeout is at [118:120], encoding
unknown; modem baud is in none of the six blocks.
CORRECTED IN PLACE: the 9-24 notes-label offset (0x8A -> 0x7A) and
channel-block start (0x06BC -> 0x06AC), both 16-byte slips.
RULE: never write modem baud or modem type remotely -- the remote link is
the modem port.
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
Brian's hypothesis from the end of the 10-17 pass: selecting a .MMB
repopulates the active config, so a single load moves every field that
differs between two setups -- a check of the whole map in one step.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
47 snapshots of UM20147 while settings were changed on its own keypad, one
at a time. Every byte that moved is accounted for; nothing outside 0x1A
moved.
MEASURED (operator named setting + values): record mode [5] (01 Waveform,
02 Manual, 03 Histogram, 04 Combo -- S3's encoding, one byte later than the
S3 analogy put it), sample rate [6:8], histogram interval [8:10] s,
pre-trigger [12:16] f32 negative s (all four values), stop mode [17], record
time [18:22] f32, auto-stop [23], active-sensor and trigger-source bitmasks
[25]/[29], trigger level at channel +30 (geo in/s, mic psi).
MEASURED: the trailer is CRC-16/AUG-CCITT over content[0:2088] -- 47/47 and
a second unit. Thor's write omits it, so it is read-side integrity, not a
write obligation.
MEASURED: blocks 1-3 are geophones, block 4 is the ACTIVE mic (a byte copy
of 5 or 6), 5 and 6 are the stored linear / SLM mic setups. No separate
mic-type byte; block 4's +4:8 code is the type. Promotes the 10-15 "+4
channel type" guess; retracts "+46:48 is a trigger-source flag" in place.
MEASURED: 0x1A reads the keypad's edit buffer live; discard reverts;
commit timing differs by widget (list / spinner / sub-window).
INFERRED, Series III: the 6-byte "stable anchor" sits exactly where Series
IV keeps pre-trigger (-0.25 s) + stop mode (Fixed). An S3 unit in Auto
stop mode would lose it and decode no mode/rate/interval/record time. Not
measured on S3; noted in instantel_protocol_reference.md, code untouched.
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
`watch` saved every session as `watch-000..NNN`, so each run silently
overwrote the last. Harmless while those snapshots were clock ticks; data
loss once they were findings. Labels now default to `watch-MMDD-HHMM-NNN`
(`--prefix` overrides).
Each 0x1A change also prints its trailer check: CRC-16/AUG-CCITT over
content[0:2088], stored BE at content[2090:2092]. Measured on 47/47
snapshots of UM20147 plus UM12947's 9-24 capture; a mismatch means a short
or corrupt read, or a layout this does not assume.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
"Where things stand" said config decoding "needs a bench session varying one
setting at a time -- not desk work", which was true when written and now sends a
reader off to build tooling that exists. This is the same staleness that had
the file claiming micromate/ had no live client.
What it now says, because these are the things that cost time to rediscover:
- The harness is scratch/mm_config_diff.py and the baseline is already captured.
- THE METHOD IS VERIFIED VIABLE: all five config blocks are bit-stable, so any
byte differing between two snapshots IS the setting. That was the open
question about whether the Series III approach transfers at all.
- Start with SAMPLE RATE. A large distinctive power of two pins endianness in
one shot; a boolean toggle moves one byte 0 -> 1 and teaches nothing.
- The keypad works. No Windows VM, no contending for the modem's single TCP
session.
- `sg dialout -c` is required to open /dev/ttyACM0, because the group membership
exists in /etc/group but not in shells started before it was added -- AND THE
FAILURE LOOKS LIKE A DEAD UNIT, which is worth a line on its own.
- watch-001..005 on disk are clock ticks, not findings.
- channel+24 = 3.1030800342559814, independently confirming _GEO_LSB_IPS to
1.1e-8 and 32,226.05 counts exactly.
- The rest of that channel map is GRADED and the grades are load-bearing: +4
"channel type" and the +8:24 uint16 split are single-setup guesses, recorded
as guesses on purpose.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ru8Lg9HkkYvX9VWWo65SmL
and two are guesses
Six 48-byte channel blocks at content[1708], stride exactly 48: Tran, Vert,
Long, Mic, LMic, SMic. (Mic is 3 chars, so a 4+-printable scan misses it and
the stride looks like 96 across that gap.)
RECORDED IN THREE EXPLICIT GRADES, because I wrote them in one voice first and
that is the failure mode this reference already carries retractions for -- the
0x0C float from a single sample, the cost model fitted to sub-1 KB responses,
offset detector v1. All three were an interpretation presented with the
confidence of a measurement.
MEASURED, and the one worth having: channel+24 is a float32 BE reading
3.1030800342559814 on all three geo channels. Divided by 10,000 that is
0.00031030800342559815 -- the documented _GEO_LSB_IPS to 1.1e-8. It implies
10.0/3.10308 = 3.222605 V full scale, which at 10,000 counts/V gives 32226.05
counts, the documented figure exactly.
That is an INDEPENDENT confirmation of a number that until now rested purely on
statistical inference: _GEO_LSB_IPS was pinned by intersecting 991,415 rounding
constraints from Thor's own CSV exports. The unit reports it directly. Two
unrelated derivations agreeing to eight digits. It is also almost exactly half
Series III's 6.206053 (ratio 1.99997, the residual being S3's rounded display
value).
Also measured: the units strings ("in."/"/s.", "psi"/"(L)", "dB"/"(A)") are
literal ASCII, and Tran/Vert/Long are byte-identical EXCEPT +47, which reads
0x01 on Tran and Vert and 0x00 on Long.
INFERRED (one setup, one unit): that +24 is the calibration constant rather than
another field holding the same number -- the arithmetic proves the number, not
the field's purpose; and that +47 is an enable or trigger-source flag.
GUESSED, explicitly flagged not to build on: +4 as a uint32 "channel type", from
six correlated observations in a single setup; and +8:24 as eight uint16 BE
values, where the split itself is an assumption.
TOOLING FIX in the same commit, from a real miss: the volatile baseline ran four
reads over eight seconds, so it never crossed a minute boundary and never saw
the minutes byte. Five "changes" then came in a row that were just the clock.
Hours and the date would have slipped through identically. An empirical noise
floor only catches what moves WHILE sampling, so 0x1C's known clock span
(content[2:10]) is now seeded regardless, and the report says which bytes were
observed versus seeded. Memory-free is deliberately left unmasked -- it moves
only when the unit records, which is worth being told about.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ru8Lg9HkkYvX9VWWo65SmL