Skip to content

Commit

Permalink
Gracefully flushing move queue
Browse files Browse the repository at this point in the history
Signed-off-by: Pascal Pieper <[email protected]>
  • Loading branch information
Cirromulus committed Oct 28, 2020
1 parent 474549f commit 7b89695
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 14 deletions.
3 changes: 0 additions & 3 deletions klippy/chelper/stepcompress.c
Original file line number Diff line number Diff line change
Expand Up @@ -550,12 +550,9 @@ sync_channel_queue_msg(struct sync_channel *pc, uint32_t *data, int len,
{
struct queue_message *qm = message_alloc_and_encode(data, len);
qm->req_clock = req_clock;
// TODO: Add more slack if min_clock is a bit earlier?
qm->min_clock = req_clock;

list_add_tail(&qm->node, &pc->msg_queue);

//TODO: Add queue flush here, or keep in mcu.py?
return 0;
}

Expand Down
11 changes: 5 additions & 6 deletions klippy/mcu.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,10 +269,9 @@ def set_pwm(self, print_time, value, cycle_time=None):
self._sync_channel, data, len(data), clock)
if ret:
raise error("Internal error in pwm send")
#self._mcu.flush_moves(print_time)
self._th.note_synchronous_command(print_time)
return

# Soft pwm update
if cycle_time is None:
cycle_time = self._cycle_time
Expand Down Expand Up @@ -602,10 +601,10 @@ def _connect(self):
ffi_main, ffi_lib = chelper.get_ffi()
self._steppersync = ffi_main.gc(
ffi_lib.steppersync_alloc(self._serial.serialqueue,
self._stepqueues, len(self._stepqueues),
self._sync_channels, len(self._sync_channels),
move_count),
ffi_lib.steppersync_free)
self._stepqueues, len(self._stepqueues),
self._sync_channels, len(self._sync_channels),
move_count),
ffi_lib.steppersync_free)
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)
Expand Down
7 changes: 2 additions & 5 deletions klippy/toolhead.py
Original file line number Diff line number Diff line change
Expand Up @@ -534,12 +534,9 @@ def register_lookahead_callback(self, callback):
last_move.timing_callbacks.append(callback)
def note_synchronous_command(self, kin_time):
self.note_kinematic_activity(kin_time)
# Fixme: will this destroy move queue?
#self._update_move_time(kin_time)

self._update_move_time(kin_time)
# timer will call _flush_handler to check if
# Batch should be sent.
# if not, reschedule.
# Batch should be sent. if not, reschedule.
self.reactor.update_timer(self.flush_timer, self.reactor.NOW)
def note_kinematic_activity(self, kin_time):
self.last_kin_move_time = max(self.last_kin_move_time, kin_time)
Expand Down

0 comments on commit 7b89695

Please sign in to comment.