fix(protocol): remove auto-detection of frame mode and ensure extra chunks are always used for valid waveform footer

This commit is contained in:
2026-04-28 00:05:51 -04:00
parent 6b875e161b
commit e1a6fd5386
2 changed files with 24 additions and 29 deletions
+6 -23
View File
@@ -614,31 +614,14 @@ class MiniMateProtocol:
[f"0x{f.page_key:04X}" for f in probe_batch],
)
# Auto-detect frame mode from probe response size.
#
# Two observed TCP modes (confirmed from 4-26-26 and 4-27-26 captures):
#
# 1-frame mode (RS-232 / fast TCP): probe returns 1 large frame (~1100 B).
# Each subsequent chunk also returns 1 large frame. The probe contributes
# ~999 bytes of ADC body data. The correct term_counter = metadata_counter
# + 0x0400, which returns ~702 bytes of tail+footer — NO extra chunk needed.
#
# 2-frame mode (TCP frame-splitting): probe returns 1 smaller frame (~554 B).
# Each subsequent chunk returns 2 smaller frames (~550 B each). The probe
# contributes only ~487 bytes. The missing ~512 bytes of body data must come
# from an extra chunk after metadata, terminating at metadata_counter+0x0800.
# The caller's extra_chunks_after_metadata value (default 1) covers this.
#
# Threshold 700 B sits comfortably between the two observed probe sizes (554 vs
# 1097 bytes) and is robust to minor variation.
_probe_is_large = (
len(probe_batch) == 1 and len(probe_batch[0].data) >= 700
)
_effective_extra_chunks = 0 if _probe_is_large else extra_chunks_after_metadata
# Log probe frame size for diagnostics.
# The device always needs extra_chunks_after_metadata chunks after the
# metadata frame before termination to prime the valid waveform footer.
# This holds regardless of TCP frame size (1-frame vs 2-frame mode).
_effective_extra_chunks = extra_chunks_after_metadata
log.warning(
"5A probe data_len=%d _probe_is_large=%s effective_extra_chunks=%d",
"5A probe data_len=%d effective_extra_chunks=%d",
len(probe_batch[0].data),
_probe_is_large,
_effective_extra_chunks,
)