Compare commits
13
Commits
263daa0f96
...
4c29820831
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4c29820831 | ||
|
|
8b48b3f42b | ||
|
|
9c8eb5c5b8 | ||
|
|
7645c91ae2 | ||
|
|
08d2d31a09 | ||
|
|
8f67608e0f | ||
|
|
90ac7ff76a | ||
|
|
52d18b0d5d | ||
|
|
fc0a7b2a88 | ||
|
|
3fa2a4035e | ||
|
|
67de2c18da | ||
|
|
bdf4909d2a | ||
|
|
4579896b6d |
No files matched your search
+40
-33
@@ -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
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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())
|
||||
@@ -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}")
|
||||
|
||||
@@ -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` /
|
||||
|
||||
Reference in new issue
Block a user