fix: ensure proper waveform context by always calling 0A before 0C and use all-zero params for event advancement
This commit is contained in:
@@ -274,34 +274,31 @@ class MiniMateClient:
|
||||
return []
|
||||
|
||||
events: list[Event] = []
|
||||
idx = 0
|
||||
is_first = True
|
||||
idx = 0
|
||||
|
||||
while data8[4:8] != b"\x00\x00\x00\x00":
|
||||
log.info("get_events: record %d key=%s", idx, key4.hex())
|
||||
ev = Event(index=idx)
|
||||
ev._waveform_key = key4 # stored so download_waveform() can re-use it
|
||||
|
||||
# First event: call 0A to verify it's a full record (0x30 length).
|
||||
# Subsequent keys come from 1F(0xFE) which guarantees full records,
|
||||
# so we skip 0A for those — exactly matching Blastware behaviour.
|
||||
# Always call 0A before 0C to establish device waveform context.
|
||||
# The device requires 0A context for both 0C and the subsequent 1F.
|
||||
# (Earlier code skipped 0A for events after the first — confirmed wrong.)
|
||||
proceed = True
|
||||
if is_first:
|
||||
try:
|
||||
_hdr, rec_len = proto.read_waveform_header(key4)
|
||||
if rec_len < 0x30:
|
||||
log.warning(
|
||||
"get_events: first key=%s is partial (len=0x%02X) — skipping",
|
||||
key4.hex(), rec_len,
|
||||
)
|
||||
proceed = False
|
||||
except ProtocolError as exc:
|
||||
try:
|
||||
_hdr, rec_len = proto.read_waveform_header(key4)
|
||||
if rec_len < 0x30:
|
||||
log.warning(
|
||||
"get_events: 0A failed for key=%s: %s — skipping 0C",
|
||||
key4.hex(), exc,
|
||||
"get_events: key=%s is partial (len=0x%02X) — skipping",
|
||||
key4.hex(), rec_len,
|
||||
)
|
||||
proceed = False
|
||||
is_first = False
|
||||
except ProtocolError as exc:
|
||||
log.warning(
|
||||
"get_events: 0A failed for key=%s: %s — skipping 0C",
|
||||
key4.hex(), exc,
|
||||
)
|
||||
proceed = False
|
||||
|
||||
if proceed:
|
||||
# SUB 0C — full waveform record (peak values, timestamp, "Project:" string)
|
||||
@@ -357,9 +354,18 @@ class MiniMateClient:
|
||||
events.append(ev)
|
||||
idx += 1
|
||||
|
||||
# SUB 1F — advance to the next full waveform record key
|
||||
# SUB 1F — advance to the next record key.
|
||||
# Uses browse mode (all-zero params) — empirically confirmed to work on
|
||||
# this device. token=0xFE (download mode) returns null regardless of
|
||||
# context, even after 0A+0C+5A. The 3-31-26 capture only had one event
|
||||
# so we never saw 1F actually return a second key in download mode;
|
||||
# the token=0xFE assumption was never validated for multi-event iteration.
|
||||
try:
|
||||
key4, data8 = proto.advance_event()
|
||||
key4, data8 = proto.advance_event(browse=True)
|
||||
log.info(
|
||||
"get_events: 1F → key=%s trailing=%s",
|
||||
key4.hex(), data8[4:8].hex(),
|
||||
)
|
||||
except ProtocolError as exc:
|
||||
log.warning("get_events: 1F failed: %s — stopping iteration", exc)
|
||||
break
|
||||
|
||||
Reference in New Issue
Block a user