diff --git a/dstat_interface/dstat_comm.py b/dstat_interface/dstat_comm.py index a4e98ff86bb540b058bf17527fbaa3d66ce0ece0..ac58436aae39fa901301d1784cc6664da337b441 100755 --- a/dstat_interface/dstat_comm.py +++ b/dstat_interface/dstat_comm.py @@ -34,10 +34,21 @@ def _serial_process(ser_port, proc_pipe, ctrl_pipe, data_pipe): ser_logger = logging.getLogger("dstat.comm._serial_process") ser = delayedSerial(ser_port, baudrate=1000000, timeout=1) + ser_logger.info("Reattaching DStat udc") + ser.write("!R") # Send restart command + ser.close() - ser_logger.info("Connecting") + for i in range(5): + time.sleep(1) # Give OS time to enumerate - ser.write("ck") + try: + ser = delayedSerial(ser_port, baudrate=1000000, timeout=1) + ser_logger.info("Connecting") + break + except serial.SerialException: + pass + + ser.write("ck") # Keep this to support old firmwares ser.flushInput() ser.write('!') @@ -47,6 +58,7 @@ def _serial_process(ser_port, proc_pipe, ctrl_pipe, data_pipe): time.sleep(.5) ser.write('!') else: + ser.write('V') break while True: