Release v0.34.0 — Series-4 parity, and most of Blastware's report from the event file alone #59
No files matched your search
@@ -56,6 +56,8 @@ class WritePlan:
|
|||||||
steps: Tuple[WriteStep, ...]
|
steps: Tuple[WriteStep, ...]
|
||||||
|
|
||||||
def __post_init__(self) -> None:
|
def __post_init__(self) -> None:
|
||||||
|
# Copy: a caller's list must not be able to add a step after validation.
|
||||||
|
object.__setattr__(self, "steps", tuple(self.steps))
|
||||||
for s in self.steps:
|
for s in self.steps:
|
||||||
if s.sub in CROSS_SERIES_COLLISIONS:
|
if s.sub in CROSS_SERIES_COLLISIONS:
|
||||||
raise OpcodeRefused(
|
raise OpcodeRefused(
|
||||||
@@ -117,6 +119,11 @@ def plan_setup_push(prefs: bytes, trigger: bytes, setup: bytes, name: str) -> Wr
|
|||||||
No field editing here (phase 5). Each block goes back with its length echo
|
No field editing here (phase 5). Each block goes back with its length echo
|
||||||
[0:3] zeroed; the unit recomputes the CRCs, so 0x68 and 0x71 drop the CRC
|
[0:3] zeroed; the unit recomputes the CRCs, so 0x68 and 0x71 drop the CRC
|
||||||
slot and 0x82 sends it zeroed -- exactly THOR's frames.
|
slot and 0x82 sends it zeroed -- exactly THOR's frames.
|
||||||
|
|
||||||
|
The name goes out exactly as given. `MicromateClient.get_active_setup()`
|
||||||
|
strips whitespace, so a setup name with leading or trailing spaces would
|
||||||
|
not round-trip through it; phase 5 decides whether to take the unstripped
|
||||||
|
name from the 0x41 read.
|
||||||
"""
|
"""
|
||||||
_checked(prefs, _PREFS_LEN, "preferences (0x08)")
|
_checked(prefs, _PREFS_LEN, "preferences (0x08)")
|
||||||
_checked(trigger, _TRIGGER_LEN, "trigger (0x2E)")
|
_checked(trigger, _TRIGGER_LEN, "trigger (0x2E)")
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
"""Write plans: built from the unit's own reads, equal to THOR's frames byte for byte."""
|
"""Write plans: built from the unit's own reads, equal to THOR's frames byte for byte."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import dataclasses
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
@@ -80,15 +81,24 @@ def test_call_home_enable_then_disable_equal_thors_frames():
|
|||||||
assert off.frames() == [w2, confirms[1]]
|
assert off.frames() == [w2, confirms[1]]
|
||||||
|
|
||||||
|
|
||||||
def test_call_home_flips_exactly_one_bit_and_echoes_everything_else():
|
def _call_home_reads():
|
||||||
r1 = next(_content(e) for e in _session("call-home-enable-disable") if e["sub"] == 0x2C)
|
return [_content(e) for e in _session("call-home-enable-disable") if e["sub"] == 0x2C]
|
||||||
for enabled in (True, False):
|
|
||||||
data = plan_call_home_enabled(r1, enabled).steps[0].data
|
|
||||||
diff = [i for i in range(len(r1)) if data[i] != r1[i]]
|
@pytest.mark.parametrize("read_idx", [0, 1])
|
||||||
|
@pytest.mark.parametrize("enabled", [True, False])
|
||||||
|
def test_call_home_flips_exactly_one_bit_and_echoes_everything_else(read_idx, enabled):
|
||||||
|
reads = _call_home_reads()
|
||||||
|
assert {reads[0][5], reads[1][5]} == {0x04, 0x05}
|
||||||
|
r = reads[read_idx]
|
||||||
|
data = plan_call_home_enabled(r, enabled).steps[0].data
|
||||||
|
diff = [i for i in range(len(r)) if data[i] != r[i]]
|
||||||
assert set(diff) <= {5}
|
assert set(diff) <= {5}
|
||||||
assert data[5] & 0x01 == (1 if enabled else 0)
|
assert data[5] & 0x01 == (1 if enabled else 0)
|
||||||
assert data[5] & 0xFE == r1[5] & 0xFE
|
assert data[5] & 0xFE == r[5] & 0xFE
|
||||||
assert data[118:120] == r1[118:120]
|
if (r[5] & 1) == int(enabled):
|
||||||
|
assert data[5] == r[5]
|
||||||
|
assert data[118:120] == r[118:120]
|
||||||
|
|
||||||
|
|
||||||
def test_call_home_refuses_an_unobserved_size():
|
def test_call_home_refuses_an_unobserved_size():
|
||||||
@@ -160,3 +170,20 @@ def test_describe_is_the_dry_run_shape():
|
|||||||
assert step == {"sub": "0x97", "what": "stop monitoring", "offset": "0xFFFF",
|
assert step == {"sub": "0x97", "what": "stop monitoring", "offset": "0xFFFF",
|
||||||
"data_len": 0, "expect_ack": "0x68",
|
"data_len": 0, "expect_ack": "0x68",
|
||||||
"frame": "41021010009700ffff00000000000000000000a503"}
|
"frame": "41021010009700ffff00000000000000000000a503"}
|
||||||
|
|
||||||
|
|
||||||
|
def test_a_plan_copies_its_steps_so_a_later_mutation_cannot_change_it():
|
||||||
|
lst = [WriteStep(0x96, 0xFFFF)]
|
||||||
|
plan = WritePlan("start", lst)
|
||||||
|
before = plan.frames()
|
||||||
|
lst.append(WriteStep(0xA2, 0xFFFF))
|
||||||
|
lst[0] = WriteStep(0x97, 0xFFFF)
|
||||||
|
assert isinstance(plan.steps, tuple) and len(plan.steps) == 1
|
||||||
|
assert plan.steps[0].sub == 0x96
|
||||||
|
assert plan.frames() == before
|
||||||
|
|
||||||
|
|
||||||
|
def test_steps_cannot_be_reassigned():
|
||||||
|
plan = plan_stop_monitoring()
|
||||||
|
with pytest.raises(dataclasses.FrozenInstanceError):
|
||||||
|
plan.steps = ()
|
||||||
Reference in new issue
Block a user