new e502 adc
This commit is contained in:
@ -143,6 +143,8 @@ class LegacyBinaryParser:
|
||||
|
||||
def __init__(self):
|
||||
self._buf = bytearray()
|
||||
self._last_step: Optional[int] = None
|
||||
self._seen_points = False
|
||||
|
||||
@staticmethod
|
||||
def _u16_at(buf: bytearray, offset: int) -> int:
|
||||
@ -157,11 +159,17 @@ class LegacyBinaryParser:
|
||||
w1 = self._u16_at(self._buf, 2)
|
||||
w2 = self._u16_at(self._buf, 4)
|
||||
if w0 == 0xFFFF and w1 == 0xFFFF and w2 == 0xFFFF and self._buf[6] == 0x0A:
|
||||
self._last_step = None
|
||||
self._seen_points = False
|
||||
events.append(StartEvent(ch=int(self._buf[7])))
|
||||
del self._buf[:8]
|
||||
continue
|
||||
if self._buf[6] == 0x0A:
|
||||
ch = int(self._buf[7])
|
||||
if self._seen_points and self._last_step is not None and w0 <= self._last_step:
|
||||
events.append(StartEvent(ch=ch))
|
||||
self._seen_points = True
|
||||
self._last_step = int(w0)
|
||||
value = u32_to_i32((w1 << 16) | w2)
|
||||
events.append(PointEvent(ch=ch, x=int(w0), y=float(value)))
|
||||
del self._buf[:8]
|
||||
@ -175,6 +183,8 @@ class LogScaleBinaryParser32:
|
||||
|
||||
def __init__(self):
|
||||
self._buf = bytearray()
|
||||
self._last_step: Optional[int] = None
|
||||
self._seen_points = False
|
||||
|
||||
@staticmethod
|
||||
def _u16_at(buf: bytearray, offset: int) -> int:
|
||||
@ -187,11 +197,17 @@ class LogScaleBinaryParser32:
|
||||
while len(self._buf) >= 12:
|
||||
words = [self._u16_at(self._buf, idx * 2) for idx in range(6)]
|
||||
if words[0:5] == [0xFFFF] * 5 and (words[5] & 0x00FF) == 0x000A:
|
||||
self._last_step = None
|
||||
self._seen_points = False
|
||||
events.append(StartEvent(ch=int((words[5] >> 8) & 0x00FF)))
|
||||
del self._buf[:12]
|
||||
continue
|
||||
if (words[5] & 0x00FF) == 0x000A and words[0] != 0xFFFF:
|
||||
ch = int((words[5] >> 8) & 0x00FF)
|
||||
if self._seen_points and self._last_step is not None and words[0] <= self._last_step:
|
||||
events.append(StartEvent(ch=ch))
|
||||
self._seen_points = True
|
||||
self._last_step = int(words[0])
|
||||
avg_1 = u32_to_i32((words[1] << 16) | words[2])
|
||||
avg_2 = u32_to_i32((words[3] << 16) | words[4])
|
||||
events.append(
|
||||
@ -214,6 +230,8 @@ class LogScale16BitX2BinaryParser:
|
||||
def __init__(self):
|
||||
self._buf = bytearray()
|
||||
self._current_channel = 0
|
||||
self._last_step: Optional[int] = None
|
||||
self._seen_points = False
|
||||
|
||||
@staticmethod
|
||||
def _u16_at(buf: bytearray, offset: int) -> int:
|
||||
@ -227,10 +245,16 @@ class LogScale16BitX2BinaryParser:
|
||||
words = [self._u16_at(self._buf, idx * 2) for idx in range(4)]
|
||||
if words[0:3] == [0xFFFF, 0xFFFF, 0xFFFF] and (words[3] & 0x00FF) == 0x000A:
|
||||
self._current_channel = int((words[3] >> 8) & 0x00FF)
|
||||
self._last_step = None
|
||||
self._seen_points = False
|
||||
events.append(StartEvent(ch=self._current_channel))
|
||||
del self._buf[:8]
|
||||
continue
|
||||
if words[3] == 0xFFFF and words[0] != 0xFFFF:
|
||||
if self._seen_points and self._last_step is not None and words[0] <= self._last_step:
|
||||
events.append(StartEvent(ch=self._current_channel))
|
||||
self._seen_points = True
|
||||
self._last_step = int(words[0])
|
||||
real = u16_to_i16(words[1])
|
||||
imag = u16_to_i16(words[2])
|
||||
events.append(
|
||||
|
||||
Reference in New Issue
Block a user