aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/serialhdl.py
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2019-06-21 18:54:56 -0400
committerKevin O'Connor <kevin@koconnor.net>2019-06-21 21:42:20 -0400
commitd98bbc772cb2a605786443d8cf12abce963a07f6 (patch)
tree7427a349f29d5ca82f4521038a4005ce1ee051c5 /klippy/serialhdl.py
parentebb375fee9bafd3910ea77301e199b34a2a58cc6 (diff)
downloadkutter-d98bbc772cb2a605786443d8cf12abce963a07f6.tar.gz
kutter-d98bbc772cb2a605786443d8cf12abce963a07f6.tar.xz
kutter-d98bbc772cb2a605786443d8cf12abce963a07f6.zip
serialhdl: Eventually timeout connect attempt
If the serial connection has not been successful after 2.5 minutes then report an error. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy/serialhdl.py')
-rw-r--r--klippy/serialhdl.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/klippy/serialhdl.py b/klippy/serialhdl.py
index 0f182da2..6284fe4d 100644
--- a/klippy/serialhdl.py
+++ b/klippy/serialhdl.py
@@ -67,8 +67,11 @@ class SerialReader:
def connect(self):
# Initial connection
logging.info("Starting serial connect")
+ start_time = self.reactor.monotonic()
while 1:
- starttime = self.reactor.monotonic()
+ connect_time = self.reactor.monotonic()
+ if connect_time > start_time + 150.:
+ raise error("Unable to connect")
try:
if self.baud:
self.ser = serial.Serial(
@@ -77,7 +80,7 @@ class SerialReader:
self.ser = open(self.serialport, 'rb+')
except (OSError, IOError, serial.SerialException) as e:
logging.warn("Unable to open port: %s", e)
- self.reactor.pause(starttime + 5.)
+ self.reactor.pause(connect_time + 5.)
continue
if self.baud:
stk500v2_leave(self.ser, self.reactor)
@@ -87,7 +90,7 @@ class SerialReader:
self.background_thread.start()
# Obtain and load the data dictionary from the firmware
try:
- identify_data = self._get_identify_data(starttime + 5.)
+ identify_data = self._get_identify_data(connect_time + 5.)
except error as e:
logging.exception("Timeout on serial connect")
self.disconnect()