diff --git a/sfm/device_access/s3.py b/sfm/device_access/s3.py index c9e13cc..e187b71 100644 --- a/sfm/device_access/s3.py +++ b/sfm/device_access/s3.py @@ -43,6 +43,17 @@ def s3_run_state(status: Any) -> str: return S3_RUN_STATES.get(flag, f"unknown(0x{flag:02X})") +def _woken_state(client: Any) -> str: + """The run state, read after waking the unit: SESSION_RESET + POLL first. + + A monitoring MiniMate ignores a bare request until it is woken (measured + 2026-04-08). On 2026-10-26 BE9441 acked a start, then let a bare 0x1C go + unanswered for 120 s -- the read-back had relied on the connect's wake, + which a stop's read-back (the unit idle by then) never needed.""" + client.poll() + return s3_run_state(client.get_monitor_status()) + + def default_s3_client_factory(address: UnitAddress, timeout: Optional[float] = None) -> MiniMateClient: if address.host: return MiniMateClient(transport=TcpTransport(address.host, port=address.tcp_port), @@ -208,7 +219,7 @@ class Series3Adapter: even_if_already=even_if_already, audit=audit, address=address, caller=caller, sleep=sleep, verify_timeout_s=verify_timeout_s, verify_interval_s=verify_interval_s, read_serial=read_serial, - read_state=lambda: s3_run_state(client.get_monitor_status()), + read_state=lambda: _woken_state(client), describe_plan=describe_plan, send=send) return self._run(address, op, timeout=S3_EVENT_TIMEOUT, retry=False) diff --git a/tests/test_device_access_change.py b/tests/test_device_access_change.py index 2d245b6..2f5c759 100644 --- a/tests/test_device_access_change.py +++ b/tests/test_device_access_change.py @@ -771,3 +771,17 @@ def test_series3_a_cold_unit_during_a_change_is_not_retried(): da.start_monitoring(TCP3, "BE18193") assert fake.writes == [] assert len(da.factory_calls) == 1 # the change path never takes _run's retry + + +# -- Series 3: a monitoring unit answers only after the wake ---------------------- + +def test_series3_wakes_the_unit_before_every_state_read(): + # BE9441, 2026-10-26 23:41: the start was acked, then one bare 0x1C read got + # nothing for 120 s -- a monitoring unit ignores everything until SESSION_RESET + # + POLL (measured 2026-04-08), which only the connect had sent. + fake = FakeMiniMateClient(monitor_states=[False, True]) + r = access3(fake).start_monitoring(TCP3, "BE18193") + assert r.outcome == "sent" and r.verified == "ok" + after = fake.calls[fake.calls.index("start_monitoring") + 1:] + reads = [i for i, c in enumerate(after) if c == "get_monitor_status"] + assert reads and all(after[i - 1] == "poll" for i in reads)