fix(lf): download only the acquired sample count, not a fixed span

With the debug-frame fix the BigBuf download now returns clean sample frames (verified on
hardware: offsets 0..N, real envelope data, then ACK). But identify downloaded a fixed
15000 bytes while the acquisition captured 12288 samples (98304 bits / 8), so the tail was
BigBuf memory past the samples (heap / the 0xDEADBEEF stack canary) — which flagged as
"garbage" and poisoned the demod.

read_emitted now sizes the download to lf.read()'s reported count (firmware returns the
size in BITS; /8 = samples at 8 bits/sample); read_config downloads the readbl acquisition
span. No trailing memory -> the demod runs on clean samples.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
michael
2026-07-14 17:34:23 -07:00
parent 938a571155
commit a06f4d12b8
2 changed files with 27 additions and 4 deletions

View File

@@ -362,3 +362,12 @@ class TestIdentifyLF:
def test_no_device(self):
assert identify_lf(None) is None
class TestAcquiredBytes:
def test_bit_count_to_bytes(self):
from pm3py.lf.capture import _acquired_bytes
assert _acquired_bytes({"samples": 98304}, 15000) == 12288 # 98304 bits / 8 = 12288 samples
assert _acquired_bytes({"samples": 0}, 15000) == 15000 # no count -> fallback
assert _acquired_bytes(None, 15000) == 15000
assert _acquired_bytes({"samples": 100}, 15000) == 512 # clamped up to a floor