refactor: normalize data directory naming, and consolidate serial connection handling
This commit is contained in:
@@ -309,9 +309,11 @@ class SessionController(QObject):
|
||||
|
||||
# The new binary protocol sends payload of (sensorCount * 2) bytes
|
||||
# Each sensor is a big-endian 16-bit value (Sign-Magnitude).
|
||||
expected_sensors = 80 if (family_code or "") == "X" else 244
|
||||
|
||||
def parse_binary_frame(payload: bytes, seq: int) -> Frame:
|
||||
values = []
|
||||
num_sensors = min(80, len(payload) // 2)
|
||||
num_sensors = min(expected_sensors, len(payload) // 2)
|
||||
for i in range(num_sensors):
|
||||
high_byte = payload[i * 2]
|
||||
low_byte = payload[i * 2 + 1]
|
||||
@@ -333,13 +335,9 @@ class SessionController(QObject):
|
||||
self._last = None
|
||||
self._last_raw_frame = None
|
||||
|
||||
try:
|
||||
transport = pyserial.Serial(port, SerialPort.BAUDRATE, timeout=1)
|
||||
except Exception as exc:
|
||||
log.warning("Baud rate %d failed on %s, falling back to 115200: %s", SerialPort.BAUDRATE, port, exc)
|
||||
transport = pyserial.Serial(port, 115200, timeout=1)
|
||||
transport = SerialPort.open_port(port, timeout=1)
|
||||
# Send 'D2' command padded to 512 bytes to start the stream
|
||||
cmd = b"D2" + (b"F" * 510)
|
||||
cmd = b"D2" + SerialPort.COMMAND_PAD.encode()
|
||||
transport.write(cmd)
|
||||
|
||||
def on_error(exc: Exception):
|
||||
|
||||
Reference in New Issue
Block a user