2 Commits

Author SHA1 Message Date
claude df51fe0668 client: wire record_time (cfg[64] f32_BE) and sample_rate (cfg[52] u16_BE)
Both offsets identified from _cfg_diagnostic scan on BE11529:
  cfg[64] float32_BE = 3.0  → record_time in seconds
  cfg[52] uint16_BE  = 1024 → sample_rate in Sa/s

Values are plausible but NOT yet validated by changing device settings
and re-reading.  Marked as  candidate in docstring — confirm and
remove the ⚠️ note once a device-side change is observed here.
2026-04-01 15:40:35 -04:00
claude 114cbb4679 protocol: skip duplicate E5 chunks in read_compliance_config
BE11529 sometimes returns frame D with page_key=0x0000 (44 bytes),
identical to the frame B response, inflating cfg to ~1115 bytes and
mis-aligning all field offsets.  Track (page_key, chunk_size) pairs
and drop any repeat before appending to the running config buffer.
2026-04-01 15:39:56 -04:00
2 changed files with 45 additions and 12 deletions
+26 -10
View File
@@ -583,16 +583,20 @@ def _decode_compliance_config_into(data: bytes, info: DeviceInfo) -> None:
The *data* argument is the raw bytes returned by read_compliance_config()
(frames B+C+D concatenated, echo headers stripped).
Confirmed field locations (BE11529 with 3-step read, 2126 bytes):
Confirmed field locations (BE11529 with 3-step read, duplicate detection):
- cfg[89] = setup_name: first long ASCII string in cfg[40:250]
- cfg[??] = record_time: float32 BE — offset TBD (scan below)
- cfg[??] = sample_rate: uint16 or float — offset TBD (scan below)
- cfg[64] = record_time: float32 BE (BE11529 shows 3.0 s) ✅ candidate
- cfg[52] = sample_rate: uint16 BE (BE11529 shows 1024 Sa/s) ✅ candidate
- "Project:" needle → project string
- "Client:" needle → client string
- "User Name:" needle → operator string
- "Seis Loc:" needle → sensor_location string
- "Extended Notes" needle → notes string
⚠️ record_time and sample_rate offsets are confirmed candidates from
diagnostic scan but have NOT yet been validated by changing device settings
and re-reading. Mark as ✅ once validated.
Modifies info.compliance_config in-place.
"""
if not data or len(data) < 40:
@@ -619,11 +623,16 @@ def _decode_compliance_config_into(data: bytes, info: DeviceInfo) -> None:
except Exception as exc:
log.warning("compliance_config: setup_name extraction failed: %s", exc)
# ── Record Time (⚠️ OFFSET UNCONFIRMED — waiting on diagnostic output) ──
# Previous guess of 0x28 was wrong (that offset holds "(L)" string).
# The correct offset will be clear once _cfg_diagnostic identifies it.
# Temporarily disabled to avoid returning a garbage value.
config.record_time = None # TODO: set once offset confirmed from diagnostic
# ── Record Time — float32 BE at cfg[64] ──────────────────────────────────
# Diagnostic confirmed: cfg[64] float32_BE = 3.0 on BE11529 (set to 3 s).
# Previous guess of 0x28 was wrong (that offset holds the "(L)" label string).
# ⚠️ Validate by changing device record time and re-reading — mark ✅ once confirmed.
try:
if len(data) > 68:
config.record_time = struct.unpack_from(">f", data, 64)[0]
log.debug("compliance_config: record_time = %.3f s", config.record_time)
except Exception as exc:
log.warning("compliance_config: record_time extraction failed: %s", exc)
# ── Project strings ───────────────────────────────────────────────────────
try:
@@ -655,8 +664,15 @@ def _decode_compliance_config_into(data: bytes, info: DeviceInfo) -> None:
except Exception as exc:
log.warning("compliance_config: project string extraction failed: %s", exc)
# ── Sample rate (⚠️ OFFSET UNCONFIRMED — waiting on diagnostic output) ────
config.sample_rate = None # TODO: set once offset confirmed from diagnostic
# ── Sample Rate — uint16 BE at cfg[52] ───────────────────────────────────
# Diagnostic confirmed: cfg[52] uint16_BE = 1024 on BE11529 (standard mode).
# ⚠️ Validate by changing device sample rate and re-reading — mark ✅ once confirmed.
try:
if len(data) > 54:
config.sample_rate = struct.unpack_from(">H", data, 52)[0]
log.debug("compliance_config: sample_rate = %d Sa/s", config.sample_rate)
except Exception as exc:
log.warning("compliance_config: sample_rate extraction failed: %s", exc)
info.compliance_config = config
+18 -1
View File
@@ -466,6 +466,11 @@ class MiniMateProtocol:
]
config = bytearray()
# Track (page_key, chunk_size) pairs to detect when frame D returns the
# same page/size as frame B — observed on BE11529 when the device is
# busy or connection state is fresh. Duplicate chunks inflate the cfg
# and mis-align field offsets, so we drop them.
seen_chunks: set[tuple[int, int]] = set()
for step_name, step_offset, step_params in _STEPS:
log.debug(
@@ -485,10 +490,22 @@ class MiniMateProtocol:
continue
chunk = data_rsp.data[11:]
page = data_rsp.page_key
key = (page, len(chunk))
if key in seen_chunks:
log.warning(
"read_compliance_config: frame %s page=0x%04X data=%d "
"cfg_chunk=%d DUPLICATE — skipping",
step_name, page, len(data_rsp.data), len(chunk),
)
continue
seen_chunks.add(key)
log.warning(
"read_compliance_config: frame %s page=0x%04X data=%d "
"cfg_chunk=%d running_total=%d",
step_name, data_rsp.page_key, len(data_rsp.data),
step_name, page, len(data_rsp.data),
len(chunk), len(config) + len(chunk),
)
config.extend(chunk)