mirror of
https://github.com/Klipper3d/klipper.git
synced 2025-07-18 04:08:04 -06:00
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>
This commit is contained in:
parent
4709f1fad5
commit
37482178b5
4 changed files with 24 additions and 14 deletions
|
@ -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():
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue