From 905a3692a295c4834b567da883aa637cd12e4363 Mon Sep 17 00:00:00 2001 From: Rob Giseburt Date: Mon, 18 Nov 2019 16:58:08 -0600 Subject: [PATCH] Catch case where in FEEDHOLD_SYNC and no more moves to clear it Fixes #75 --- g2core/planner.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/g2core/planner.cpp b/g2core/planner.cpp index 8feb4c21..dee2d3b1 100644 --- a/g2core/planner.cpp +++ b/g2core/planner.cpp @@ -593,15 +593,19 @@ bool mp_is_phat_city_time() stat_t mp_planner_callback() { - // Edgge case: If there's no runnable buffer, FEEDHOLD_SYNC will never exit - if (cm->hold_state == FEEDHOLD_SYNC && cm->cycle_type == CYCLE_NONE) { - cm->hold_state = FEEDHOLD_MOTION_STOPPED; - } // Test if the planner has transitioned to an IDLE state - if ((mp_get_planner_buffers(mp) == mp->q.queue_size) && // detect and set IDLE state - (cm->motion_state == MOTION_STOP) && (cm->hold_state == FEEDHOLD_OFF)) { - mp->planner_state = PLANNER_IDLE; - return (STAT_OK); + if (mp_get_planner_buffers(mp) == mp->q.queue_size) { + + // Edgge case: If there's no runnable buffer, FEEDHOLD_SYNC will never exit + if (cm->hold_state == FEEDHOLD_SYNC) { + cm->hold_state = FEEDHOLD_MOTION_STOPPED; + } + + // detect and set IDLE state + if ((cm->motion_state == MOTION_STOP) && (cm->hold_state == FEEDHOLD_OFF)) { + mp->planner_state = PLANNER_IDLE; + return (STAT_OK); + } } bool _timed_out = mp->block_timeout.isPast();