13 Commits
Author SHA1 Message Date
serversdownandClaude Opus 5 4c29820831 docs(changelog): the Series-4 call-home session, and two more corrections
Folded into the existing Unreleased sections.

Added: bridges/mm_ach_server.py, flagged as implementing the listener path only.

Changed: the captured ACH session (101 frames, every command already
implemented bar one); the two call-home paths and what decides between them; the
0xA2 collision with series III's CONFIRM ERASE; monitor-while-calling-home
blocking erase while THOR reports success; THOR rewriting unit IPs from the
call-home source; and the CLAUDE.md refresh.

Fixed: mm_client_check misreporting its own request count, the ACH server
buffering its output and leaving modem chatter as a hex dump, and .gitignore
missing capture artefacts beside tracked bridge source.

TWO ENTRIES CORRECT THIS FILE'S OWN EARLIER TEXT, which is the part worth
reading: 0x06 content[4:8] was recorded here as "a constant, 9 on both units"
and is the monitor-log count; SUB 0x49 was recorded as two states and has three.

Migration stays None -- no codec, store, DB or schema change and no TOOL_VERSION
bump -- but the note now says explicitly that THE 0xA2 COLLISION IS DOCUMENTATION
RATHER THAN A FIX.  minimateplus can already send 0xA2 as the last step of its
erase sequence, and nothing yet stops a future shared path confusing the two
meanings.  A guard is outstanding, and a reader deciding whether this release is
safe deserves to know that.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ru8Lg9HkkYvX9VWWo65SmL
2026-10-15 00:06:45 -04:00
serversdownandClaude Opus 5 8b48b3f42b merge: the Series-4 call-home session, captured end to end
Closes the last protocol unknown.  A MITM between UM12947's modem and THOR
1.5.0.29 captured a complete working ACH session: 101 request frames, 101
responses, 0 bad checksums, 34,872 B of event data in 65 seconds.

EVERY COMMAND IN A REAL ACH SESSION IS ONE micromate/protocol.py ALREADY
IMPLEMENTS -- POLL, BULK_DOWNLOAD, STATE, EVENT_RECORD, EVENT_NEXT,
STORAGE_RANGE, MONITOR_STATUS, ARM_EVENT, SERIAL, EVENT_FIRST -- bar one.

Three findings that change how a receiver must be built:

1. CALL-HOME HAS TWO PATHS, decided by who holds the modem's single TCP
   session.  If something is already connected, the unit's RADIO RING travels up
   THAT connection; if nothing is, the modem dials out to a listener.  THOR's
   UnitWatchDogTimer reconnects continuously, so THOR usually holds the slot --
   which is why probes and relays saw "connected, no reply" all afternoon.  That
   was contention, not a fault.

2. SUB 0xA2 ENDS A CALL-HOME ON SERIES IV AND IS CONFIRM ERASE ON SERIES III.
   Same opcode, same 0x5D response, opposite consequence.  minimateplus and
   micromate already share a transport, so any shared path must dispatch on
   series before that byte reaches a wire.  This is a hazard in code that
   already ships, which is the main reason this merge should not wait.

3. "MONITOR WHILE CALLING HOME" SILENTLY BLOCKS ERASE, and THOR reports the
   session successful anyway.  A receiver therefore cannot rely on erase to
   manage storage -- the server-side high-water mark is load-bearing, and the
   condition is detectable from event count plus free memory on every call.

Two corrections to entries made earlier this month: 0x06 content[4:8] is the
monitor-log count rather than a constant, and SUB 0x49 has a third state (0x03,
in-call-home) which is why that flag is tested for non-zero.

bridges/mm_ach_server.py implements the LISTENER path only and says so; the
poller half -- holding outbound connections and watching for the ring -- is the
next piece of work.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ru8Lg9HkkYvX9VWWo65SmL
2026-10-15 00:05:47 -04:00
serversdownandClaude Opus 5 9c8eb5c5b8 docs(claude): refresh "Where things stand" -- it claimed there was no live client
Stale since 2026-09-26, and wrong in two ways that matter to anyone picking the
project up:

- "micromate/ still has no live client -- it is codec-only."  There has been a
  full client since 2026-10-02: framing/protocol/client + models, 119 tests,
  verified on hardware across both firmware lines and both transports.
- "the inbound call-home session is the only protocol unknown left."  It was
  captured end to end on 2026-10-14.  There are no protocol unknowns left.

Replaced with the current state, and added the three things a reader most needs
up front: that ACH has TWO paths decided by who holds the modem's single session
(so silence from a probe is usually contention with THOR, not a fault); that
0xA2 ends a call-home on series IV and CONFIRMS ERASE on series III across a
shared transport; and that monitor-while-calling-home blocks erase while THOR
calls the session a success, which makes the server-side high-water mark
load-bearing.

Also named the real remaining gap honestly: config decoding, not protocol.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ru8Lg9HkkYvX9VWWo65SmL
2026-10-14 19:51:46 -04:00
serversdownandClaude Opus 5 7645c91ae2 docs(series4): monitor-while-calling-home blocks erase, and THOR calls it success
Manual 11.4.4: a Micromate can call home WHILE IT CONTINUES TO MONITOR, or pause
monitoring and send.  UM12947 is on the former, which is why the captured session
logged "CANNOT DOWNLOAD MONITOR LOG" and "CANNOT DELETE ALL EVENTS -- The unit is
monitoring".

THOR REPORTS THAT SESSION AS "SESSION COMPLETED SECCESSFULLY" ANYWAY.  The
refusals are INFO lines.  From outside, a unit quietly accumulating looks
identical to one being managed correctly.

Correcting my own framing from earlier today: I flagged "Delete Events and Logs
from Unit = Yes" as a risk to the test data.  It is TMI's normal and necessary
fleet setting -- without it a unit fills up and re-offers every event on every
call.  A unit left on monitor-while-calling-home is the misconfigured one, and
drifts toward a full buffer by itself.

DESIGN CONSEQUENCE FOR SFM: a receiver cannot rely on erase to manage storage.
The erase can fail for a reason the unit considers normal, so the server-side
high-water mark is LOAD-BEARING rather than an optimisation -- it is the only
thing preventing a full re-download every session.  Series III's ach_state.json
(downloaded_keys / max_downloaded_key) is the pattern and has to carry over
deliberately.

Also a detectable fleet-health signal: "memory filling AND deletes refused" is
visible on every call from 0x06's event count and 0x1C's memory fields.  Worth
surfacing precisely because THOR calls it success.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ru8Lg9HkkYvX9VWWo65SmL
2026-10-14 18:37:10 -04:00
serversdownandClaude Opus 5 08d2d31a09 docs(series4): a complete ACH session captured -- and 0xA2 is a loaded gun
MITM between UM12947's modem and THOR 1.5.0.29: 101 request frames, 101
responses, 0 bad checksums, 34,872 B of event data in 65 seconds.

EVERY COMMAND IN A REAL ACH SESSION IS ONE WE ALREADY IMPLEMENT -- POLL, SERIAL,
STORAGE_RANGE, MONITOR_STATUS, STATE, ARM_EVENT, EVENT_FIRST/NEXT, EVENT_RECORD,
BULK_DOWNLOAD -- except one.

SUB 0xA2 ENDS A CALL-HOME, AND COLLIDES WITH SERIES III'S ERASE.  The session's
final command is 0xA2 at offset 0xFFFF, answered 0x5D, and THOR's log at that
instant reads "StartMonitoringAfterCallhome / Switching unit back to monitoring".
So on series IV it means exit call-home and resume monitoring.

On SERIES III, 0xA2 -> 0x5D is CONFIRM ERASE -- the last step of
0xA3/0x1C/0x06/0xA2, after which the unit's memory is cleared.  Same opcode, same
response SUB, opposite consequence.  This is the most dangerous collision found
in this protocol: minimateplus and micromate already share a transport, and
sending 0xA2 to a MiniMate Plus to "end a session" erases it.  Any shared path
must dispatch on series before that byte goes near a wire.

It also corroborates the firmware string found by static analysis in September,
CMD_EXIT_CALL_HOME_DELETE_EVENTS_START_MONITORING.

TWO CORRECTIONS TO EARLIER ENTRIES OF MINE:

