fix(device_access): a start's read-back waits out the sensor check, then wakes the MiniMate with retries
Second start through SFM, BE9441 2026-10-26 23:54:41: acked 0x69, and Brian saw 'starting, performing sensor check, recording' -- but the read-back's single SESSION_RESET + POLL went out 2.3 s after the ack, inside the ~30 s sensor check, and was never answered or re-sent (504 after 120 s, audit ca7b5b42). Brian: every unit is set to sensor-check before monitoring, ~30 s, then 'Recording...'. - MiniMateProtocol.wake(attempt_s, deadline_s): SESSION_RESET + POLL re-sent every attempt_s until the unit answers, then the POLL data step; a named timeout at the deadline. Reads only. MiniMateClient.wake() wraps it. - The Series-3 change: after a START, the first read waits S3_SENSOR_CHECK_S (30 s) before asking; every read then wakes with retries (every 5 s, up to 60 s). A stop is unchanged -- its read-back was confirmed three times tonight. Tests: a unit deaf for 4 probes is asked a 5th time and answers; a unit that never answers ends in the named timeout after ~6 probes; a start's first read waits the sensor check, a stop's does not; every read is preceded by a wake. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
This commit is contained in:
1 parent
9886422212
commit
ca5c401c6f
6 files changed
+166
-9
No files matched your search
@@ -289,6 +289,35 @@ class MiniMateProtocol:
|
||||
log.debug("read SUB=0x%02X: received %d data bytes", sub, len(data_rsp.data))
|
||||
return data_rsp.data
|
||||
|
||||
def wake(self, attempt_s: float = 5.0, deadline_s: float = 60.0) -> S3Frame:
|
||||
"""SESSION_RESET + POLL, re-sent every `attempt_s` until the unit answers.
|
||||
|
||||
A monitoring unit ignores everything until SESSION_RESET (2026-04-08), and
|
||||
right after a start it runs its sensor check (~30 s, Brian, 2026-10-26).
|
||||
BE9441 left a POLL sent 2 s after a start unanswered and never answered
|
||||
it later, so one try with a long wait is not enough: ask again until the
|
||||
unit answers or `deadline_s` passes. A read -- nothing but SESSION_RESET
|
||||
and POLL is sent. Returns the POLL data frame.
|
||||
"""
|
||||
deadline = time.monotonic() + deadline_s
|
||||
while True:
|
||||
self._parser.reset()
|
||||
self._send(SESSION_RESET)
|
||||
self._send(POLL_PROBE)
|
||||
try:
|
||||
self._recv_one(expected_sub=_expected_rsp_sub(SUB_POLL), timeout=attempt_s)
|
||||
break
|
||||
except TimeoutError:
|
||||
if time.monotonic() >= deadline:
|
||||
raise TimeoutError(
|
||||
f"the unit did not answer a POLL within {deadline_s:.0f} s "
|
||||
f"(asked every {attempt_s:.0f} s)") from None
|
||||
self._send(SESSION_RESET)
|
||||
self._send(POLL_DATA)
|
||||
rsp = self._recv_one(expected_sub=_expected_rsp_sub(SUB_POLL), timeout=attempt_s)
|
||||
self._drain_boot_string(drain_ms=300) # a late answer to an earlier try, if any
|
||||
return rsp
|
||||
|
||||
def poll(self) -> S3Frame:
|
||||
"""
|
||||
Send a single POLL (SUB 5B) probe+data cycle and return the data response.
|
||||
|
||||
Reference in new issue
Block a user