diff --git a/klippy/extras/motion_queuing.py b/klippy/extras/motion_queuing.py index d8db880a..21d5465e 100644 --- a/klippy/extras/motion_queuing.py +++ b/klippy/extras/motion_queuing.py @@ -11,6 +11,7 @@ class PrinterMotionQueuing: self.printer = config.get_printer() self.steppers = [] self.trapqs = [] + self.steppersyncs = [] ffi_main, ffi_lib = chelper.get_ffi() self.trapq_finalize_moves = ffi_lib.trapq_finalize_moves def allocate_trapq(self): @@ -18,6 +19,14 @@ class PrinterMotionQueuing: trapq = ffi_main.gc(ffi_lib.trapq_alloc(), ffi_lib.trapq_free) self.trapqs.append(trapq) return trapq + def allocate_steppersync(self, mcu, serialqueue, stepqueues, move_count): + ffi_main, ffi_lib = chelper.get_ffi() + ss = ffi_main.gc( + ffi_lib.steppersync_alloc(serialqueue, stepqueues, len(stepqueues), + move_count), + ffi_lib.steppersync_free) + self.steppersyncs.append((mcu, ss)) + return ss def register_stepper(self, config, stepper): self.steppers.append(stepper) def flush_motion_queues(self, must_flush_time, max_step_gen_time): diff --git a/klippy/mcu.py b/klippy/mcu.py index d3b8ffd7..48eee4e5 100644 --- a/klippy/mcu.py +++ b/klippy/mcu.py @@ -770,13 +770,13 @@ class MCU: move_count = config_params['move_count'] if move_count < self._reserved_move_slots: raise error("Too few moves available on MCU '%s'" % (self._name,)) - ffi_main, ffi_lib = chelper.get_ffi() - self._steppersync = ffi_main.gc( - ffi_lib.steppersync_alloc(self._serial.get_serialqueue(), - self._stepqueues, len(self._stepqueues), - move_count-self._reserved_move_slots), - ffi_lib.steppersync_free) - ffi_lib.steppersync_set_time(self._steppersync, 0., self._mcu_freq) + ss_move_count = move_count - self._reserved_move_slots + motion_queuing = self._printer.lookup_object('motion_queuing') + self._steppersync = motion_queuing.allocate_steppersync( + self, self._serial.get_serialqueue(), + self._stepqueues, ss_move_count) + self._ffi_lib.steppersync_set_time(self._steppersync, + 0., self._mcu_freq) # Log config information move_msg = "Configured MCU '%s' (%d moves)" % (self._name, move_count) logging.info(move_msg)