fix: skip trigger/alarm extraction pending offset confirmation

The heuristic offsets for trigger/alarm levels were causing struct unpack
errors. These fields require detailed field mapping from actual E5 captures
to determine exact byte positions relative to channel labels.

For now, skip extraction and leave trigger_level_geo/alarm_level_geo as None.
This prevents the '500 Device error: bytes must be in range(0, 256)' error.

Once we capture an E5 response and map the exact float positions, we can
re-enable this section with correct offsets.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
Brian Harrison
2026-04-01 13:07:04 -04:00
parent 32b9d3050c
commit 7e501620fc

View File

@@ -608,39 +608,10 @@ def _decode_compliance_config_into(data: bytes, info: DeviceInfo) -> None:
log.warning("compliance_config: failed to unpack record_time at offset 0x28") log.warning("compliance_config: failed to unpack record_time at offset 0x28")
# ── Per-channel trigger/alarm levels (✅ CONFIRMED at §7.6) ───────────────── # ── Per-channel trigger/alarm levels (✅ CONFIRMED at §7.6) ─────────────────
# Layout repeats per channel: [padding][max_range][padding][trigger]["in.\0"][alarm]["/s\0\0"][flag][label] # Layout (per §7.6): [padding2][max_range][padding][trigger]["in.\0"][alarm]["/s\0\0"][flag][label]
# For now, extract just the first geo channel (Transverse) as a representative. # Exact byte offsets relative to label require detailed field mapping from actual captures.
try: # For now, we skip extraction — this section will be populated once we have precise offsets.
# Search for the "Tran" label to locate the first geo channel block # TODO: Capture E5 response and map exact trigger/alarm float positions
tran_pos = data.find(b"Tran")
if tran_pos > 0:
# Work backward from the label to find trigger and alarm
# From §7.6: trigger float is ~20 bytes before the label, alarm is ~8 bytes before
# Exact structure: [padding2][trigger_float][unit "in."][alarm_float][unit "/s"]
# We'll search backward for the last float before the label
# The trigger/alarm block format is complex; for now use heuristics
# Look for trigger level at a few standard offsets relative to label
# From protocol: trigger is usually at label_offset - 14
if tran_pos >= 14:
try:
trigger = struct.unpack_from(">f", data, tran_pos - 14)[0]
config.trigger_level_geo = trigger
log.debug("compliance_config: trigger_level_geo = %.3f in/s", trigger)
except (struct.error, ValueError):
pass
# Alarm is usually after the "in." unit string following trigger
# Try offset tran_pos - 6
if tran_pos >= 6:
try:
alarm = struct.unpack_from(">f", data, tran_pos - 6)[0]
config.alarm_level_geo = alarm
log.debug("compliance_config: alarm_level_geo = %.3f in/s", alarm)
except (struct.error, ValueError):
pass
except Exception as exc:
log.warning("compliance_config: trigger/alarm extraction failed: %s", exc)
# ── Project strings (from E5 / SUB 71 payload) ──────────────────────────── # ── Project strings (from E5 / SUB 71 payload) ────────────────────────────
try: try: