client: add WARNING-level diagnostics for Tran channel block search

Temporary: log tran_pos, surrounding bytes, and exact unit string check
results at WARNING level so we can see why trigger/alarm/max_range are
still null even with the full 2126-byte cfg.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Brian Harrison
2026-04-02 14:18:27 -04:00
parent 638e60532c
commit c4a5da893c

View File

@@ -703,6 +703,13 @@ def _decode_compliance_config_into(data: bytes, info: DeviceInfo) -> None:
# "Tran2" at a later position won't match because its surrounding bytes differ. # "Tran2" at a later position won't match because its surrounding bytes differ.
try: try:
tran_pos = data.find(b"Tran", 1000) tran_pos = data.find(b"Tran", 1000)
log.warning("compliance_config: 'Tran' search from 1000 → pos=%d cfg_len=%d", tran_pos, len(data))
if tran_pos >= 0:
pre = data[max(0, tran_pos - 30) : tran_pos + 8]
log.warning(
"compliance_config: bytes around 'Tran'@%d: %s",
tran_pos, pre.hex(),
)
if ( if (
tran_pos >= 24 tran_pos >= 24
and data[tran_pos + 4 : tran_pos + 5] != b"2" # not "Tran2" and data[tran_pos + 4 : tran_pos + 5] != b"2" # not "Tran2"
@@ -712,18 +719,22 @@ def _decode_compliance_config_into(data: bytes, info: DeviceInfo) -> None:
config.trigger_level_geo = struct.unpack_from(">f", data, tran_pos - 18)[0] config.trigger_level_geo = struct.unpack_from(">f", data, tran_pos - 18)[0]
config.alarm_level_geo = struct.unpack_from(">f", data, tran_pos - 10)[0] config.alarm_level_geo = struct.unpack_from(">f", data, tran_pos - 10)[0]
config.max_range_geo = struct.unpack_from(">f", data, tran_pos - 24)[0] config.max_range_geo = struct.unpack_from(">f", data, tran_pos - 24)[0]
log.debug( log.warning(
"compliance_config: trigger=%.4f alarm=%.4f max_range=%.4f in/s", "compliance_config: trigger=%.4f alarm=%.4f max_range=%.4f in/s",
config.trigger_level_geo, config.alarm_level_geo, config.max_range_geo, config.trigger_level_geo, config.alarm_level_geo, config.max_range_geo,
) )
elif tran_pos >= 0: elif tran_pos >= 24:
log.debug( log.warning(
"compliance_config: 'Tran' at %d but unit strings absent " "compliance_config: 'Tran' at %d unit string check failed: "
"— channel block not yet in cfg (frame D duplicate?)", "label-14..label-10=%s (want 696e2e00) label-6..label-2=%s (want 2f730000)",
tran_pos, tran_pos,
data[tran_pos - 14 : tran_pos - 10].hex(),
data[tran_pos - 6 : tran_pos - 2 ].hex(),
) )
elif tran_pos >= 0:
log.warning("compliance_config: 'Tran' at %d but too close to start (< 24)", tran_pos)
else: else:
log.debug("compliance_config: channel block not present in cfg (len=%d)", len(data)) log.warning("compliance_config: channel block not present in cfg (len=%d)", len(data))
except Exception as exc: except Exception as exc:
log.warning("compliance_config: channel block extraction failed: %s", exc) log.warning("compliance_config: channel block extraction failed: %s", exc)