aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/mcu.py
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2024-05-19 13:15:30 -0400
committerKevin O'Connor <kevin@koconnor.net>2024-05-21 20:16:31 -0400
commit37482178b5482a013a4a5a62789705ccaf1e03c6 (patch)
tree34d936d7d76183bd429fd4dfa399f39fe7ed8dee /klippy/mcu.py
parent4709f1fad50b642f744a8804608d55855d7d7b42 (diff)
downloadkutter-37482178b5482a013a4a5a62789705ccaf1e03c6.tar.gz
kutter-37482178b5482a013a4a5a62789705ccaf1e03c6.tar.xz
kutter-37482178b5482a013a4a5a62789705ccaf1e03c6.zip
mcu: Raise an error on a failed home_wait() call
Raise a printer.command_error exception if a home_wait() call fails. This makes it easier to support future types of homing errors. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy/mcu.py')
-rw-r--r--klippy/mcu.py18
1 files changed, 10 insertions, 8 deletions
diff --git a/klippy/mcu.py b/klippy/mcu.py
index 2a01c5a7..d7a679ac 100644
--- a/klippy/mcu.py
+++ b/klippy/mcu.py
@@ -104,9 +104,9 @@ class CommandWrapper:
class MCU_trsync:
REASON_ENDSTOP_HIT = 1
- REASON_COMMS_TIMEOUT = 2
- REASON_HOST_REQUEST = 3
- REASON_PAST_END_TIME = 4
+ REASON_HOST_REQUEST = 2
+ REASON_PAST_END_TIME = 3
+ REASON_COMMS_TIMEOUT = 4
def __init__(self, mcu, trdispatch):
self._mcu = mcu
self._trdispatch = trdispatch
@@ -180,7 +180,7 @@ class MCU_trsync:
if tc is not None:
self._trigger_completion = None
reason = params['trigger_reason']
- is_failure = (reason == self.REASON_COMMS_TIMEOUT)
+ is_failure = (reason >= self.REASON_COMMS_TIMEOUT)
self._reactor.async_complete(tc, is_failure)
elif self._home_end_clock is not None:
clock = self._mcu.clock32_to_clock64(params['clock'])
@@ -279,8 +279,9 @@ class TriggerDispatch:
ffi_main, ffi_lib = chelper.get_ffi()
ffi_lib.trdispatch_stop(self._trdispatch)
res = [trsync.stop() for trsync in self._trsyncs]
- if any([r == MCU_trsync.REASON_COMMS_TIMEOUT for r in res]):
- return MCU_trsync.REASON_COMMS_TIMEOUT
+ err_res = [r for r in res if r >= MCU_trsync.REASON_COMMS_TIMEOUT]
+ if err_res:
+ return err_res[0]
return res[0]
class MCU_endstop:
@@ -334,8 +335,9 @@ class MCU_endstop:
self._dispatch.wait_end(home_end_time)
self._home_cmd.send([self._oid, 0, 0, 0, 0, 0, 0, 0])
res = self._dispatch.stop()
- if res == MCU_trsync.REASON_COMMS_TIMEOUT:
- return -1.
+ if res >= MCU_trsync.REASON_COMMS_TIMEOUT:
+ cmderr = self._mcu.get_printer().command_error
+ raise cmderr("Communication timeout during homing")
if res != MCU_trsync.REASON_ENDSTOP_HIT:
return 0.
if self._mcu.is_fileoutput():