fix(blastware_file): remove harmful "duplicate header+STRT" strip logic to preserve valid waveform data
This commit is contained in:
@@ -732,24 +732,18 @@ def write_blastware_file(
|
||||
bytes(all_bytes[-28:]).hex() if len(all_bytes) >= 28 else bytes(all_bytes).hex(),
|
||||
)
|
||||
|
||||
# Strip embedded "duplicate header+STRT" blocks from body (v0.14.1).
|
||||
# Chunk@0x1000 sometimes lands on the device's metadata-mirror page,
|
||||
# whose response includes a 25-byte "00 12 03 00 STRT ..." block that
|
||||
# mirrors the file's own header + STRT record. BW treats embedded STRT
|
||||
# markers as second-event starts and rejects the file. Replace these
|
||||
# blocks with zeros to preserve file size + alignment.
|
||||
needle = b"\x00\x12\x03\x00STRT"
|
||||
pos = bytes(all_bytes).find(needle)
|
||||
while pos >= 0:
|
||||
end = pos + 25
|
||||
if end <= len(all_bytes):
|
||||
all_bytes[pos:end] = b"\x00" * 25
|
||||
log.warning(
|
||||
"write_blastware_file: stripped duplicate header+STRT at "
|
||||
"all_bytes[%d:%d] (replaced with 25 zero-bytes)",
|
||||
pos, end,
|
||||
)
|
||||
pos = bytes(all_bytes).find(needle, end)
|
||||
# NOTE: The "duplicate header+STRT strip" logic from v0.13.x has been
|
||||
# REMOVED in v0.14.2. Under the v0.14.0 BW-exact 5A walk, body assembly
|
||||
# is just contiguous concatenation of frame contributions in stream order
|
||||
# (probe → meta@0x1002 → meta@0x1004 → samples → TERM), exactly as BW
|
||||
# writes its files. The previous strip was matching the `00 12 03 00 STRT`
|
||||
# byte sequence in legitimate waveform data — sample chunks at counter
|
||||
# 0x1000 and beyond often contain those bytes coincidentally — and
|
||||
# zeroing 25 bytes of valid samples per match. Compared to a known-good
|
||||
# BW reference for the same 3-sec event 0, the strip introduced 26 bytes
|
||||
# of zeros that BW did not have, then propagated alignment differences
|
||||
# through the rest of the body. See decode_test/5-1-26/bw vs SFM diff
|
||||
# at file[0x1012..0x102B] (2026-05-04 analysis).
|
||||
|
||||
# Find the first valid 0e 08 footer marker (v0.14.0).
|
||||
footer_pos = -1
|
||||
|
||||
Reference in New Issue
Block a user