aboutsummaryrefslogtreecommitdiffstats
path: root/klippy
diff options
context:
space:
mode:
Diffstat (limited to 'klippy')
-rw-r--r--klippy/extras/bltouch.py3
-rw-r--r--klippy/extras/homing.py8
-rw-r--r--klippy/mcu.py12
3 files changed, 18 insertions, 5 deletions
diff --git a/klippy/extras/bltouch.py b/klippy/extras/bltouch.py
index 05822c01..48759752 100644
--- a/klippy/extras/bltouch.py
+++ b/klippy/extras/bltouch.py
@@ -116,7 +116,8 @@ class BLTouchEndstopWrapper:
self.mcu_endstop.home_start(self.action_end_time, ENDSTOP_SAMPLE_TIME,
ENDSTOP_SAMPLE_COUNT, ENDSTOP_REST_TIME,
triggered=triggered)
- return self.mcu_endstop.home_wait(self.action_end_time + 0.100)
+ trigger_time = self.mcu_endstop.home_wait(self.action_end_time + 0.100)
+ return trigger_time > 0.
def raise_probe(self):
self.sync_mcu_print_time()
if not self.pin_up_not_triggered:
diff --git a/klippy/extras/homing.py b/klippy/extras/homing.py
index dc7acd62..67a19513 100644
--- a/klippy/extras/homing.py
+++ b/klippy/extras/homing.py
@@ -76,9 +76,11 @@ class HomingMove:
# Wait for endstops to trigger
move_end_print_time = self.toolhead.get_last_move_time()
for mcu_endstop, name in self.endstops:
- did_trigger = mcu_endstop.home_wait(move_end_print_time)
- if not did_trigger and check_triggered and error is None:
- error = "Failed to home %s: Timeout during homing" % (name,)
+ trigger_time = mcu_endstop.home_wait(move_end_print_time)
+ if trigger_time < 0. and error is None:
+ error = "Communication timeout during homing %s" % (name,)
+ elif not trigger_time and check_triggered and error is None:
+ error = "No trigger on %s after full movement" % (name,)
# Determine stepper halt positions
self.toolhead.flush_step_generation()
self.end_mcu_pos = [(s, name, spos, s.get_mcu_position())
diff --git a/klippy/mcu.py b/klippy/mcu.py
index 83143837..eb1f319f 100644
--- a/klippy/mcu.py
+++ b/klippy/mcu.py
@@ -136,6 +136,7 @@ class MCU_endstop:
self._home_cmd = self._query_cmd = None
self._mcu.register_config_callback(self._build_config)
self._trigger_completion = None
+ self._rest_ticks = 0
ffi_main, ffi_lib = chelper.get_ffi()
self._trdispatch = ffi_main.gc(ffi_lib.trdispatch_alloc(), ffi_lib.free)
self._trsync = MCU_trsync(mcu, self._trdispatch)
@@ -169,6 +170,7 @@ class MCU_endstop:
triggered=True):
clock = self._mcu.print_time_to_clock(print_time)
rest_ticks = self._mcu.print_time_to_clock(print_time+rest_time) - clock
+ self._rest_ticks = rest_ticks
reactor = self._mcu.get_printer().get_reactor()
self._trigger_completion = reactor.completion()
etrsync = self._trsync
@@ -190,7 +192,15 @@ class MCU_endstop:
ffi_main, ffi_lib = chelper.get_ffi()
ffi_lib.trdispatch_stop(self._trdispatch)
res = etrsync.stop()
- return res == etrsync.REASON_ENDSTOP_HIT
+ if res == etrsync.REASON_COMMS_TIMEOUT:
+ return -1.
+ if res != etrsync.REASON_ENDSTOP_HIT:
+ return 0.
+ if self._mcu.is_fileoutput():
+ return home_end_time
+ params = self._query_cmd.send([self._oid])
+ next_clock = self._mcu.clock32_to_clock64(params['next_clock'])
+ return self._mcu.clock_to_print_time(next_clock - self._rest_ticks)
def query_endstop(self, print_time):
clock = self._mcu.print_time_to_clock(print_time)
if self._mcu.is_fileoutput():