motion_report: Improve "motion_report/dump_trapq" during homing

Now that trapq_extract_old() can return upcoming moves, it's possible
for homing to cause confusing results (as these moves can end early).
Avoid this by delaying query responses until after homing completes.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor
2025-10-09 21:05:34 -04:00
parent 3fe594ef20
commit 95b0ebf4c7
2 changed files with 16 additions and 0 deletions

View File

@@ -54,6 +54,8 @@ class PrinterMotionQueuing:
self.do_kick_flush_timer = True
self.last_flush_time = self.last_step_gen_time = 0.
self.need_flush_time = self.need_step_gen_time = 0.
# "Drip" timing (for homing and probing moves)
self.drip_start_times = []
# Register handlers
printer.register_event_handler("klippy:shutdown", self._handle_shutdown)
# C trapq tracking
@@ -245,7 +247,9 @@ class PrinterMotionQueuing:
if self.do_kick_flush_timer:
self.do_kick_flush_timer = False
self.reactor.update_timer(self.flush_timer, self.reactor.NOW)
# "Drip" timing (for homing and probing moves)
def drip_update_time(self, start_time, end_time, drip_completion):
self.drip_start_times.append(start_time)
self._await_flush_time(start_time)
# Disable background flushing from timer
self.reactor.update_timer(self.flush_timer, self.reactor.NEVER)
@@ -269,6 +273,11 @@ class PrinterMotionQueuing:
# Restore background flushing
self.reactor.update_timer(self.flush_timer, self.reactor.NOW)
self._advance_flush_time(flush_time + self.kin_flush_delay)
self.drip_start_times.remove(start_time)
def check_drip_timing(self):
if not self.drip_start_times:
return None
return min(self.drip_start_times)
def load_config(config):
return PrinterMotionQueuing(config)

View File

@@ -71,6 +71,7 @@ class DumpTrapQ:
self.name = name
self.trapq = trapq
self.last_batch_msg = (0., 0.)
self.motion_queuing = printer.lookup_object("motion_queuing")
self.batch_bulk = bulk_sensor.BatchBulkHelper(printer,
self._process_batch)
api_resp = {'header': ('time', 'duration', 'start_velocity',
@@ -121,6 +122,12 @@ class DumpTrapQ:
d = [(m.print_time, m.move_t, m.start_v, m.accel,
(m.start_x, m.start_y, m.start_z), (m.x_r, m.y_r, m.z_r))
for m in data]
if d:
start_drip_time = self.motion_queuing.check_drip_timing()
if start_drip_time is not None:
# If homing, delay sending trapq entries that may change
while d and d[-1][0] + d[-1][1] >= start_drip_time:
d.pop()
if d and d[0] == self.last_batch_msg:
d.pop(0)
if not d: