diff --git a/bridges/mm_ach_server.py b/bridges/mm_ach_server.py index fa2593a..098c536 100644 --- a/bridges/mm_ach_server.py +++ b/bridges/mm_ach_server.py @@ -103,6 +103,20 @@ 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.""" @@ -190,6 +204,24 @@ class Session: 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: @@ -304,6 +336,15 @@ def main() -> int: 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")