fix
This commit is contained in:
@ -30,6 +30,7 @@ READ_CHUNK = 65536
|
||||
MARKER_MAIN = 0x000A
|
||||
MARKER_REF = 0x00A8
|
||||
MAX_SWEEP_POINTS = 4096 # safety limit — force finalize if dict grows past this
|
||||
MIN_SWEEP_POINTS = 400 # discard fragments shorter than this
|
||||
|
||||
DATA_PATH = "/tmp/ttyADC_data"
|
||||
|
||||
@ -74,7 +75,6 @@ class SweepAccumulator:
|
||||
self._buf = bytearray()
|
||||
self._main = {} # step → (ch1_i16, ch2_i16)
|
||||
self._ref = {}
|
||||
self._last_main_step = -1
|
||||
|
||||
def feed(self, data):
|
||||
"""Feed raw bytes. Return list of completed sweep dicts."""
|
||||
@ -98,14 +98,7 @@ class SweepAccumulator:
|
||||
|
||||
# Main channel data point
|
||||
if w0 == MARKER_MAIN and w1 != 0xFFFF:
|
||||
step = w1
|
||||
# Detect sweep wrap (step regression) without start marker
|
||||
if self._last_main_step >= 0 and step < self._last_main_step - 10:
|
||||
sw = self._finalize()
|
||||
if sw is not None:
|
||||
sweeps.append(sw)
|
||||
self._main[step] = (_i16(w2), _i16(w3))
|
||||
self._last_main_step = step
|
||||
self._main[w1] = (_i16(w2), _i16(w3))
|
||||
# Safety: force finalize if accumulator grew too large
|
||||
if len(self._main) >= MAX_SWEEP_POINTS:
|
||||
sw = self._finalize()
|
||||
|
||||
Reference in New Issue
Block a user