From f76dec86d2fc9e5fa37d645ea0b96358adbfb04f Mon Sep 17 00:00:00 2001 From: Rob Giseburt Date: Mon, 6 Feb 2017 16:52:38 -0600 Subject: [PATCH] Marlin: Better handling of startup, correction to last commit --- g2core/controller.cpp | 4 ++-- g2core/controller.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/g2core/controller.cpp b/g2core/controller.cpp index 718e71e5..2117a860 100755 --- a/g2core/controller.cpp +++ b/g2core/controller.cpp @@ -233,7 +233,6 @@ static void _dispatch_kernel(const devflags_t flags) #if MARLIN_COMPAT_ENABLED == true // marlin_handle_fake_stk500 returns true if it responded to a stk500v2 message if (marlin_handle_fake_stk500(cs.bufp)) { - cs.comm_mode = MARLIN_COMM_MODE; js.json_mode = MARLIN_COMM_MODE; sr.status_report_verbosity = SR_OFF; @@ -350,7 +349,7 @@ static stat_t _controller_state() _connection_timeout.set(10); #endif } else if ((cs.controller_state == CONTROLLER_STARTUP) && (_connection_timeout.isPast())) { // first time through after reset - if (cs.comm_mode != MARLIN_COMM_MODE) { // MARLIN_COMM_MODE is always defined, just not always used + if (js.json_mode != MARLIN_COMM_MODE) { // MARLIN_COMM_MODE is always defined, just not always used _reset_comms_mode(); } cs.controller_state = CONTROLLER_READY; @@ -372,6 +371,7 @@ void controller_set_connected(bool is_connected) { if (is_connected) { cs.controller_state = CONTROLLER_CONNECTED; // we JUST connected } else { // we just disconnected from the last device, we'll expect a banner again + _reset_comms_mode(); cs.controller_state = CONTROLLER_NOT_CONNECTED; } } diff --git a/g2core/controller.h b/g2core/controller.h index d040590c..7c6e3078 100755 --- a/g2core/controller.h +++ b/g2core/controller.h @@ -64,7 +64,7 @@ typedef struct controllerSingleton { // main TG controller struct uint32_t led_blink_rate; // used to flash indicator LED // communications state variables - // cs.comm_mode is the setting for the communications more + // cs.comm_mode is the setting for the communications mode // js.json_mode is the actual current mode (see also js.json_now) commMode comm_mode; // ej: 0=text mode sticky, 1=JSON mode sticky, 2=auto mode commMode comm_request_mode; // mode of request (may be different thatn the setting)