Release v0.34.0 — Series-4 parity, and most of Blastware's report from the event file alone #59
No files matched your search
+10
-7
@@ -39,7 +39,9 @@ _WRITE_SUBS: Dict[int, str] = {
|
||||
0xDA: "setup push: file name",
|
||||
}
|
||||
|
||||
# Same bytes, opposite consequence on the other series. Never transmitted on
|
||||
# Same SUB, opposite consequence on the other series (not the same bytes:
|
||||
# Series III's CONFIRM ERASE carries offset 0x0000 and token 0xFE, THOR's 0xA2
|
||||
# carries offset 0xFFFF). Never transmitted on
|
||||
# Series IV, allowed or not: if a Series-III unit is at the address (a moved
|
||||
# modem, a stale IP), it would execute the other meaning. Lifting an entry is
|
||||
# a spec change, not a parameter.
|
||||
@@ -87,17 +89,18 @@ def check_transmit(sub: int, allowed_writes: FrozenSet[int] = frozenset()) -> No
|
||||
"""Raise OpcodeRefused unless `sub` may go on the wire.
|
||||
|
||||
Precedence: (1) a cross-series collision is refused always; (2) a
|
||||
catalogued write is refused unless in `allowed_writes`; (3) a SUB in
|
||||
neither READ_SUBS nor `allowed_writes` is unknown and refused.
|
||||
SUB in neither READ_SUBS nor WRITE_SUBS is unknown and refused whatever
|
||||
`allowed_writes` says; (3) a catalogued write is refused unless in
|
||||
`allowed_writes`.
|
||||
"""
|
||||
if sub in CROSS_SERIES_COLLISIONS:
|
||||
raise OpcodeRefused(
|
||||
f"refused to transmit SUB 0x{sub:02X}: {CROSS_SERIES_COLLISIONS[sub]}")
|
||||
if sub not in READ_SUBS and sub not in WRITE_SUBS:
|
||||
raise OpcodeRefused(
|
||||
f"refused to transmit SUB 0x{sub:02X}: unknown opcode -- not in "
|
||||
"micromate.opcodes; catalogue it first (allowing it does not help)")
|
||||
if sub in WRITE_SUBS and sub not in allowed_writes:
|
||||
raise OpcodeRefused(
|
||||
f"refused to transmit SUB 0x{sub:02X} ({WRITE_SUBS[sub]}): writes are "
|
||||
"not enabled on this connection")
|
||||
if sub not in READ_SUBS and sub not in allowed_writes:
|
||||
raise OpcodeRefused(
|
||||
f"refused to transmit SUB 0x{sub:02X}: unknown opcode -- not in "
|
||||
"micromate.opcodes; catalogue it first")
|
||||
@@ -15,7 +15,8 @@ from micromate.opcodes import ( # noqa: E4
|
||||
)
|
||||
from test_micromate_protocol import frame, proto # noqa: E402
|
||||
|
||||
# THOR's captured end-call-home frame -- byte-identical to Series III's CONFIRM ERASE.
|
||||
# THOR's captured end-call-home frame. Same SUB as Series III's CONFIRM ERASE, not the
|
||||
# same bytes (S3 carries offset 0x0000 and token 0xFE; this carries offset 0xFFFF).
|
||||
A2_WIRE = bytes.fromhex("4102101000a200ffff00000000000000000000b003")
|
||||
|
||||
|
||||
@@ -120,3 +121,8 @@ def test_a_bytearray_frame_is_checked_and_written_as_the_same_bytes():
|
||||
p, t = proto([])
|
||||
p._send(bytearray(build_request(0x5B, 0x0030)))
|
||||
assert t.written == [build_request(0x5B, 0x0030)]
|
||||
|
||||
|
||||
def test_an_uncatalogued_sub_is_refused_even_when_explicitly_allowed():
|
||||
with pytest.raises(OpcodeRefused):
|
||||
check_transmit(0xEE, frozenset({0xEE}))
|
||||
Reference in new issue
Block a user