fix: improve metadata frame detection and update version to v0.12.1

This commit is contained in:
2026-04-15 01:42:13 -04:00
parent 3dd3c970ab
commit ad7b064b67
6 changed files with 91 additions and 17 deletions
+21 -3
View File
@@ -125,6 +125,20 @@ _BULK_COUNTER_STEP = 0x0400 # chunk counter increment per chunk ✅
# protocol requirement. Confirmed 2026-04-06: 0x0400 for chunk 1 works; 0x1004
# causes a 120-second device timeout. Formula n * 0x0400 is used for all chunks.
# Needles for identifying the 5A metadata frame.
# Devices with no Project/Client/etc. configured omit those label strings,
# so b"Geo: " (geo threshold — always present) is the universal fallback.
# Mirror of _METADATA_FRAME_NEEDLES in client.py; kept here for the
# stop_after_metadata check in read_bulk_waveform_stream.
_METADATA_FRAME_NEEDLES: tuple[bytes, ...] = (
b"Project:",
b"Client:",
b"User Name:",
b"Seis Loc:",
b"Extended Notes",
b"Geo: ",
)
# Default timeout values (seconds).
# MiniMate Plus is a slow device — keep these generous.
DEFAULT_RECV_TIMEOUT = 10.0
@@ -617,9 +631,13 @@ class MiniMateProtocol:
break
raise
# Detect metadata frame using the same multi-needle set used by
# _decode_a5_waveform. Devices with no Project/Client/etc.
# configured omit those label strings; b"Geo: " is the fallback.
_is_metadata = any(n in rsp.data for n in _METADATA_FRAME_NEEDLES)
log.warning(
"5A RX chunk=%d page_key=0x%04X data_len=%d contains_Project=%s",
chunk_num, rsp.page_key, len(rsp.data), b"Project:" in rsp.data,
"5A RX chunk=%d page_key=0x%04X data_len=%d is_metadata=%s",
chunk_num, rsp.page_key, len(rsp.data), _is_metadata,
)
if rsp.page_key == 0x0000:
@@ -629,7 +647,7 @@ class MiniMateProtocol:
frames_data.append(rsp.data)
if stop_after_metadata and b"Project:" in rsp.data:
if stop_after_metadata and _is_metadata:
log.debug("5A A5[%d] metadata found — stopping early", chunk_num)
break
else: