Release v0.34.0 — Series-4 parity, and most of Blastware's report from the event file alone #59

Merged
serversdown merged 245 commits from dev into main 2026-11-04 18:19:24 -05:00
5 changed files with 71 additions and 6 deletions
Showing only changes of commit 5326e99ac2 - Show all commits

No files matched your search

+11
View File
@@ -169,6 +169,17 @@ class ImageRefused(ValueError):
"""A write refused before any byte was sent: the image is not a whole block.""" """A write refused before any byte was sent: the image is not a whole block."""
def is_call_home_block(raw: bytes) -> bool:
"""Whether a 0x2C reply payload is the call-home block: it starts with its own
length N = 0x7C (00 7C DC on every read on record) and is N (or N + 2) bytes
unescaped. A MONITORING MiniMate answers the read with its device-info block
instead (00 00 00 08 'Instantel' ..., measured 2026-11-03 on BE9441), which
fails this."""
image = unescape_reply(bytes(raw))
n = DATA_LENGTHS[SUB_CALL_HOME]
return len(image) >= 3 and int.from_bytes(image[:2], "big") == n and len(image) in (n, n + 2)
def call_home_enabled(raw: bytes) -> Optional[bool]: def call_home_enabled(raw: bytes) -> Optional[bool]:
"""The call-home switch of a `0x2C` reply payload, read UNESCAPED (an escaped """The call-home switch of a `0x2C` reply payload, read UNESCAPED (an escaped
byte before it would move the raw index -- bench finding #1's lesson): byte 5, byte before it would move the raw index -- bench finding #1's lesson): byte 5,
+17 -5
View File
@@ -13,12 +13,12 @@ from minimateplus.event_file_io import _GEO_INT16_FS
from minimateplus.framing import build_bw_write_frame, unescape_reply from minimateplus.framing import build_bw_write_frame, unescape_reply
from minimateplus.protocol import ( from minimateplus.protocol import (
SUB_CALL_HOME_CONFIRM, SUB_CALL_HOME_WRITE, SUB_START_MONITORING, SUB_STOP_MONITORING, SUB_CALL_HOME_CONFIRM, SUB_CALL_HOME_WRITE, SUB_START_MONITORING, SUB_STOP_MONITORING,
ImageRefused, call_home_enabled, call_home_image, write_image, ImageRefused, call_home_enabled, call_home_image, is_call_home_block, write_image,
) )
from minimateplus.transport import TcpTransport from minimateplus.transport import TcpTransport
from .errors import (DeviceError, EventNotFound, MalformedReply, NoAnswer, NotSupported, StaleEvent, from .errors import (DeviceError, EventNotFound, MalformedReply, NoAnswer, NotSupported, StaleEvent,
WrongUnit, translate) UnitStateUnknown, WrongUnit, translate)
from .change import call_home_change, monitoring_change, run_change from .change import call_home_change, monitoring_change, run_change
from .events import iso_of, make_event_id, stamp_of from .events import iso_of, make_event_id, stamp_of
from .models import (CallHomeState, ChangeResult, DownloadedEvent, EventList, EventRef, UnitAddress, from .models import (CallHomeState, ChangeResult, DownloadedEvent, EventList, EventRef, UnitAddress,
@@ -39,6 +39,13 @@ S3_EVENT_TIMEOUT = 120.0 # what the legacy event-download routes use
# writes (BE11529, 2026-04-20) byte for byte from the unit's own reads. # writes (BE11529, 2026-04-20) byte for byte from the unit's own reads.
S3_CALL_HOME_FRAME_VERIFIED = True S3_CALL_HOME_FRAME_VERIFIED = True
# Measured 2026-11-03 (BE9441): while monitoring, a MiniMate answers the 0x2C read
# with its device-info block, as it answers 1A -- its call-home settings cannot be
# read, so they cannot be changed (SFM writes back only a block it just read).
S3_CALL_HOME_WHILE_MONITORING = ("did not return its call-home settings -- a MiniMate answers the "
"call-home read with its device-info block while monitoring; "
"stop monitoring first, then change call-home")
# The 0x1C flag byte (section[1]): the only values ever measured. 0x10 is # The 0x1C flag byte (section[1]): the only values ever measured. 0x10 is
# BE11529 monitoring (2026-04-08); 0x0B is BE9441 recording a histogram, # BE11529 monitoring (2026-04-08); 0x0B is BE9441 recording a histogram,
# confirmed at the unit (2026-10-26). Anything else is refused for a change. # confirmed at the unit (2026-10-26). Anything else is refused for a change.
@@ -349,11 +356,14 @@ class Series3Adapter:
client.wake(attempt_s=S3_WAKE_ATTEMPT_S, deadline_s=S3_WAKE_DEADLINE_S) client.wake(attempt_s=S3_WAKE_ATTEMPT_S, deadline_s=S3_WAKE_DEADLINE_S)
raw = client.read_call_home_raw() raw = client.read_call_home_raw()
image = unescape_reply(raw) image = unescape_reply(raw)
detail = {"byte5": f"0x{image[5]:02X}" if len(image) > 5 else None,
"block": bytes(raw).hex(), "serial_verified": False}
if not is_call_home_block(raw):
detail["reason"] = f"the unit {S3_CALL_HOME_WHILE_MONITORING}"
return CallHomeState(serial=serial, series=3, enabled=None, dial_string=None, detail=detail)
dial = bytes(image[6:46]).split(b"\x00", 1)[0].decode("ascii", errors="replace") or None dial = bytes(image[6:46]).split(b"\x00", 1)[0].decode("ascii", errors="replace") or None
return CallHomeState(serial=serial, series=3, enabled=call_home_enabled(raw), return CallHomeState(serial=serial, series=3, enabled=call_home_enabled(raw),
dial_string=dial, dial_string=dial, detail=detail)
detail={"byte5": f"0x{image[5]:02X}" if len(image) > 5 else None,
"block": bytes(raw).hex(), "serial_verified": False})
return self._run(address, op) return self._run(address, op)
def change_call_home(self, address: UnitAddress, serial: str, *, enabled: bool, dry_run: bool, def change_call_home(self, address: UnitAddress, serial: str, *, enabled: bool, dry_run: bool,
@@ -378,6 +388,8 @@ class Series3Adapter:
def read_state() -> str: def read_state() -> str:
client.wake(attempt_s=S3_WAKE_ATTEMPT_S, deadline_s=S3_WAKE_DEADLINE_S) client.wake(attempt_s=S3_WAKE_ATTEMPT_S, deadline_s=S3_WAKE_DEADLINE_S)
raw = client.read_call_home_raw() raw = client.read_call_home_raw()
if not is_call_home_block(raw):
raise UnitStateUnknown(f"{serial} {S3_CALL_HOME_WHILE_MONITORING} -- nothing sent")
reads.append(raw) reads.append(raw)
on = call_home_enabled(raw) on = call_home_enabled(raw)
if on is None: if on is None:
+2 -1
View File
@@ -204,8 +204,9 @@ function serialPanes(bySerial, settingsRead) {
// enable byte never measured -- shown with the byte, never as On or Off. // enable byte never measured -- shown with the byte, never as On or Off.
function callHomeRows(state) { function callHomeRows(state) {
const s = state || {}; const s = state || {};
const d = s.detail || {};
const sw = s.enabled === true ? 'On' : s.enabled === false ? 'Off' const sw = s.enabled === true ? 'On' : s.enabled === false ? 'Off'
: `Unknown (byte 5 = ${(s.detail || {}).byte5 ?? '?'})`; : d.reason || `Unknown (byte 5 = ${d.byte5 ?? '?'})`;
return [['Call-home', sw], ['Dial string', s.dial_string || '—'], ['Series', s.series]]; return [['Call-home', sw], ['Dial string', s.dial_string || '—'], ['Series', s.series]];
} }
/* </device-routing> */ /* </device-routing> */
+34
View File
@@ -145,3 +145,37 @@ def test_a_pre_wire_refusal_is_recorded_as_nothing_sent():
((_, row),) = audit.rows.items() ((_, row),) = audit.rows.items()
assert (row["outcome"], row["sent"]) == ("failed", 0) assert (row["outcome"], row["sent"]) == ("failed", 0)
assert row["error"].startswith("refused before sending") assert row["error"].startswith("refused before sending")
# Measured 2026-11-03 (BE9441): while monitoring, a MiniMate answers the 0x2C read
# with its DEVICE-INFO block ("Instantel", "MiniMate Plus", its serial), not its
# call-home block -- as it answers 1A. Idle again, it returns the call-home block.
# SFM says so plainly instead of "run state unknown(0x6E)".
def device_info_shaped(serial=b"BE9441"):
"""Shaped like BE9441's reply (its first bytes: 00 00 00 08 'Instantel')."""
block = b"\x00\x00\x00\x08Instantel".ljust(26, b"\x00") + b"MiniMate Plus".ljust(16, b"\x00") + serial
return block.ljust(126, b"\x00")
def test_a_call_home_block_is_told_from_the_device_info_block():
from minimateplus.protocol import is_call_home_block
assert is_call_home_block(s3_call_home_raw()) is True
assert is_call_home_block(device_info_shaped()) is False
@pytest.mark.parametrize("dry_run", [True, False])
def test_a_monitoring_minimate_is_told_to_stop_first_and_nothing_is_sent(dry_run):
fake = FakeMiniMateClient(call_home_raw=device_info_shaped())
with pytest.raises(UnitStateUnknown) as e:
change(adapter(fake), enabled=True, dry_run=dry_run)
msg = str(e.value)
assert "monitoring" in msg and "stop" in msg and "nothing sent" in msg
assert e.value.http_status == 409 and fake.writes == []
def test_the_call_home_state_of_a_monitoring_minimate_says_why():
st = adapter(FakeMiniMateClient(call_home_raw=device_info_shaped())).call_home_state(TCP, "BE18193")
assert st.enabled is None
assert "monitoring" in st.detail["reason"]
+7
View File
@@ -327,3 +327,10 @@ def test_call_home_rows():
assert r[0] == [["Call-home", "On"], ["Dial string", "RADIO RING"], ["Series", 4]] assert r[0] == [["Call-home", "On"], ["Dial string", "RADIO RING"], ["Series", 4]]
assert r[1] == [["Call-home", "Off"], ["Dial string", "—"], ["Series", 3]] assert r[1] == [["Call-home", "Off"], ["Dial string", "—"], ["Series", 3]]
assert r[2][0] == ["Call-home", "Unknown (byte 5 = 0x07)"] assert r[2][0] == ["Call-home", "Unknown (byte 5 = 0x07)"]
def test_call_home_rows_say_why_a_switch_did_not_read():
r = run(["callHomeRows", [{"enabled": None, "dial_string": None, "series": 3,
"detail": {"byte5": "0x6E", "reason": "not readable while monitoring -- stop it first"}}]])
assert r[0][0] == ["Call-home", "not readable while monitoring -- stop it first"]