tui update
This commit is contained in:
parent
5f03c0a18c
commit
d90bd69576
@ -1,23 +1,36 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
import serial
|
import serial
|
||||||
import pysimplesync
|
import pysimplesync
|
||||||
|
import time
|
||||||
|
|
||||||
try:
|
i = 0
|
||||||
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:
|
while True:
|
||||||
|
try:
|
||||||
|
ser = None
|
||||||
|
if (i == 0):
|
||||||
|
ser = serial.Serial("/dev/ttyUSB0",115200);
|
||||||
|
elif (i == 1):
|
||||||
|
ser = serial.Serial("/dev/ttyACM0");
|
||||||
|
elif (i == 2):
|
||||||
|
ser = serial.Serial("/dev/ttyACM1");
|
||||||
|
else:
|
||||||
|
i = 0
|
||||||
|
|
||||||
|
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.handle_stream(ser.read_until(b"\x00"))
|
||||||
print("\t".join([str(a) for a in list(sync)]))
|
print("\t".join([str(a) for a in list(sync)]))
|
||||||
sync["v2"] = -400
|
|
||||||
sync["v1"] = 400
|
|
||||||
# 11.62V := 604
|
# 11.62V := 604
|
||||||
sync.update();
|
sync.update();
|
||||||
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
|
time.sleep(0.5);
|
||||||
|
if ser is not None:
|
||||||
|
ser.close()
|
||||||
|
i+=1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user