From c7056f5f1fca63eabce3c41ca6d908bb1ed2b561 Mon Sep 17 00:00:00 2001 From: Rob Giseburt Date: Wed, 13 Nov 2019 15:10:36 -0600 Subject: [PATCH] Don't accept input before controller is ready, adjust init alert timing --- g2core/controller.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/g2core/controller.cpp b/g2core/controller.cpp index 86cb3a34..5bae3d38 100644 --- a/g2core/controller.cpp +++ b/g2core/controller.cpp @@ -263,7 +263,7 @@ static void _controller_HSM() static stat_t _dispatch_control() { - if (cs.controller_state != CONTROLLER_PAUSED) { + if (cs.controller_state == CONTROLLER_READY) { devflags_t flags = DEV_IS_CTRL; if ((cs.bufp = xio_readline(flags, cs.linelen)) != NULL) { _dispatch_kernel(flags); @@ -274,11 +274,7 @@ static stat_t _dispatch_control() static stat_t _dispatch_command() { -// #ifdef ENABLE_INTERLOCK_AND_ESTOP -// if (cs.controller_state != CONTROLLER_PAUSED && cm1.estop_state == 0) { -// #else - if (cs.controller_state != CONTROLLER_PAUSED) { -// #endif + if (cs.controller_state == CONTROLLER_READY) { devflags_t flags = DEV_IS_BOTH | DEV_IS_MUTED; // expressly state we'll handle muted devices if ((!mp_planner_is_full(mp)) && (cs.bufp = xio_readline(flags, cs.linelen)) != NULL) { _dispatch_kernel(flags); @@ -422,9 +418,12 @@ static stat_t _controller_state() _connection_timeout.set(10); } #else - _connection_timeout.set(10); + _connection_timeout.set(1); #endif - } else if ((cs.controller_state == CONTROLLER_STARTUP) && (_connection_timeout.isPast())) { // first time through after reset + } + + // first time through after reset + if ((cs.controller_state == CONTROLLER_STARTUP) && (!_connection_timeout.isSet() || _connection_timeout.isPast())) { if (MARLIN_COMM_MODE != js.json_mode) { // MARLIN_COMM_MODE is always defined, just not always used _reset_comms_mode(); }