Sync parser
sync parser implementation
This commit is contained in:
1 parent
96cc366595
commit
d2318b6903
4 files changed
+64
-3
No files matched your search
@@ -1,6 +1,7 @@
|
||||
from serial.tools import list_ports
|
||||
from serial import Serial
|
||||
from dataclasses import dataclass
|
||||
from serial_sync import SerialSync
|
||||
import struct
|
||||
|
||||
DATA_STRUCT = struct.Struct("<BIf")
|
||||
@@ -21,13 +22,16 @@ def main() -> None:
|
||||
choice = None
|
||||
ports = list(list_ports.comports())
|
||||
for index, port in enumerate(ports):
|
||||
if len(ports) < 0:
|
||||
print("No serial ports found.")
|
||||
return
|
||||
print(f"{index}: {port.device} {port.description}")
|
||||
try:
|
||||
choice = int(input("Choose a port to connect: "))
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
while choice is None or choice >= len(ports):
|
||||
while choice is None or choice >= len(ports) or choice < 0:
|
||||
|
||||
try:
|
||||
choice = int(input("Unknown port. Try again : "))
|
||||
@@ -42,10 +46,13 @@ def main() -> None:
|
||||
exit(0)
|
||||
|
||||
with Serial(selected_port,baudrate=115200,timeout=1) as ser:
|
||||
sync = SerialSync(ser)
|
||||
sync.calibrate_sync(30)
|
||||
print(f"sync ok\nOffset:{sync._offset}\nScale:{sync._scale}")
|
||||
while True:
|
||||
start_sync(ser)
|
||||
#print("paquet trouvé")
|
||||
print(DATA_STRUCT.size)
|
||||
#print(DATA_STRUCT.size)
|
||||
payload = read_exactly(ser, DATA_STRUCT.size)
|
||||
|
||||
if not payload:
|
||||
|
||||
Reference in new issue
Block a user