client: remove _cfg_diagnostic now that all compliance fields are confirmed
record_time (float32_BE) and sample_rate (uint16_BE) both validated against live device across normal / fast / faster modes and multiple record time settings. Diagnostic scaffolding no longer needed.
This commit is contained in:
@@ -608,11 +608,6 @@ def _decode_compliance_config_into(data: bytes, info: DeviceInfo) -> None:
|
||||
|
||||
config = ComplianceConfig(raw=data)
|
||||
|
||||
# ── Diagnostic: scan full cfg for strings and plausible floats ─────────────
|
||||
# Logged at WARNING so they appear without debug mode. Remove once field
|
||||
# offsets are confirmed for both BE11529 and BE18189.
|
||||
_cfg_diagnostic(data)
|
||||
|
||||
# ── Setup name ────────────────────────────────────────────────────────────
|
||||
# The setup_name IS the string itself — it is NOT a label followed by a value.
|
||||
# It appears as the first long (>=8 char) ASCII string in cfg[40:250].
|
||||
@@ -709,57 +704,3 @@ def _find_first_string(data: bytes, start: int, end: int, min_len: int) -> Optio
|
||||
i += 1
|
||||
return None
|
||||
|
||||
|
||||
def _cfg_diagnostic(data: bytes) -> None:
|
||||
"""
|
||||
Log all strings and plausible float32 BE values found in the full compliance
|
||||
config data. Used to map field offsets for record_time and sample_rate.
|
||||
Remove once offsets are confirmed.
|
||||
"""
|
||||
import struct as _struct
|
||||
|
||||
# ── All printable ASCII strings >= 4 chars ────────────────────────────────
|
||||
strings_found = []
|
||||
i = 0
|
||||
while i < len(data):
|
||||
if 0x20 <= data[i] < 0x7F:
|
||||
j = i
|
||||
while j < len(data) and 0x20 <= data[j] < 0x7F:
|
||||
j += 1
|
||||
if j - i >= 4:
|
||||
s = data[i:j].decode("ascii", errors="replace")
|
||||
strings_found.append((i, s))
|
||||
i = j
|
||||
else:
|
||||
i += 1
|
||||
|
||||
log.warning("cfg_diag: %d strings found:", len(strings_found))
|
||||
for off, s in strings_found[:40]: # cap at 40 to avoid log spam
|
||||
log.warning(" cfg[%04d/0x%04X] str %r", off, off, s[:60])
|
||||
|
||||
# ── Float32 BE values in plausible physical ranges ─────────────────────────
|
||||
log.warning("cfg_diag: float32_BE scan (plausible record_time / sample_rate / trigger):")
|
||||
for i in range(len(data) - 3):
|
||||
try:
|
||||
v = _struct.unpack_from(">f", data, i)[0]
|
||||
except Exception:
|
||||
continue
|
||||
if v != v or v == float("inf") or v == float("-inf"):
|
||||
continue
|
||||
tag = ""
|
||||
if 0.5 <= v <= 30.0: tag = "RECORD_TIME?"
|
||||
elif 200 <= v <= 8192: tag = "SAMPLE_RATE?"
|
||||
elif 0.003 <= v <= 5.0: tag = "TRIGGER/ALARM?"
|
||||
if tag:
|
||||
log.warning(" cfg[%04d/0x%04X] f32_BE=%10.4f %s", i, i, v, tag)
|
||||
|
||||
# ── uint16 BE/LE scan for known sample rates ──────────────────────────────
|
||||
known_rates = {256, 512, 1024, 2048, 4096}
|
||||
log.warning("cfg_diag: uint16 scan for sample rates %s:", known_rates)
|
||||
for i in range(len(data) - 1):
|
||||
u16_le = _struct.unpack_from("<H", data, i)[0]
|
||||
u16_be = _struct.unpack_from(">H", data, i)[0]
|
||||
if u16_le in known_rates:
|
||||
log.warning(" cfg[%04d/0x%04X] uint16_LE=%d", i, i, u16_le)
|
||||
if u16_be in known_rates and u16_be != u16_le:
|
||||
log.warning(" cfg[%04d/0x%04X] uint16_BE=%d", i, i, u16_be)
|
||||
|
||||
Reference in New Issue
Block a user