- 0x06 content[4:8] was recorded on 2026-10-01 as "9 on both units regardless of
  count -- a constant, not a count".  It reads 47 here, where THOR's log twelve
  minutes earlier reported "Monitor Log count: 45" on the same unit.  It is
  almost certainly the monitor-log count; both units reading 9 just meant both
  held 9 records.

- SUB 0x49 was recorded as 0x00 idle / 0x02 monitoring.  It reads 0x03 throughout
  this session, ten for ten -- a distinct in-call-home state.  Precisely why the
  rule is "test for non-zero": a client checking == 0x02 would call a unit
  mid-call-home idle.

Also softened the claim that mm_ach_server is "built on the wrong model".
ListenerAchTcp HAS now accepted a connection -- when nothing else holds the
modem's single session, the unit dials out and the listener takes it; when THOR
already holds a connection, the ring rides that instead.  Both paths are real.
The listener model is valid, it just loses the race against anything already
connected -- which explains every failed probe and relay attempt today as
contention rather than bugs.

And noted: THOR rewrites a unit's stored IP from the call-home source address, so
a relay silently poisons THOR's record of where that unit lives.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ru8Lg9HkkYvX9VWWo65SmL
2026-10-14 18:35:38 -04:00
serversdownandClaude Opus 5 8f67608e0f feat(micromate): answer a RADIO RING the way THOR does -- SERIAL, immediately
THOR's ACH log exposed two differences between what it does on seeing a ring and
what we were doing, and either could explain why the unit never answered us:

              | ours              | THOR
  command     | POLL (0x5B)       | ReadSerialNumber (0x15)
  delay       | 8 s (grace window)| 36 ms

We sat silent for the whole grace window and then asked a different question.
The unit may well have given up long before we spoke.

So the grace window now ENDS THE MOMENT a RING is seen, and the ring is answered
with SERIAL first -- which is THOR identifying which unit rang before doing
anything else.  The push-vs-pull experiment the window was built for is
unaffected: silence still runs the full duration.

This does not change the bigger finding that mm_ach_server is built on the wrong
model for a PAD-connected unit -- THOR's working path is a POLLER holding an
outbound connection, not a listener.  But if a unit whose modem dials out can be
made to answer on the inbound path too, that is worth knowing before the rewrite,
and it costs two small changes to find out.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ru8Lg9HkkYvX9VWWo65SmL
2026-10-14 18:12:14 -04:00
serversdownandClaude Opus 5 90ac7ff76a docs(series4): SOLVED -- call-home is an in-band wake signal, not a dial-out
From THOR's own ACH log, 4,414 lines, UM12947 over an RX55.  This overturns the
model this document has carried from the start and explains every confusing
result of the past weeks.

A MICROMATE DOES NOT DIAL ANYBODY.  It emits the ASCII string "RADIO RING" over
its serial port, and that text travels up a TCP connection THE SERVER ALREADY HAS
OPEN TO THE UNIT.  The server recognises it and runs a session on that same
connection.

  17:18:17  TcpClientSystemNet    #1: RADIO RING IS RECEIVED FROM IP:63.45.161.30 Port:9034
  17:18:17  ListenerAchRadioRing  #2 RADIO RING IS DETECTED
  17:18:17  ConnectorWorkerThread Process Request: ReadSerialNumber
  17:18:18  ListenerAchRadioRing  #3 RADIO RING UNIT SERIAL NUMBER = UM12947
  17:18:18  ACHManager            #8 RADIO RING STARTED A NEW SESSION

TcpClientSystemNet is THOR's outbound TCP CLIENT -- the ring arrives on the
connection THOR itself opened to unit:9034, the ordinary call-UP path.  No
inbound connection, no dial, nothing to accept.  THOR keeps that connection alive
on purpose: UnitWatchDogTimer reconnects continuously, 1,039 log lines in 37
minutes.

THOR's OTHER ACH path was never used.  ListenerAchTcp logs "Waiting for a ACH
connection on Port 12346" and in 4,414 lines NEVER ACCEPTED ONE.  All twelve ACH
events came through ListenerAchRadioRing.

CONSEQUENCE: bridges/mm_ach_server.py is built on the wrong model for this
deployment.  It listens for an inbound connection -- ListenerAchTcp's model, the
one THOR never exercises here.  The right shape is a POLLER that holds an
outbound connection to each unit, watches the stream for RADIO RING, identifies
the unit, and runs a session on the same socket.

That also dissolves the single-session contention that dogged every experiment
today: the receiver must hold the modem's one session slot PERMANENTLY.  Our
probes and MITM attempts were not fighting a bug, they were fighting the design.

Also captured: the full ACH state machine (15 steps), the eight request types
with counts, and two corroborations -- StartMonitoringAfterCallhome matches the
firmware string found by static analysis in September, and ReadEventRecordCount
returning "Event count: 19" independently supports the SUB 0x06 event-count
finding.

Flagged, unexplained: events are addressed as 90000001 (length 4076) in THOR's
ACH path, where our chain walk returns 055d4a81 for an event of exactly that
length.  Same event, different address space.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ru8Lg9HkkYvX9VWWo65SmL
2026-10-14 17:55:50 -04:00
serversdownandClaude Opus 5 52d18b0d5d docs(series4): OBSERVED -- THOR's ACH side is POLL, byte-identical to ours
First capture of THOR's half of a Micromate call-home, taken with ach_mitm.py
between UM12947's modem and a THOR 1.5.0.29 ACH server on port 8070.

THOR sends POLL (SUB 0x5B, offset 0x0030) and NOTHING ELSE -- four times over
~21 s, then gives up.  No greeting, no answer to the RADIO RING, no CONNECT.

And that POLL is BYTE-IDENTICAL to what micromate.protocol builds:
build_request(SUB_POLL, 0x0030) reproduces all four frames exactly.

So the ACH session is PULL, and bridges/mm_ach_server.py already implements it
correctly.  The "inbound call-home session" -- carried for weeks as the last
protocol unknown -- was never a separate protocol at all.  It is the ordinary
command set on an inbound socket, exactly as series III's 72 captured sessions
suggested it would be.

THE OPEN PROBLEM IS NOW CLEARLY ELSEWHERE.  In the same capture the unit sent
only "RADIO RING", four times, and never a protocol frame.  THOR polled four
times and got nothing -- identically to our own server in three attempts the
same afternoon.  THE VENDOR'S OWN SOFTWARE FAILS THE SAME WAY WE DO, which
eliminates the receiver as a suspect and places the fault between modem and
unit.

Established: cellular healthy (151 ms connect, outbound dial works), bytes do
reach us from the unit's side, modem serial config matches spec (115200 8N1, no
flow control, PAD/TCP), cable is FTDI and cold-booted with it attached.  Not
established: whether the unit or the modem emits "RADIO RING" -- it is the
literal string in this unit's own 0x2C dial-string field, and the cheap
disambiguation is to disconnect the unit and see if it still appears.

Next step is a config diff against a working deployed unit's modem, not more
protocol work.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ru8Lg9HkkYvX9VWWo65SmL
2026-10-14 16:42:18 -04:00
serversdownandClaude Opus 5 fc0a7b2a88 chore: ignore capture artefacts beside the bridge scripts
A stale Windows checkout had ten March-era capture files staged as new and
deleted from the working tree -- .bin/.log/.set artefacts in bridges/ and
bridges/s3-bridge/ that .gitignore never covered, since it only had
/bridges/captures/.

Deliberately NOT ignoring /bridges/s3-bridge/ wholesale: proxy.py and
s3_bridge.py live there and are tracked.  Only the artefact extensions.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ru8Lg9HkkYvX9VWWo65SmL
2026-10-14 16:33:44 -04:00
serversdownandClaude Opus 5 3fa2a4035e fix(micromate): the ACH server now names modem chatter, and flushes its output
Three things the first real call-in exposed.  UM12947's modem dialled in at
14:16:56 from 63.45.161.30 -- the network path works -- and sent 60 bytes of
"RADIO RING", space-padded and newline-separated, four times.

