mcu: Be sure all moves are completed before raising a home timeout

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2017-12-05 23:50:29 -05:00
parent b340fdcc4a
commit c78f66b8e8
1 changed files with 6 additions and 7 deletions

View File

@ -179,7 +179,7 @@ class MCU_endstop:
rest_ticks = int(rest_time * self._mcu.get_adjusted_freq()) rest_ticks = int(rest_time * self._mcu.get_adjusted_freq())
self._homing = True self._homing = True
self._min_query_time = self._mcu.monotonic() self._min_query_time = self._mcu.monotonic()
self._next_query_time = print_time + self.RETRY_QUERY self._next_query_time = self._min_query_time + self.RETRY_QUERY
msg = self._home_cmd.encode( msg = self._home_cmd.encode(
self._oid, clock, self._mcu.seconds_to_clock(sample_time), self._oid, clock, self._mcu.seconds_to_clock(sample_time),
sample_count, rest_ticks, 1 ^ self._invert) sample_count, rest_ticks, 1 ^ self._invert)
@ -195,7 +195,6 @@ class MCU_endstop:
self._last_state = params self._last_state = params
def _check_busy(self, eventtime, home_end_time=0.): def _check_busy(self, eventtime, home_end_time=0.):
# Check if need to send an end_stop_query command # Check if need to send an end_stop_query command
print_time = self._mcu.estimated_print_time(eventtime)
last_sent_time = self._last_state.get('#sent_time', -1.) last_sent_time = self._last_state.get('#sent_time', -1.)
if last_sent_time >= self._min_query_time or self._mcu.is_fileoutput(): if last_sent_time >= self._min_query_time or self._mcu.is_fileoutput():
if not self._homing: if not self._homing:
@ -205,7 +204,8 @@ class MCU_endstop:
s.note_homing_end(did_trigger=True) s.note_homing_end(did_trigger=True)
self._homing = False self._homing = False
return False return False
if print_time > home_end_time: last_sent_print_time = self._mcu.estimated_print_time(last_sent_time)
if last_sent_print_time > home_end_time:
# Timeout - disable endstop checking # Timeout - disable endstop checking
for s in self._steppers: for s in self._steppers:
s.note_homing_end() s.note_homing_end()
@ -215,15 +215,14 @@ class MCU_endstop:
raise self.TimeoutError("Timeout during endstop homing") raise self.TimeoutError("Timeout during endstop homing")
if self._mcu.is_shutdown(): if self._mcu.is_shutdown():
raise error("MCU is shutdown") raise error("MCU is shutdown")
if print_time >= self._next_query_time: if eventtime >= self._next_query_time:
self._next_query_time = print_time + self.RETRY_QUERY self._next_query_time = eventtime + self.RETRY_QUERY
msg = self._query_cmd.encode(self._oid) msg = self._query_cmd.encode(self._oid)
self._mcu.send(msg, cq=self._cmd_queue) self._mcu.send(msg, cq=self._cmd_queue)
return True return True
def query_endstop(self, print_time): def query_endstop(self, print_time):
self._homing = False self._homing = False
self._next_query_time = print_time self._min_query_time = self._next_query_time = self._mcu.monotonic()
self._min_query_time = self._mcu.monotonic()
def query_endstop_wait(self): def query_endstop_wait(self):
eventtime = self._mcu.monotonic() eventtime = self._mcu.monotonic()
while self._check_busy(eventtime): while self._check_busy(eventtime):