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
This commit is contained in:
1 parent
90ac7ff76a
commit
8f67608e0f
1 file changed
+27
-5
@@ -173,19 +173,30 @@ class Session:
|
|||||||
# ── the experiment ────────────────────────────────────────────────────────
|
# ── the experiment ────────────────────────────────────────────────────────
|
||||||
|
|
||||||
def _listen_first(self, transport) -> bytes:
|
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
|
Originally this just answered "does the unit speak first?". THOR's ACH
|
||||||
answer it: you have to connect, keep quiet, and see.
|
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 "
|
print(f" listening in silence for up to {self.args.grace:.1f} s "
|
||||||
f"(push-vs-pull test)...")
|
f"(ends early on a RING)...")
|
||||||
deadline = time.monotonic() + self.args.grace
|
deadline = time.monotonic() + self.args.grace
|
||||||
got = bytearray()
|
got = bytearray()
|
||||||
while time.monotonic() < deadline:
|
while time.monotonic() < deadline:
|
||||||
chunk = transport.read(4096)
|
chunk = transport.read(4096)
|
||||||
if chunk:
|
if chunk:
|
||||||
got += 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:
|
else:
|
||||||
time.sleep(0.02)
|
time.sleep(0.02)
|
||||||
return bytes(got)
|
return bytes(got)
|
||||||
@@ -241,6 +252,17 @@ class Session:
|
|||||||
# From here on it is the ordinary client, which is the point.
|
# From here on it is the ordinary client, which is the point.
|
||||||
mm = MicromateClient(transport, recv_timeout=self.args.timeout)
|
mm = MicromateClient(transport, recv_timeout=self.args.timeout)
|
||||||
try:
|
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()
|
info = mm.connect()
|
||||||
except ProtocolError as e:
|
except ProtocolError as e:
|
||||||
print(f" handshake FAILED: {type(e).__name__}: {e}")
|
print(f" handshake FAILED: {type(e).__name__}: {e}")
|
||||||
|
|||||||
Reference in new issue
Block a user