From 8f67608e0f05490e093acab5b5eef70dc4c4214a Mon Sep 17 00:00:00 2001 From: serversdown Date: Wed, 14 Oct 2026 18:12:14 -0400 Subject: [PATCH] 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 Claude-Session: https://claude.ai/code/session_01Ru8Lg9HkkYvX9VWWo65SmL --- bridges/mm_ach_server.py | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/bridges/mm_ach_server.py b/bridges/mm_ach_server.py index 098c536..fbeb691 100644 --- a/bridges/mm_ach_server.py +++ b/bridges/mm_ach_server.py @@ -173,19 +173,30 @@ class Session: # ── the experiment ──────────────────────────────────────────────────────── def _listen_first(self, transport) -> bytes: - """Say nothing for `--grace` seconds. Does the unit speak first? + """Say nothing for `--grace` seconds — unless a RING arrives. - This is the whole reason the server exists. A packet capture cannot - answer it: you have to connect, keep quiet, and see. + 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 {self.args.grace:.1f} s " - f"(push-vs-pull test)...") + 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) @@ -241,6 +252,17 @@ class Session: # 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}")