fix: correct DLE-stuffing handling in build_5a_frame function and update parameter description

This commit is contained in:
2026-04-06 03:02:36 -04:00
parent 5d43acd827
commit 57e7225a62
+8 -7
View File
@@ -112,10 +112,13 @@ def build_5a_frame(offset_word: int, raw_params: bytes) -> bytes:
Args:
offset_word: 16-bit offset (0x1004 for probe/chunks, 0x005A for term).
raw_params: 10 params bytes (from bulk_waveform_params or
bulk_waveform_term_params). 0x10 bytes in params ARE
DLE-stuffed (BW confirmed this for counter=0x1000 and
counter=0x1004 in the capture).
raw_params: 10 or 11 params bytes (from bulk_waveform_params or
bulk_waveform_term_params). 0x10 bytes in params are
written RAW — NOT DLE-stuffed. Confirmed 2026-04-06 by
comparing wire bytes: BW sends bare `10 04` for chunk 1
(counter=0x1004), not stuffed `10 10 04`. Device reads
params at fixed byte positions; stuffing shifts the bytes
and corrupts the counter, causing device to ignore the frame.
Returns:
Complete frame bytes: [ACK][STX][stuffed_section][chk][ETX]
@@ -131,9 +134,7 @@ def build_5a_frame(offset_word: int, raw_params: bytes) -> bytes:
s += b"\x00" # field3
s += bytes([(offset_word >> 8) & 0xFF, # offset_hi — raw, NOT stuffed
offset_word & 0xFF]) # offset_lo
for b in raw_params: # params — DLE-stuffed
if b == DLE:
s.append(DLE)
for b in raw_params: # params — NOT DLE-stuffed (raw bytes, match BW wire format)
s.append(b)
# DLE-aware checksum: for 0x10 XX pairs count XX; for lone bytes count them