Release v0.32.0 — event times you can trust, and Series 4 mapped #54
@@ -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