feat(micromate): get_event_count() and read_unsolicited()
0x06 content[0:4] moves from the bench tool into the client, tested against a real UM20147 read and its chain-walk count. read_unsolicited() reads without sending, for spotting RADIO RING on an idle session. 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
31181f64e6
commit
fa032567c2
2 files changed
+49
No files matched your search
@@ -547,3 +547,30 @@ def test_is_open_works_on_a_real_transport():
|
||||
|
||||
mm = MicromateClient(TcpTransport("127.0.0.1", port=9)) # never connected
|
||||
assert mm.is_open() is False
|
||||
|
||||
|
||||
# ── get_event_count() / read_unsolicited() ────────────────────────────────────
|
||||
|
||||
# 0x06 response data captured from UM20147 (11.0BD) by Task 2, Step 1. The
|
||||
# expected count is that session's independent chain-walk count.
|
||||
SR_UM20147 = bytes.fromhex("2400000000000000000000000000050000000900000000000000000000000600000000000000000000000000000000")
|
||||
SR_UM20147_CHAIN_WALK_COUNT = 5
|
||||
|
||||
|
||||
def test_event_count_is_content_0_4_and_matches_the_chain_walk():
|
||||
mm, t = client([frame(0xF9, SR_UM20147, flags=FLAGS_THOR)])
|
||||
assert mm.get_event_count() == SR_UM20147_CHAIN_WALK_COUNT
|
||||
assert [w[5] for w in t.written] == [0x06]
|
||||
|
||||
|
||||
def test_a_truncated_storage_range_raises():
|
||||
mm, _ = client([frame(0xF9, bytes(CONTENT) + b"\x00\x05", flags=FLAGS_THOR)])
|
||||
with pytest.raises(ProtocolError, match="storage range"):
|
||||
mm.get_event_count()
|
||||
|
||||
|
||||
def test_read_unsolicited_sends_nothing_and_returns_what_arrived():
|
||||
"""Used to spot RADIO RING on an idle session. It must never write."""
|
||||
mm, t = client([b"\r\nRADIO RING\r\n"])
|
||||
assert mm.read_unsolicited() == b"\r\nRADIO RING\r\n"
|
||||
assert t.written == []
|
||||
Reference in new issue
Block a user