diff --git a/minimateplus/client.py b/minimateplus/client.py index 9c1389a..ab803c3 100644 --- a/minimateplus/client.py +++ b/minimateplus/client.py @@ -993,14 +993,22 @@ def _extract_peak_floats(data: bytes) -> Optional[PeakValues]: if not vals: return None - # ── Peak Vector Sum — fixed offset 87 (✅ confirmed 2026-04-01) ─────────── + # ── Peak Vector Sum — label-relative offset ────────────────────────────── # = √(Tran² + Vert² + Long²) at the sample instant of maximum combined geo # motion, NOT the vector sum of the three per-channel peak values (which may # occur at different times). Matches Blastware "Peak Vector Sum" exactly. + # + # PVS lives at tran_label_pos - 12 for both 0x10 and 0x03 record types. + # Confirmed from raw bytes of two events (2026-04-01 and 2026-04-03): + # 0x10: Tran at byte 98, PVS float at bytes 86–89 (98 - 12 = 86) ✅ + # 0x03: Tran at byte 104, PVS float at bytes 92–95 (104 - 12 = 92) ✅ + # Using a fixed absolute offset (87) breaks for 0x03 records because their + # timestamp header is 10 bytes instead of 9, shifting all subsequent fields. pvs: Optional[float] = None - if len(data) > 91: + tran_pos = data.find(b"Tran") + if tran_pos >= 12: try: - pvs = struct.unpack_from(">f", data, 87)[0] + pvs = struct.unpack_from(">f", data, tran_pos - 12)[0] except struct.error: pass diff --git a/sfm/server.py b/sfm/server.py index 8a57408..10c2a1d 100644 --- a/sfm/server.py +++ b/sfm/server.py @@ -155,7 +155,7 @@ def _serialise_device_info(info: DeviceInfo) -> dict: "dsp_version": info.dsp_version, "manufacturer": info.manufacturer, "model": info.model, - "event_count": info.event_count, + "event_count_sub08": info.event_count, # unreliable — SUB 08 always returns 1 "compliance_config": _serialise_compliance_config(info.compliance_config), }