Let MCU detection recover faster

Use small timeouts to recover faster if there is a misdetection for
whatever reason (truncated packet, user program toggles port, etc.).
This commit is contained in:
Grigori Goronzy 2015-11-25 22:19:54 +01:00
parent b72c5a60fb
commit e0afd851ae

View File

@ -718,9 +718,9 @@ class StcBaseProtocol:
self.ser = serial.Serial(port=self.port, baudrate=self.baud_handshake,
parity=self.PARITY)
# conservative timeout values
self.ser.timeout = 10.0
self.ser.interCharTimeout = 1.0
# fast timeout values to deal with detection errors
self.ser.timeout = 0.5
self.ser.interCharTimeout = 0.5
print("Waiting for MCU, please cycle power: ", end="")
sys.stdout.flush()
@ -735,6 +735,10 @@ class StcBaseProtocol:
except (StcFramingException, serial.SerialTimeoutException): pass
print("done")
# conservative timeout values
self.ser.timeout = 15.0
self.ser.interCharTimeout = 1.0
self.initialize_status(status_packet)
self.initialize_model()
self.initialize_options(status_packet)