1. THAT IS MODEM CHATTER, NOT THE UNIT, and the server left it as a hex dump to
   interpret by hand.  CLAUDE.md already records that an RV50/RV55 "sends
   \r\nRING\r\n\r\nCONNECT\r\n over TCP to the caller even with Quiet Mode
   enabled"; an RX55 on AirLink OS says RADIO RING instead.  The server now
   recognises the known modem strings and says so.

   ⚠ The diagnostic value is in what was MISSING: four RINGs and NO CONNECT.
   RING means the modem is ringing the serial device, CONNECT means something
   answered.  Rings without a connect, plus no answer to POLL, means TCP is fine
   and the unit is not on the other end of the serial link.  The server now
   prints that conclusion and the three things to check -- cabled at all, cable
   chipset (FTDI/CDC-ACM only, never Prolific), and a cold boot with the cable
   attached, since the USB-A host port only enumerates at power-on.

2. STDOUT WAS BLOCK-BUFFERED.  With output redirected, every print sat in a
   buffer, so the log read EMPTY while a call was in progress and the session was
   only discoverable on disk afterwards.  For a tool whose whole job is to be
   watched during a one-shot event, that is close to useless.  Line-buffered now.

3. THE DOCSTRING PROMISED SCANNERS LEAVE NO TRACE ON DISK, AND THEY DID.  The
   failed-handshake path created a session directory unconditionally -- my own
   loopback sanity check produced one.  Now a connection that sends nothing AND
   fails the handshake is discarded with no directory; one that sent something
   unprompted is always kept, because that is the interesting case.

Also recorded in session.json: modem_chatter, ring_count and a diagnosis string,
so a session can be triaged without re-reading the raw bytes.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ru8Lg9HkkYvX9VWWo65SmL
2026-10-14 14:21:42 -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 bdf4909d2a docs(series4): no Micromate has ever been observed calling home
Correcting an implication I made.  The 72 ach_inbound_* sessions in
bridges/captures/ are MiniMate Plus, and I framed the Series III ACH setup as
though it transfers to a Micromate.  It is not known to.

What we actually have for Series IV is prior, not observation:

- THOR manual 6.2 and the firmware's own strings
  (CMD_EXIT_CALL_HOME_DELETE_EVENTS_START_MONITORING, "Call Home Deleting
  Events") say the unit dials in and waits to be told what to do -- server-driven,
  the same shape as Series III's pull model.
- UM12947's 0x2C dial string reads literally "RADIO RING", which is modem ANSWER
  vocabulary rather than a destination.  With the RV50 debug string
  ATQ1 ATE0 ATS0=2 ... RADIO RING -- ATS0=2 being auto-answer-after-2-rings --
  that reads as the unit arranging to ACCEPT calls, i.e. the call-UP path.  Which
  argues the ACH destination lives in the modem, as it does for series III.

If both priors hold, mm_ach_server.py is just MicromateClient on an inbound
socket and the unknown evaporates.  But there is a specific failure mode worth
naming in advance:

THE MICROMATE DEMONSTRABLY TALKS AT TO ITS MODEM.  If it drives an AT dial for
call-home, that exchange happens on the SERIAL LINK and a TCP listener sees none
of it.  So the first experiment has an AMBIGUOUS NULL -- no connection could mean
the trigger did not fire, or that the interesting part is invisible from the
network.  The escalation is a serial-level capture between unit and modem, not
more fiddling with the server.

Recorded in both the protocol reference and the server's own docstring, so
whoever runs the experiment reads the caveat before being puzzled by a silence.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ru8Lg9HkkYvX9VWWo65SmL
2026-10-03 01:54:31 -04:00
serversdownandClaude Opus 5 4579896b6d feat(micromate): inbound ACH server -- and the push-vs-pull experiment
The inbound call-home session is the last unmapped part of the Series IV
protocol, and it may well not be a separate protocol at all.  Series III's
answer, from the 72 ach_inbound_* sessions on disk, is that the unit DIALS IN AND
THEN WAITS: ach_server.py accepts the socket, wraps it in SocketTransport ->
MiniMateClient, runs the ordinary handshake and drives with the ordinary command
set.  If Series IV behaves the same way, this file is just MicromateClient
attached to an inbound socket.

THE ONE QUESTION THAT MATTERS IS PUSH VS PULL, and no packet capture can answer
it -- you have to connect and keep quiet.  So the server says NOTHING for --grace
seconds after accepting.  Bytes in that window mean the unit speaks first, and it
reports the hex, the ASCII, and whether they parse as a response frame (series III
sends an "Operating System" banner on cold boot, so a banner is the likely shape).
Silence means pull, and the normal handshake follows.

READ-ONLY, and deliberately more so than its series III sibling: that one has
"rescue actions" that stop monitoring and disable ACH on a runaway unit, and
those are absent here.  No command has ever been originated against a unit by
this project, and an inbound session is the worst place to break that.  --depth
defaults to walking the event chain WITHOUT downloading.

Captures land as raw_bw_*/raw_s3_* so scratch/mm_frame_parse.py reads the pair
with no arguments, plus a session.json recording what was learned -- including
the push flag, which is the result worth keeping.  The session directory is
created only after the handshake succeeds, so a port scanner leaves nothing on
disk.

Smoke-tested both paths against a fake unit that dials in: PULL detected over
silence and driven to a full chain walk (33 frames, 0 bad checksums, parses with
the existing tool), and PUSH detected from a 10-byte banner with the frame-parse
attempt reported honestly as "none parsed".

Worth recording for the setup: for series III the call-home DESTINATION lived in
the MODEM's config (ACEmanager), not in the seismograph.  If that holds for the
RX55 then nothing on the instrument needs changing, which keeps the no-writes
line intact.  If it has to come from the unit, its 0x2C block holds a 40-byte
dial string -- and writing that is THOR's job, not ours.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ru8Lg9HkkYvX9VWWo65SmL
2026-10-03 01:25:53 -04:00
6 changed files with 874 additions and 44 deletions

No files matched your search

+40 -33
View File
@@ -1,33 +1,40 @@
/bridges/captures/
/example-events/
/tests/fixtures/
/manuals/
# Python build artifacts
*.egg-info/
dist/
build/
# Python bytecode
__pycache__/
*.py[cod]
# Virtual environments
.venv/
venv/
env/
# Editor / OS
.vscode/
*.swp
.DS_Store
Thumbs.db
# Analyzer outputs
*.report
claude_export_*.md
# Frame database
*.db
*.db-wal
*.db-shm
/bridges/captures/
# Capture artefacts that land beside the bridge scripts. Deliberately NOT
# `/bridges/s3-bridge/` -- proxy.py and s3_bridge.py live there and are tracked.
/bridges/*.bin
/bridges/s3-bridge/*.bin
/bridges/s3-bridge/*.log
/bridges/s3-bridge/*.set
/example-events/
/tests/fixtures/
/manuals/
# Python build artifacts
*.egg-info/
dist/
build/
# Python bytecode
__pycache__/
*.py[cod]
# Virtual environments
.venv/
venv/
env/
# Editor / OS
.vscode/
*.swp
.DS_Store
Thumbs.db
# Analyzer outputs
*.report
claude_export_*.md
# Frame database
*.db
*.db-wal
*.db-shm
+75
View File
@@ -54,6 +54,23 @@ All notable changes to seismo-relay are documented here.
passed. Pinned to `THOR_CHUNK_SIZE`, the only size with THOR's captures behind
it.
- **`mm_client_check.py` reported THOR's request count, not its own.** It printed
"71 chunks" for a download that made **5 requests**, computing `size / 1024`
while the download used the 16 KB default — nearly reading 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.
- **The ACH server buffered its own output and mislabelled modem chatter.**
stdout was block-buffered, so the log read **empty** while a call was in
progress — useless for a tool whose job is being watched during a one-shot
event. It also left `RADIO RING` as a hex dump; it now names known modem
strings and, on rings without a `CONNECT`, says what to check. And its
docstring promised scanners leave no trace on disk while the failure path
created a session directory regardless.
- **`.gitignore` missed capture artefacts beside the bridge scripts.** Targets
`*.bin`/`*.log`/`*.set` specifically — **not** `/bridges/s3-bridge/`, which
holds tracked source.
### Added
- **Diagnostics tab in the SFM standalone webapp.** Surfaces the device
@@ -178,6 +195,15 @@ All notable changes to seismo-relay are documented here.
caller ask "is there anything here?" in one command. `content[4:8]` reads **9**
on both units regardless of count, so it is a constant, not a count.
- **`bridges/mm_ach_server.py` — an inbound Auto Call Home receiver.** Read-only,
and deliberately more so than its Series III sibling, which has rescue actions
that stop monitoring and disable ACH. Its grace window is the experiment: it
stays **silent** after accepting, to answer the one question no packet capture
can — does the unit speak first? Captures land as `raw_bw_*`/`raw_s3_*` so
`scratch/mm_frame_parse.py` reads the pair unchanged.
⚠ Implements the **listener** path only. See *Changed* — there are two.
### Changed
- **Connecting to a unit no longer walks its event chain.** `/device/events`
@@ -305,6 +331,46 @@ All notable changes to seismo-relay are documented here.
deduplicates must key on `(serial, event_key)`; `MicromateEventRef.uid` is that
pair.
- **🔑 The Series-4 call-home session is captured end to end.** A MITM between a
unit's modem and THOR 1.5.0.29: **101 request frames, 101 responses, 0 bad
checksums, 34,872 B of event data in 65 s.** **Every command in a real ACH
session is one `micromate/protocol.py` already implements** — `POLL`×36,
`BULK_DOWNLOAD`×27, `STATE`×10, `EVENT_RECORD`×8, `EVENT_NEXT`×7,
`STORAGE_RANGE`×4, `MONITOR_STATUS`×3, `ARM_EVENT`×3, `SERIAL`, `EVENT_FIRST`
— bar one. **The last protocol unknown is closed.**
- **🔑 Call-home has TWO paths, and timing decides which runs.** If anything
already holds the modem's single TCP session, the unit's `RADIO RING` travels
**up that existing connection**; if nothing is connected, the modem **dials
out** to a listener. THOR's `UnitWatchDogTimer` reconnects continuously, so
THOR usually holds that slot — which is why probes and relays see "connected,
no reply". **That is contention, not a fault**, and it accounted for a full
afternoon of apparent failures.
- **⚠⚠ `SUB 0xA2` ends a call-home on Series IV — and is CONFIRM ERASE on
Series III.** Same opcode, same `0x5D` response, opposite consequence: on a
MiniMate Plus it is the final step of the erase-all sequence. `minimateplus`
and `micromate` already share a transport, so **any shared path must dispatch
on series before that byte reaches a wire.** Corroborates the firmware string
`CMD_EXIT_CALL_HOME_DELETE_EVENTS_START_MONITORING` found by static analysis.
- **⚠ "Monitor While Calling Home" silently blocks erase, and THOR reports the
session successful anyway.** Both refusals are INFO lines. Delete-after-
download is the necessary fleet setting; a unit left on monitor-while-calling
accumulates events forever while looking healthy.
**Consequence: a receiver cannot rely on erase to manage storage** — the
server-side high-water mark is load-bearing, not an optimisation. Detectable
on any call from `0x06`'s event count plus `0x1C`'s memory fields.
- **⚠ Corrected: `0x06` content[4:8] is the monitor-log count, not a constant.**
Recorded in this file as "9 on both units regardless". It reads 47 against
THOR's `Monitor Log count: 45` twelve minutes earlier on the same unit; both
units simply held 9 records.
- **⚠ Corrected: `SUB 0x49` has a third state.** `0x00` idle, `0x02` monitoring,
and **`0x03` in-call-home** — ten for ten through a session. Exactly why the
rule is *test for non-zero*: `== 0x02` calls a unit mid-call-home idle.
- **THOR rewrites a unit's stored IP from the call-home source address**, so a
relay silently poisons its record of where that unit lives.
- **`CLAUDE.md`'s "Where things stand" refreshed** — it still claimed `micromate/`
had no live client, and that the call-home was the only protocol unknown.
### Migration
**None.** No codec change, no waveform-store change, no DB or schema change,
@@ -323,6 +389,15 @@ and nothing imports them yet, so an existing deployment behaves identically.
only callers are the new client and the bench tooling. Nothing in `sfm/` or the
ingest path is affected.
⚠ Likewise `bridges/mm_ach_server.py` and the bench tooling have **no shipped
caller**, and `micromate/client.py` gained only a ring-answering branch inside
that ACH path. Nothing under `sfm/` or `minimateplus/` changed.
⚠ **The `SUB 0xA2` collision above is documentation, not a fix.** `minimateplus`
can already send `0xA2` as the last step of its erase sequence; nothing yet
prevents a future shared path from confusing the two meanings. A guard is
outstanding.
---
## v0.31.0 — 2026-09-18
+31 -6
View File
@@ -10,7 +10,7 @@ pair — lives in `../terra-view/docs/tmi-stack.md`, which is also loaded as
---
## Where things stand (updated 2026-09-26)
## Where things stand (updated 2026-10-14)
Read this first when picking the project back up.
@@ -22,14 +22,39 @@ Read this first when picking the project back up.
firmware) or `0x03` (Thor firmware) rather than `0x10`, and the data length
is a **uint16 BE at `payload[8:10]`** (as a byte it under-reads `SUB 0x1A`
by 47x). Read path, event chain, setups, scheduler, monitoring control and
per-event delete are all mapped; **the inbound call-home session is the only
protocol unknown left.**
per-event delete are all mapped — **and as of 2026-10-14 so is the inbound
call-home session.** There are no protocol unknowns left.
⚠ **No command has ever been originated against a unit by this project.**
Every write was performed by THOR while we recorded. That line is worth
keeping.
⚠ `micromate/` still has **no live client** — it is codec-only. The
`minimateplus/` stack (transport/framing/protocol/client) has no Series-4
counterpart yet. `minimateplus.transport` is protocol-agnostic and reusable.
- **✅ `micromate/` HAS a live client (2026-10-02).** `framing.py`,
`protocol.py`, `client.py` + models, **119 tests**, mirroring the
`minimateplus/` stack and reusing its `transport.py` unchanged. Connect over
TCP or serial, identify a unit, read state/clock/battery/memory, list setups,
walk the event chain and download + decode events. **Read-only** — every
write remains mapped-but-unimplemented, deliberately.
Verified on hardware across **both firmware lines** (UM12947 `11.0CB`,
UM20147 `11.0BD`) and **both transports** (USB CDC-ACM and an RX55 over
cellular), byte-identical.
⚠ **The gap is config decoding**, not the protocol: `0x1A` (2,103 B) has
about a dozen fields read; `0x2C`, `0x2E`, `0x08`, `0x01` are fetched and
undecoded. Finishing it needs a bench session varying one setting at a time,
as was done for Series III — not desk work.
- **🔑 ACH / call-home, captured end to end (2026-10-14).** A Micromate signals
`RADIO RING`; **two paths exist and timing decides which**: if anything
already holds the modem's single TCP session the ring rides that connection,
otherwise the modem dials out to a listener. THOR's `UnitWatchDogTimer`
reconnects continuously, so THOR usually holds that slot — which is why
probes and relays see silence. That is contention, not a fault.
⚠⚠ **`SUB 0xA2` ends a call-home on Series IV and is CONFIRM ERASE on
Series III** — same opcode, same `0x5D` response, opposite consequence.
`minimateplus` and `micromate` share a transport; dispatch on series before
that byte reaches a wire.
⚠ **"Monitor While Calling Home" silently blocks erase**, and THOR reports
the session successful anyway. A receiver therefore **cannot rely on erase to
manage storage** — the server-side high-water mark is load-bearing.
⚠ `bridges/mm_ach_server.py` implements the listener path only; it needs to
also hold outbound connections and watch for the ring.
- **Bench tooling for device diagnosis (2026-09-25).** `bridges/mm_probe.py`
distinguishes the four faults THOR reports identically as "disconnected"
(refused / connect timeout / **connected but no reply** / replied) and names
+398
View File
@@ -0,0 +1,398 @@
#!/usr/bin/env python3
"""
mm_ach_server.py — inbound Auto Call Home server for Micromate (Series IV).
**Read-only.** It identifies the unit, reads its state and setups, and walks the
event chain. It does not erase, does not write, does not start or stop
monitoring, and downloads nothing unless asked. Series III's `ach_server.py`
has "rescue actions" that quiet a runaway unit; those are deliberately absent
here, because no command has ever been originated against a unit by this project
and an inbound session is the worst place to break that.
What this is for
----------------
The inbound call-home session is the last unmapped part of the Series IV
protocol.
⚠ **No Micromate has ever been observed calling home.** The 72 `ach_inbound_*`
sessions in `bridges/captures/` are **MiniMate Plus**, and the Series III setup
does not automatically transfer. What we have for Series IV is prior, not
observation:
* The THOR manual §6.2 and the firmware's own strings
(`CMD_EXIT_CALL_HOME_DELETE_EVENTS_START_MONITORING`, `Call Home Deleting
Events`) say the unit dials in and then **waits to be told what to do** —
server-driven, the same shape as Series III's pull model.
* UM12947's `0x2C` dial string reads literally `"RADIO RING"`, which is modem
*answer* vocabulary rather than a destination. With the RV50 debug string
`ATQ1 ATE0 ATS0=2 … RADIO RING` — `ATS0=2` being auto-answer-after-2-rings —
that reads as the unit configuring the modem to **accept** calls, i.e. the
call-*up* path. Which suggests the ACH destination lives in the **modem**,
as it does for Series III.
**If both priors hold, this file is just `MicromateClient` on an inbound socket
and the unknown evaporates.** But there is a specific way it can fail:
⚠ **Those AT strings prove the Micromate talks to the modem over serial.** If it
drives an AT dial for call-home, that exchange happens on the **serial link**,
where a TCP listener sees nothing whatsoever. So a null result here is
informative but ambiguous — it means *either* the trigger did not fire *or* the
interesting part is happening somewhere this tool cannot watch. **If nothing
arrives, the next step is a serial-level capture between the unit and the modem,
not more fiddling with this server.**
**The one question that matters is push vs pull**, and it cannot be answered by
sniffing — only by connecting and keeping quiet. So this server **says nothing
for `--grace` seconds** after accepting. If bytes arrive in that window the unit
speaks first (push) and the server reports exactly what it sent. If the window
passes in silence, it is pull, and the normal handshake follows.
Setup
-----
1. Run this where the unit can reach it:
python3 bridges/mm_ach_server.py --port 12345
2. Point the call-home destination at this machine. **For Series III that
lived in the MODEM's config (ACEmanager), not in the seismograph** — so try
AirLink OS first. If the RX55 can be told to open an outbound TCP session
to `<your IP>:12345` on serial activity, nothing on the instrument needs to
change, which is much the better outcome.
If it has to come from the unit instead, its `SUB 0x2C` call-home block
holds a 40-byte dial string — but **writing that is THOR's job, not ours.**
3. Trigger a call. A scheduled time is the controllable option: repeatable,
needs no monitoring and no thumping. An event-triggered call is the more
interesting session, because it shows how an event gets offered.
4. Watch. Every frame is decoded as it arrives.
⚠ Use a bench unit. Changing a call-home destination means a unit stops
reporting to THOR until it is changed back.
Output per session, in the layout `scratch/mm_frame_parse.py` reads directly:
bridges/captures/mm_ach_<ts>/
raw_bw_<ts>.bin us → unit
raw_s3_<ts>.bin unit → us
session_<ts>.log
session.json what we learned, including push-vs-pull
"""
from __future__ import annotations
import argparse
import datetime
import json
import logging
import socket
import sys
import threading
import time
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
from micromate.client import MicromateClient # noqa: E402
from micromate.framing import MicromateFrameParser # noqa: E402
from micromate.protocol import ProtocolError # noqa: E402
from minimateplus.transport import SocketTransport # noqa: E402
log = logging.getLogger("mm_ach")
DEPTHS = ("identify", "state", "events", "download")
# Strings the MODEM puts on the wire, which are not the unit talking.
#
# `CLAUDE.md` already records that an RV50/RV55 "sends \r\nRING\r\n\r\nCONNECT\r\n
# over TCP to the caller even with Quiet Mode enabled". An RX55 on AirLink OS
# says `RADIO RING` instead, space-padded and newline-separated. Observed
# 2026-10-14 from UM12947's modem: four of them and **no CONNECT**.
#
# ⚠ The absence of CONNECT is the useful part. RING means the modem is ringing
# the serial device; CONNECT means something answered. Rings without a CONNECT,
# and no answer to POLL, means the TCP side is fine and the UNIT is not on the
# other end of the serial link.
_MODEM_CHATTER = (b"RADIO RING", b"RING", b"CONNECT", b"NO CARRIER", b"BUSY",
b"NO ANSWER", b"ERROR", b"OK")
class Session:
"""One inbound call. Captures every byte; decides push vs pull first."""
def __init__(self, sock: socket.socket, peer: str, args) -> None:
self.sock, self.peer, self.args = sock, peer, args
self.ts = datetime.datetime.now().strftime("%Y%m%d_%H%M%S")
self.found: dict = {"peer": peer, "started": self.ts}
self._rx: list[bytes] = []
self._tx: list[bytes] = []
self._rx_fh = self._tx_fh = None
# ── byte taps ─────────────────────────────────────────────────────────────
def _tap(self, transport) -> None:
"""Mirror every byte, buffered until we know this is a real unit."""
orig_read, orig_write = transport.read, transport.write
def read(n: int) -> bytes:
data = orig_read(n)
if data:
(self._rx_fh.write(data), self._rx_fh.flush()) if self._rx_fh \
else self._rx.append(data)
return data
def write(data: bytes) -> None:
orig_write(data)
if data:
(self._tx_fh.write(data), self._tx_fh.flush()) if self._tx_fh \
else self._tx.append(data)
transport.read, transport.write = read, write
def _open_capture(self) -> Path:
"""Create the session directory — only once we trust the peer.
A port scanner should leave nothing on disk.
"""
d = Path(self.args.output) / f"mm_ach_{self.ts}"
d.mkdir(parents=True, exist_ok=True)
# Named raw_bw/raw_s3 so scratch/mm_frame_parse.py reads the pair as-is.
self._tx_fh = open(d / f"raw_bw_{self.ts}.bin", "wb")
self._rx_fh = open(d / f"raw_s3_{self.ts}.bin", "wb")
for c in self._tx:
self._tx_fh.write(c)
for c in self._rx:
self._rx_fh.write(c)
self._tx_fh.flush()
self._rx_fh.flush()
self._tx.clear()
self._rx.clear()
return d
# ── the experiment ────────────────────────────────────────────────────────
def _listen_first(self, transport) -> bytes:
"""Say nothing for `--grace` seconds — unless a RING arrives.
Originally this just answered "does the unit speak first?". THOR's ACH
log (2026-10-14) made the question sharper: on seeing `RADIO RING` it
replies in **36 ms**, and with `ReadSerialNumber`, not `POLL`.
We were doing neither — sitting silent for the full 8 s and then sending
POLL. The unit may well have given up long before we spoke. So the
grace window now **ends the moment a ring is seen**, and the caller
answers it the way THOR does.
"""
print(f" listening in silence for up to {self.args.grace:.1f} s "
f"(ends early on a RING)...")
deadline = time.monotonic() + self.args.grace
got = bytearray()
while time.monotonic() < deadline:
chunk = transport.read(4096)
if chunk:
got += chunk
if b"RING" in got:
print(f" RING seen after "
f"{self.args.grace - (deadline - time.monotonic()):.2f} s"
f" — answering immediately, as THOR does")
return bytes(got)
else:
time.sleep(0.02)
return bytes(got)
def run(self) -> None:
print(f"\n=== inbound from {self.peer} at {self.ts} ===")
transport = SocketTransport(self.sock, peer=self.peer)
self._tap(transport)
unsolicited = self._listen_first(transport)
self.found["push"] = bool(unsolicited)
self.found["unsolicited_bytes"] = len(unsolicited)
if unsolicited:
print(f" ** PUSH ** — the unit sent {len(unsolicited)} B unprompted")
print(f" hex : {unsolicited[:64].hex(' ')}")
txt = "".join(chr(c) if 32 <= c < 127 else "." for c in unsolicited[:64])
print(f" ascii : |{txt}|")
hits = [c.decode() for c in _MODEM_CHATTER if c in unsolicited]
if hits:
rings = unsolicited.count(b"RING")
print(f" *** MODEM CHATTER, not the unit: {hits} ***")
self.found["modem_chatter"] = hits
self.found["ring_count"] = rings
if rings and b"CONNECT" not in unsolicited:
print(f" *** {rings} RING(s) and NO CONNECT. ***")
print(" The modem is ringing the serial device and nothing")
print(" is answering. TCP is fine; the UNIT is not on the")
print(" other end of the serial link. Check, in order:")
print(" 1. is the unit cabled to the modem at all?")
print(" 2. cable chipset -- FTDI (0403) or CDC-ACM only,")
print(" never Prolific (067b)")
print(" 3. cold-boot the unit WITH the cable attached;")
print(" its USB-A host port only enumerates at power-on")
self.found["diagnosis"] = "rings without connect: unit not on serial"
frames = MicromateFrameParser().feed(unsolicited)
if frames:
for f in frames:
print(f" frame : SUB=0x{f.sub:02x} "
f"(answers 0x{f.request_sub:02x}) {len(f.data)} B data, "
f"flags=0x{f.flags:02x}, chk "
f"{'ok' if f.checksum_valid else 'BAD'}")
self.found["unsolicited_subs"] = [f"0x{f.sub:02x}" for f in frames]
else:
print(" frame : none parsed — not a response frame. Could be")
print(" a banner (series III sends 'Operating System'")
print(" on cold boot) or a greeting we have not seen.")
else:
print(" ** PULL ** — silence. The unit is waiting to be driven,")
print(" same as series III. Running the normal handshake.")
# From here on it is the ordinary client, which is the point.
mm = MicromateClient(transport, recv_timeout=self.args.timeout)
try:
if b"RING" in unsolicited:
# ⚠ Answer a ring the way THOR does: SERIAL first, not POLL.
# THOR's ACH log shows ReadSerialNumber 36 ms after detecting the
# ring -- it is identifying which unit rang before doing anything
# else. Our POLL-after-8-seconds may simply have been too late
# and the wrong question.
print(" answering the ring with SERIAL (THOR's first move)...")
serial = _cstring(_content(mm.protocol.read_serial()))
print(f" *** THE UNIT ANSWERED: {serial} ***")
self.found["answered_ring"] = True
self.found["ring_serial"] = serial
info = mm.connect()
except ProtocolError as e:
print(f" handshake FAILED: {type(e).__name__}: {e}")
if not unsolicited:
print(" Nothing unprompted AND no answer to POLL — so this is")
print(" neither push nor pull as we understand it. The raw")
print(" capture is the thing to look at; keep it.")
self._finish(self._open_capture())
return
d = self._open_capture()
print(f" {info}")
self.found["device"] = {
"serial": info.serial, "model": info.model,
"firmware_line": info.firmware_line, "monitoring": info.monitoring,
"active_setup": info.active_setup,
}
try:
if DEPTHS.index(self.args.depth) >= DEPTHS.index("state"):
st = mm.get_state()
print(f" {st}")
self.found["state"] = {
"monitoring": st.monitoring,
"device_time": st.device_time.isoformat() if st.device_time else None,
"battery_volts": st.battery_volts,
"memory_free_bytes": st.memory_free_bytes,
}
self.found["setups"] = mm.list_setups()
print(f" {len(self.found['setups'])} setups")
if DEPTHS.index(self.args.depth) >= DEPTHS.index("events"):
refs = mm.list_events()
print(f" {len(refs)} events")
self.found["events"] = []
for r in refs:
print(f" {r}")
self.found["events"].append({
"uid": r.uid, "key": r.key_hex, "size": r.size,
"type": r.record_type, "filename": r.filename,
"timestamp": r.timestamp.isoformat() if r.timestamp else None,
"pvs_ips": r.peak_vector_sum_ips,
})
if self.args.depth == "download":
# Bounded on purpose: an unknown session is a poor place to
# discover that a 70 KB pull takes 30 s and the unit hung up.
for r in refs[: self.args.max_events]:
blob = mm.download_event(r)
out = d / (r.filename or f"{r.key_hex}.bin")
out.write_bytes(blob)
print(f" saved {out.name} ({len(blob)} B)")
except ProtocolError as e:
print(f" session ended early: {type(e).__name__}: {e}")
self.found["error"] = f"{type(e).__name__}: {e}"
self._finish(d)
def _finish(self, d: Path) -> None:
for fh in (self._rx_fh, self._tx_fh):
if fh:
fh.close()
(d / "session.json").write_text(json.dumps(self.found, indent=2))
try:
self.sock.close()
except OSError:
pass
print(f" saved {d}")
print(f" parse with: python3 scratch/mm_frame_parse.py {d}")
def main() -> int:
ap = argparse.ArgumentParser(
description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter
)
ap.add_argument("--port", type=int, default=12345)
ap.add_argument("--bind", default="0.0.0.0")
ap.add_argument("--output", default="bridges/captures")
ap.add_argument("--timeout", type=float, default=30.0,
help="per-command receive timeout; generous, because an "
"inbound cellular session is the slow case")
ap.add_argument("--grace", type=float, default=5.0,
help="seconds to stay SILENT after accepting, to see whether "
"the unit speaks first. This is the experiment; do not "
"set it to 0 on a first run.")
ap.add_argument("--depth", choices=DEPTHS, default="events",
help="how far to take the session. 'events' walks the chain "
"without downloading (default); 'download' also fetches "
"events, which on cellular is ~0.21 s + bytes/2350 each")
ap.add_argument("--max-events", type=int, default=3,
help="with --depth download, how many to fetch")
ap.add_argument("--once", action="store_true",
help="exit after the first session instead of listening on")
a = ap.parse_args()
# ⚠ Without this, stdout is block-buffered whenever it is not a terminal,
# so the live session commentary sits in a buffer and the log looks EMPTY
# while a call is happening. That cost a confusing few minutes on the first
# real call-in: the session was on disk but nothing was on screen.
try:
sys.stdout.reconfigure(line_buffering=True)
except AttributeError: # pragma: no cover - py<3.7
pass
logging.basicConfig(level=logging.INFO,
format="%(asctime)s %(levelname)-7s %(message)s")
srv = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
srv.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
srv.bind((a.bind, a.port))
srv.listen(5)
print(f"\nMicromate ACH server on {a.bind}:{a.port} (READ-ONLY)")
print(f" depth={a.depth} grace={a.grace}s timeout={a.timeout}s")
print(" waiting for a unit to call in. Ctrl-C to stop.\n")
try:
while True:
sock, addr = srv.accept()
peer = f"{addr[0]}:{addr[1]}"
s = Session(sock, peer, a)
if a.once:
s.run()
return 0
threading.Thread(target=s.run, daemon=False).start()
except KeyboardInterrupt:
print("\nstopped")
return 0
finally:
srv.close()
if __name__ == "__main__":
raise SystemExit(main())
+11 -4
View File
@@ -55,7 +55,7 @@ from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
from micromate.client import MicromateClient, _content # noqa: E402
from micromate.protocol import ProtocolError # noqa: E402
from micromate.protocol import CHUNK_SIZE, ProtocolError # noqa: E402
from minimateplus.transport import TcpTransport # noqa: E402
@@ -380,7 +380,14 @@ def main() -> int:
for ref in mm.iter_events():
if ref.key_hex not in want_keys:
continue
n_chunks = -(-ref.size // 1024)
# ⚠ Use the size actually requested. This printed
# `size // 1024` -- THOR's chunk size -- while the
# download used the 16 KB default, so it reported 71
# requests for a walk that made 5. A diagnostic that
# misreports what it did is worse than one that says
# nothing, and this one nearly had me reading a working
# 16 KB download as a broken 1 KB one.
n_chunks = -(-ref.size // CHUNK_SIZE)
note = (" <- past 64 KB, carries into params[1]"
if ref.size > 0x10000 else "")
t1 = time.monotonic()
@@ -396,8 +403,8 @@ def main() -> int:
check = ("PVS %+.4f%%" % (100 * err) if err is not None
else "PVS n/a (histogram)")
print(f" {ref.key_hex} {ref.record_type:9} "
f"{ref.size:7} B {n_chunks:3} chunks {dt:5.1f} s "
f"{n:6} samples {check}{note}")
f"{ref.size:7} B {n_chunks:3} req @ {CHUNK_SIZE} B "
f"{dt:5.1f} s {n:6} samples {check}{note}")
except ProtocolError as e:
print(f"\n ABORTED {type(e).__name__}: {e}")
+319 -1
View File
@@ -1662,6 +1662,28 @@ through a record-type discriminator (`0x2C` partial vs `0x46` full) *on its
event walk*, so partial records and events share one chain. Here the monitor
log has its own cursor and the event chain never sees it.
### USB identification — the Micromate's own ports
| device | VID:PID | appears as |
|---|---|---|
| **Micromate `PC` port (USB-B)** | **`2504:0300`** — *Instantel Inc. MICROMATE COM PORT* | `/dev/ttyACM*`, CDC-ACM |
| Sabrent cable (works on the USB-A host port) | `0403:*` — FTDI | `/dev/ttyUSB*` |
| Benfei cable (does **not** work) | `067b:*` — Prolific PL2303 | `/dev/ttyUSB*` |
⚠ **Address the unit by `/dev/serial/by-id/`, not `/dev/ttyACM<n>`.** The number
shifts whenever any other CDC-ACM device is plugged in, and this has already cost
a debugging session — the tool was aimed at a TMI-Seismo MCU and timed out
looking like a dead unit. The stable name is
`usb-Instantel_Inc._MICROMATE_COM_PORT_V1.00-if00`.
The `PC` port is a USB **device** port, so it is safe to plug and unplug freely.
The cold-boot requirement applies only to the USB-A **host** port, where the
modem cable goes.
**Passing one through to a Proxmox guest** works and hot-plugs, no VM restart:
`qm set <vmid> -usb0 host=2504:0300`. Bind by VID:PID rather than bus-port so it
survives a replug.
#### 🔑 Every response has an 11-byte prefix — and its length byte lies
**Content starts at `data[11]`.** One rule, every command.
@@ -2256,12 +2278,308 @@ A server that never issues the delete simply re-reads the same events forever.
`ach_state.json` with `downloaded_keys` / `max_downloaded_key`, and erase as a
separate deliberate step. No new mechanism is needed for Series IV.
> #### ⚠ But no Micromate has ever been observed calling home (noted 2026-10-03)
>
> The 72 `ach_inbound_*` sessions in `bridges/captures/` are **MiniMate Plus**.
> The Series III setup is not known to transfer, and there is a concrete reason
> it might not:
>
> | | Series III (observed, 72 sessions) | Series IV (inferred) |
> |---|---|---|
> | who dials | the **modem** (destination set in ACEmanager) | unknown |
> | the unit's role | passive on serial until the socket exists | sends AT strings to the modem |
> | session | pull — server runs the ordinary command set | pull, per manual §6.2 + firmware strings |
>
> ⚠ **The Micromate demonstrably talks AT to its modem** —
> `ATQ1 ATE0 ATS0=2 … RADIO RING` from the RV50 debug, and `"RADIO RING"` is what
> `0x2C`'s dial-string field actually contains on UM12947. `ATS0=2` is
> auto-answer-after-2-rings, so that exchange is the unit arranging to *accept*
> calls — the call-*up* path — which argues the ACH destination lives in the
> modem after all.
>
> **But if the unit instead drives an AT dial for call-home, that exchange is on
> the serial link and a TCP listener sees none of it.** So the first experiment
> has an ambiguous null: no connection could mean the trigger did not fire, or
> that the interesting part is invisible from the network. The escalation is a
> **serial-level capture between unit and modem**, not more work on the server.
So a homebrew receiver needs: accept the connection, identify the unit, walk the
events (already solved — `0x08`/`0x1E`/`0x0A`/`0x5A`), keep our own high-water
mark, and *optionally* erase. **The erase opcodes are the only genuinely missing
piece**, and they remain on the unsafe list.
### The session is server-driven
### 🔑🔑 CAPTURED 2026-10-14 — a complete, working ACH session
MITM between UM12947's modem and THOR 1.5.0.29. **101 request frames, 101
responses, 0 bad checksums, 34,872 B of event data in 65 seconds.**
`bridges/captures/mitm-october/ach_mitm_20261014_182612/`
🔑 **Every command in a real ACH session is one we already implement — except
one.**
| SUB | name | count |
|---|---|---|
| `0x5B` | POLL | 36 |
| `0x5A` | BULK_DOWNLOAD | 27 |
| `0x49` | STATE | 10 |
| `0x0C` | EVENT_RECORD | 8 |
| `0x1F` | EVENT_NEXT | 7 |
| `0x06` | STORAGE_RANGE | 4 |
| `0x1C` | MONITOR_STATUS | 3 |
| `0x93` | ARM_EVENT | 3 |
| `0x15` | SERIAL | 1 |
| `0x1E` | EVENT_FIRST | 1 |
| **`0xA2`** | **see below** | **1** |
Session shape — note THOR polls between *every* command:
```
POLL POLL SERIAL POLL STORAGE_RANGE POLL MONITOR_STATUS POLL STATE POLL
ARM_EVENT EVENT_FIRST POLL EVENT_RECORD POLL STATE POLL
[ EVENT_NEXT POLL EVENT_RECORD POLL STATE POLL BULK_DOWNLOAD... ] x n
POLL STORAGE_RANGE POLL STATE POLL 0xA2
```
#### ⚠⚠ `SUB 0xA2` ends a call-home — and COLLIDES with Series III's ERASE
The session's final command is `0xA2` at `offset = 0xFFFF`, answered `0x5D`.
THOR's log at that instant:
```
TX: SENT REQUEST: StartMonitoringAfterCallhome
WARN Switching unit back to monitoring; IP: 63.45.161.30
SESSION COMPLETED SECCESSFULLY
```
So on Series IV, **`0xA2` = exit call-home and resume monitoring.**
⚠⚠ **On Series III, `0xA2` → `0x5D` is CONFIRM ERASE** — the last step of
`0xA3 → 0x1C → 0x06 → 0xA2`, after which the unit's memory is cleared.
**Same opcode, same response SUB, opposite consequence.**
That is the most dangerous collision found in this protocol. Any code path shared
between the two families — and `minimateplus` and `micromate` already share a
transport — must dispatch on series *before* `0xA2` goes near a wire. Sending it
to a MiniMate Plus to "end a session" erases it.
It also corroborates the firmware string found by static analysis in September:
`CMD_EXIT_CALL_HOME_DELETE_EVENTS_START_MONITORING`.
#### ⚠ "Monitor While Calling Home" silently blocks erase — and that fills units
Manual §11.4.4: a Micromate can call home **while it continues to monitor**, or
**pause monitoring** and send. UM12947 is on the former, which is why this
session logged:
```
CANNOT DOWNLOAD MONITOR LOG. The unit is monitoring.
CANNOT DELETE ALL EVENTS. The unit is monitoring.
```
⚠ **THOR reports the session as `SESSION COMPLETED SECCESSFULLY` anyway.** The
refusals are INFO lines. From the outside, a unit that is quietly accumulating
looks identical to one being managed correctly.
**TMI's normal fleet setting is delete-after-download**, and it is not optional:
without it a unit fills up and re-offers every event on every call. So a unit
left on *monitor while calling home* is misconfigured relative to the fleet, and
drifts toward a full buffer on its own.
🔑 **Design consequence for SFM: a receiver cannot rely on erase to manage
storage.** The erase can fail for a reason the unit considers normal, so the
**server-side high-water mark is load-bearing, not an optimisation** — it is the
only thing preventing a full re-download every session. Series III's
`ach_state.json` (`downloaded_keys` / `max_downloaded_key`) is the pattern; it
has to carry over deliberately.
🔑 **And it is a detectable fleet-health signal.** "Memory filling *and* deletes
refused" is visible on every call from `0x06`'s event count plus `0x1C`'s memory
fields — worth surfacing, precisely because THOR calls it success.
#### ⚠ Correction: `0x06` content[4:8] is NOT a constant
Recorded on 2026-10-01 as "**9** on both units regardless of count — a constant,
not a count". It reads **47** here, four times in one session, where THOR's log
twelve minutes earlier reported **`Monitor Log count: 45`** on the same unit.
It is almost certainly the **monitor-log record count**. Both units reading 9
earlier simply meant both held 9 monitor-log records. ⚠ Two samples and a
near-miss (47 vs 45, twelve minutes and an active monitoring session apart), so
treat as a strong candidate rather than settled.
`content[0:4]` remains the event count — **8** here, consistent.
#### ⚠ Correction: `SUB 0x49` has a third state value
Recorded as `0x00` idle / `0x02` monitoring. Throughout this ACH session it reads
**`0x03`**, ten times out of ten — so there is a distinct *in-call-home* state.
**This is exactly why the rule is "test for non-zero".** A client checking
`== 0x02` would report a unit mid-call-home as idle.
#### ⚠ THOR rewrites a unit's stored IP from the call-home source
After this session THOR showed UM12947's connection details as
`TCP: 127.0.0.1 - Port: 9034` — the address the MITM connected *from*. THOR
learns a unit's address from its inbound call, which makes sense for units on
dynamic IPs and means **a relay silently poisons THOR's record of where that unit
lives.**
### 🔑 Both ACH paths are real — and which one runs depends on timing
> #### ⚠ Softened 2026-10-14 — "mm_ach_server is built on the wrong model"
>
> An earlier entry concluded the inbound-listener model was wrong because
> `ListenerAchTcp` had never accepted a connection. It has now:
>
> | condition | path taken |
> |---|---|
> | THOR already holds a connection to the unit | `ListenerAchRadioRing` — the ring rides that connection |
> | nothing is connected | the modem **dials out**, `ListenerAchTcp` accepts |
>
> Both are real. The listener model is valid; it simply **loses whenever
> something already holds the modem's single session slot.** That also explains
> every failed probe and relay attempt of 2026-10-14: they were not bugs, they
> were contention with THOR's `UnitWatchDogTimer`, which reconnects continuously.
### 🔑 Call-home can also be an IN-BAND WAKE SIGNAL, not a dial-out
From THOR's own ACH log (1.5.0.29, 4,414 lines, UM12947 over an RX55). **This
overturns the model this document has carried since the beginning**, and it
explains every confusing result of the preceding weeks.
**A Micromate does not dial anybody.** It emits the ASCII string `RADIO RING`
over its serial port, and that text travels up a TCP connection **the server
already has open to the unit**. The server recognises it and starts a session
*on that same connection*.
```
17:18:17,268 TcpClientSystemNet #1: RADIO RING IS RECEIVED FROM IP:63.45.161.30 and Port:9034
17:18:17,268 ListenerAchRadioRing #2 RADIO RING IS DETECTED BY Serial ListenerAchRadioRing
17:18:17,304 ConnectorWorkerThread Process Request: ReadSerialNumber <- who is this?
17:18:18,489 ListenerAchRadioRing #3 RADIO RING UNIT SERIAL NUMBER = UM12947
17:18:18,490 ListenerAchRadioRing #4 NOTIFICATION IS SENT TO ACH MANAGER
17:18:18,499 ACHManager #8 RADIO RING STARTED A NEW SESSION
```
⚠ **`TcpClientSystemNet` is THOR's outbound TCP *client*.** The ring arrives on
the connection THOR itself opened to `unit:9034` — the ordinary call-*up* path.
There is no inbound connection, no dial, nothing to accept.
**THOR keeps that connection alive deliberately.** `UnitWatchDogTimer` reconnects
to every unit continuously — 1,039 lines of it in 37 minutes. The call-home
mechanism depends on that connection existing.
#### THOR has a second, unused ACH path
`ListenerAchTcp` logs `Waiting for a ACH connection on :: Port 12346` — and in
4,414 lines **it never accepted one**. All twelve ACH events came through
`ListenerAchRadioRing`. So the inbound-TCP ACH listener exists (presumably for
units that genuinely dial, on some other modem arrangement) but is not what a
PAD-connected Micromate uses.
#### What this means for a homebrew receiver
⚠ **`bridges/mm_ach_server.py` is built on the wrong model for this deployment.**
It listens for an inbound connection, which is `ListenerAchTcp`'s model — the one
THOR never exercises here. The right shape is:
1. **Hold an outbound connection to each unit** (`unit:9034`), reconnecting as
needed — this is a poller, not a listener
2. **Watch the byte stream for `RADIO RING`**
3. On seeing it, identify the unit (THOR sends `ReadSerialNumber`) and run an
ordinary session on the same socket
That also explains the single-session contention that dogged every experiment:
**the receiver must hold the modem's one session slot permanently**, so anything
else probing that unit will be met with silence. Those are not separate
problems; holding the slot *is* the design.
#### The ACH session, from THOR's state machine
```
InitializeState ReadEventRecordCount, ReadOperatingMode
CheckEventsCount
DownloadEventState ReadUnitACHStatus, ReadEventAddressFirst/Next,
SaveEventByAddress
DownloadMonitorLogState ReadMonitorLogRecordCount
DownloadScheduler
SetDateTimeState
DeleteEventState / DeleteAllEventsState / DeleteMonitorLogState
CheckEventWhileMonitoringBeforeEndingState / ...AfterDownloadingState
LoopState
EndWithSuccessState / EndWithCommunicationErrorState / EndState
```
Request counts over the log: `ReadUnitACHStatus` 53, `SaveEventByAddress` 47,
`ReadEventAddressNext` 43, `ReadOperatingMode` 10, `ReadEventRecordCount` 10,
`ReadEventAddressFirst` 4, `StartMonitoringAfterCallhome` 3,
`ReadMonitorLogRecordCount` 3.
`StartMonitoringAfterCallhome` matches the firmware string
`CMD_EXIT_CALL_HOME_DELETE_EVENTS_START_MONITORING` found by static analysis in
September — independent corroboration that the unit resumes monitoring when the
server finishes.
✅ **`ReadEventRecordCount` returned `Event count: 19`** — corroborating the
`SUB 0x06` event-count finding from a completely different direction.
⚠ Events are addressed as `90000001` here (`length: 4076`), where the chain walk
we implemented returns `055d4a81` for an event of exactly that length. Same
event, different address space — unexplained, and worth care before assuming our
keys and THOR's addresses are interchangeable.
### Superseded 2026-10-14 — "THOR's ACH side is POLL"
First capture of THOR's half of a Micromate call-home, via `ach_mitm.py` between
UM12947's modem and a THOR 1.5.0.29 ACH server on port 8070.
```
unit -> THOR 60 B " \nRADIO RING \nRADIO RING \nRADIO RING \nRADIO RING"
THOR -> unit 84 B 4 x 41 02 10 10 00 5b 00 00 30 00 00 00 00 00 00 00 00 00 00 9b 03
```
**THOR sends `POLL` (`SUB 0x5B`, offset `0x0030`) — and nothing else.** Four
times over ~21 seconds, then it gives up. It does **not** send a greeting, does
not answer the `RADIO RING`, does not send `CONNECT`, and does not wait to be
spoken to beyond its initial silence.
🔑 **That POLL is byte-identical to the one `micromate.protocol` builds.**
Verified: `build_request(SUB_POLL, 0x0030)` reproduces all four frames exactly.
**So the ACH session is pull, and our receiver already implements it correctly.**
`bridges/mm_ach_server.py` does what THOR does. The "inbound call-home session"
was never a separate protocol — it is the ordinary command set on an inbound
socket, exactly as Series III's 72 captured sessions suggested.
### ⚠ But the unit answered neither — and that is the open problem
In the same capture the unit sent **only** `RADIO RING`, four times, and never a
protocol frame. THOR polled four times and got nothing. Our own server, in three
earlier attempts the same afternoon, saw the identical thing.
**The vendor's own software fails the same way we do**, which eliminates the
receiver as a suspect and places the fault between the modem and the unit.
What is established about that fault:
| | |
|---|---|
| cellular link | ✅ healthy — TCP connect in 151 ms, outbound dial succeeds |
| modem → us | ✅ bytes arrive |
| unit serial TX | ✅ *something* reaches us — the `RADIO RING` text |
| unit protocol mode | ❌ never entered; no frame ever sent |
| cable | FTDI, physically checked, cold-booted with it attached |
| modem serial config | 115200 8N1, no flow control, PAD/TCP — matches spec |
⚠ `"RADIO RING"` is **the literal string in this unit's own `0x2C` call-home
config** (the 40-byte dial-string field). Whether the unit emits it or the modem
does is **not yet established** — the cheap disambiguation is to disconnect the
unit and see whether the string still appears.
**Next step is a config diff, not more protocol work.** The deployed fleet runs
call-home over PAD successfully, so a working unit's modem settings are the
reference. Compare them against this one.
Which matches the firmware's state machine and its
`CMD_EXIT_CALL_HOME_DELETE_EVENTS_START_MONITORING` /