fix(sfm): wake a MiniMate before the read-back reconnect reads its serial (#9 review)

The reconnect in ce441a0 opened a fresh connection and sent a bare 0x15 (the
identity check) before any SESSION_RESET + POLL.  It exists for a unit that has
just started -- sensor check, then monitoring -- and a monitoring MiniMate
ignores a bare request until woken (measured 2026-04-08), so the identity read
would have timed out and the start reported unconfirmed anyway.  Now: open,
wake (the same retried wake the read-back uses), read the serial, read 0x1C --
the order the status read and the legacy write routes use.  Still one
reconnect, TCP only, nothing re-sent.

The fake gains bare_requests_ignored (off unless a test asks): a fresh
connection's reads time out, with the real client's TimeoutError, until woken.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
This commit is contained in:
serversdownandClaude Opus 5.5 committed 2026-10-29 23:56:44 -04:00
1 parent 1626e521ae
commit dbd8a91661
3 files changed
+41 -4

No files matched your search

+13
View File
@@ -816,6 +816,19 @@ def test_series3_start_read_back_reconnects_after_a_dropped_line():
assert fake.opened == 2 and "read_serial" in fake.calls
def test_series3_read_back_reconnect_wakes_the_unit_before_reading_it():
# The unit the reconnect is for has just started (sensor check, then
# monitoring), and a monitoring MiniMate ignores a bare request until it is
# woken -- so the fresh connection's identity read must come after the wake.
fake = FakeMiniMateClient(monitor_states=[False, True], bare_requests_ignored=True,
wake_errors=[BrokenPipeError(32, "Broken pipe")])
r = access3(fake).start_monitoring(TCP3, "BE18193")
assert (r.outcome, r.verified, r.state_after) == ("sent", "ok", "monitoring")
assert fake.writes == ["start_monitoring"] and fake.opened == 2
after = fake.calls[fake.calls.index("start_monitoring"):]
assert after.index("read_serial") > len(after) - 1 - after[::-1].index("wake")
def test_series3_read_back_reconnects_only_once():
fake = FakeMiniMateClient(monitor_states=[False],
wake_errors=[BrokenPipeError(32, "x"), BrokenPipeError(32, "x")])