fix: correct DLE-stuffing handling in build_5a_frame function and update parameter description
This commit is contained in:
@@ -112,10 +112,13 @@ def build_5a_frame(offset_word: int, raw_params: bytes) -> bytes:
|
|||||||
|
|
||||||
Args:
|
Args:
|
||||||
offset_word: 16-bit offset (0x1004 for probe/chunks, 0x005A for term).
|
offset_word: 16-bit offset (0x1004 for probe/chunks, 0x005A for term).
|
||||||
raw_params: 10 params bytes (from bulk_waveform_params or
|
raw_params: 10 or 11 params bytes (from bulk_waveform_params or
|
||||||
bulk_waveform_term_params). 0x10 bytes in params ARE
|
bulk_waveform_term_params). 0x10 bytes in params are
|
||||||
DLE-stuffed (BW confirmed this for counter=0x1000 and
|
written RAW — NOT DLE-stuffed. Confirmed 2026-04-06 by
|
||||||
counter=0x1004 in the capture).
|
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:
|
Returns:
|
||||||
Complete frame bytes: [ACK][STX][stuffed_section][chk][ETX]
|
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 += b"\x00" # field3
|
||||||
s += bytes([(offset_word >> 8) & 0xFF, # offset_hi — raw, NOT stuffed
|
s += bytes([(offset_word >> 8) & 0xFF, # offset_hi — raw, NOT stuffed
|
||||||
offset_word & 0xFF]) # offset_lo
|
offset_word & 0xFF]) # offset_lo
|
||||||
for b in raw_params: # params — DLE-stuffed
|
for b in raw_params: # params — NOT DLE-stuffed (raw bytes, match BW wire format)
|
||||||
if b == DLE:
|
|
||||||
s.append(DLE)
|
|
||||||
s.append(b)
|
s.append(b)
|
||||||
|
|
||||||
# DLE-aware checksum: for 0x10 XX pairs count XX; for lone bytes count them
|
# DLE-aware checksum: for 0x10 XX pairs count XX; for lone bytes count them
|
||||||
|
|||||||
Reference in New Issue
Block a user