simplesync/example/simplesynctui.py
2024-01-15 18:06:49 +01:00

22 lines
469 B
Python
Executable File

#!/usr/bin/python
import serial
import pysimplesync
try:
ser = serial.Serial("/dev/ttyACM0");
except:
ser = serial.Serial("/dev/ttyACM1");
def write_to_ser(buf):
ser.write(bytes(buf))
sync = pysimplesync.SimpleSync(write_to_ser)
ser.reset_input_buffer()
sync.request_all_interfaces()
while True:
sync.handle_stream(ser.read_until(b"\x00"))
sync["v2"] = 00
sync["v1"] = 00
sync.update();
print("\t".join([str(a) for a in list(sync)]))