fix(sfm): a Micromate's call-home is refused while monitoring, and only a real call-home block is ever edited
Measured at the bench 2026-11-03 (UM20147): monitoring, a Micromate returns its real call-home block and ACKS a call-home write, but does not apply it -- three read-backs unchanged, and its own menu says 'Feature disabled while monitoring'. SFM now refuses up front (UnitStateUnknown, 409: '... is monitoring -- a Micromate ignores call-home changes while monitoring ...; stop monitoring first -- nothing sent'), dry run included, instead of sending a write the unit ignores. And the block must be the call-home block: micromate.writes.is_call_home_content checks its header is its own length (00 7C, N = 124 -- 00 7C DC on every read, UM12947 and UM20147). plan_call_home_enabled refuses any other 126 bytes, the change refuses before sending, and call_home_state says why (enabled = None). At the bench this was checked by eye before the monitoring write. 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
5326e99ac2
commit
f35845d403
4 files changed
+74
-4
No files matched your search
+23
-4
@@ -19,12 +19,14 @@ from typing import Any, Callable, Optional, TypeVar
|
||||
from micromate.client import MicromateClient
|
||||
from micromate.opcodes import OpcodeRefused
|
||||
from micromate.protocol import THOR_CHUNK_SIZE
|
||||
from micromate.writes import plan_call_home_enabled, plan_start_monitoring, plan_stop_monitoring
|
||||
from micromate.writes import (
|
||||
is_call_home_content, plan_call_home_enabled, plan_start_monitoring, plan_stop_monitoring,
|
||||
)
|
||||
from minimateplus.transport import BaseTransport, SerialTransport, TcpTransport
|
||||
|
||||
from .errors import (
|
||||
AuditIncomplete, CallHomeInProgress, ChangeUnconfirmed, DeviceError, EventNotFound,
|
||||
MalformedReply, StaleEvent, WrongUnit, translate,
|
||||
MalformedReply, StaleEvent, UnitStateUnknown, WrongUnit, translate,
|
||||
)
|
||||
from .change import CALL_HOME_MESSAGE, call_home_change, monitoring_change, run_change
|
||||
from .events import iso_of, make_event_id, stamp_of
|
||||
@@ -383,12 +385,24 @@ def _changed_offsets(before: bytes, after: bytes) -> list:
|
||||
if (before[i] if i < len(before) else None) != (after[i] if i < len(after) else None)]
|
||||
|
||||
|
||||
# Measured 2026-11-03 (UM20147): monitoring, a Micromate returns its real call-home
|
||||
# block and ACKS a write, but does not apply it -- its own menu: "Feature disabled
|
||||
# while monitoring". So SFM refuses before sending one it would ignore.
|
||||
S4_CALL_HOME_WHILE_MONITORING = ("is monitoring -- a Micromate ignores call-home changes while "
|
||||
"monitoring (its own menu: 'Feature disabled while monitoring'); "
|
||||
"stop monitoring first, then change call-home")
|
||||
_NOT_CALL_HOME = "returned a block that is not its call-home block (header {}, not 007c)"
|
||||
|
||||
|
||||
def s4_call_home_state(client: Any, serial: str) -> CallHomeState:
|
||||
"""Bit 0 of content[5] is the enable (UM12947 reads 0x05 / 0x04, UM20147 0x01)."""
|
||||
block = client.get_call_home_content()
|
||||
detail = {"byte5": f"0x{block[5]:02X}" if len(block) > 5 else None, "block": block.hex()}
|
||||
if not is_call_home_content(block):
|
||||
detail["reason"] = "the unit " + _NOT_CALL_HOME.format(block[0:2].hex())
|
||||
return CallHomeState(serial=serial, series=4, enabled=None, dial_string=None, detail=detail)
|
||||
return CallHomeState(serial=serial, series=4, enabled=bool(block[5] & 0x01),
|
||||
dial_string=_dial_string(block),
|
||||
detail={"byte5": f"0x{block[5]:02X}", "block": block.hex()})
|
||||
dial_string=_dial_string(block), detail=detail)
|
||||
|
||||
|
||||
def s4_change_call_home(client: Any, serial: str, *, enabled: bool, dry_run: bool,
|
||||
@@ -406,7 +420,12 @@ def s4_change_call_home(client: Any, serial: str, *, enabled: bool, dry_run: boo
|
||||
run = client.read_run_state().name
|
||||
if run == "calling_home" or run.startswith("unknown"):
|
||||
return run # the core refuses both; a write waits for a known state
|
||||
if run == "monitoring" and not reads:
|
||||
raise UnitStateUnknown(f"{serial} {S4_CALL_HOME_WHILE_MONITORING} -- nothing sent")
|
||||
block = client.get_call_home_content()
|
||||
if not is_call_home_content(block):
|
||||
raise UnitStateUnknown(f"{serial} " + _NOT_CALL_HOME.format(block[0:2].hex())
|
||||
+ " -- nothing sent")
|
||||
reads.append(block)
|
||||
return "enabled" if block[5] & 0x01 else "disabled"
|
||||
|
||||
|
||||
Reference in new issue
Block a user