fix: fix token position in params and enhance event iteration logic for MiniMateClient
This commit is contained in:
@@ -201,9 +201,20 @@ class MiniMateClient:
|
||||
log.info("count_events: 1E returned null sentinel — device is empty")
|
||||
return 0
|
||||
|
||||
# Iterate via 0A → 1F. Each 0A call establishes waveform context so that
|
||||
# 1F (EVENT_ADVANCE) returns the actual next-event key. Without the 0A
|
||||
# call, 1F immediately returns the null sentinel regardless of how many
|
||||
# events are stored. Confirmed from 4-3-26 two-event BW/S3 capture:
|
||||
# browse-mode sequence is 0A(keyN) → 1F → 0A(keyN+1) → 1F → … → null.
|
||||
count = 0
|
||||
while data8[4:8] != b"\x00\x00\x00\x00":
|
||||
count += 1
|
||||
try:
|
||||
# 0A establishes device context for this key before 1F advances.
|
||||
proto.read_waveform_header(key4)
|
||||
except ProtocolError as exc:
|
||||
log.warning("count_events: 0A failed for key=%s: %s", key4.hex(), exc)
|
||||
break
|
||||
try:
|
||||
key4, data8 = proto.advance_event()
|
||||
log.warning(
|
||||
|
||||
@@ -223,21 +223,27 @@ def token_params(token: int = 0) -> bytes:
|
||||
Build the 10-byte params block that carries a single token byte.
|
||||
|
||||
Used for SUBs 1E (EVENT_HEADER) and 1F (EVENT_ADVANCE).
|
||||
The token goes at params[6], which maps to payload[12].
|
||||
The token goes at params[7], which maps to payload[13].
|
||||
|
||||
Confirmed from BOTH 3-31-26 and 4-3-26 BW TX captures:
|
||||
raw params bytes: 00 00 00 00 00 00 00 fe 00 00
|
||||
token is at index 7 (not 6 — that was wrong).
|
||||
|
||||
Confirmed from 3-31-26 capture:
|
||||
- token=0x00: first-event read / browse mode (no download marking)
|
||||
- token=0xfe: download mode (causes 1F to skip partial bins and
|
||||
advance to the next full record)
|
||||
|
||||
The device echoes the token at data[8] of the S3 response (payload[13]),
|
||||
distinct from the next-event key at data[11:15] (payload[16:20]).
|
||||
|
||||
Args:
|
||||
token: single byte to place at params[6] / payload[12].
|
||||
token: single byte to place at params[7] / payload[13].
|
||||
|
||||
Returns:
|
||||
10-byte params block with token at position [6].
|
||||
10-byte params block with token at position [7].
|
||||
"""
|
||||
p = bytearray(10)
|
||||
p[6] = token
|
||||
p[7] = token
|
||||
return bytes(p)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user