diff --git a/dstat_interface/dstat_comm.py b/dstat_interface/dstat_comm.py index 0a366f7aca713b173165d3b0545beeed5e83a5f3..ac58436aae39fa901301d1784cc6664da337b441 100755 --- a/dstat_interface/dstat_comm.py +++ b/dstat_interface/dstat_comm.py @@ -33,15 +33,20 @@ exp_logger = logging.getLogger("dstat.comm.Experiment") def _serial_process(ser_port, proc_pipe, ctrl_pipe, data_pipe): ser_logger = logging.getLogger("dstat.comm._serial_process") - ser = serial.Serial(ser_port, baudrate=1000000, timeout=1) + ser = delayedSerial(ser_port, baudrate=1000000, timeout=1) ser_logger.info("Reattaching DStat udc") ser.write("!R") # Send restart command ser.close() - time.sleep(1) # Give OS time to enumerate + for i in range(5): + time.sleep(1) # Give OS time to enumerate - ser = serial.Serial(ser_port, baudrate=1000000, timeout=1) - ser_logger.info("Connecting") + 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 @@ -53,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: