diff --git a/Marlin/src/feature/e_parser.h b/Marlin/src/feature/e_parser.h index 8dacb0581c12..78b5cf28ada4 100644 --- a/Marlin/src/feature/e_parser.h +++ b/Marlin/src/feature/e_parser.h @@ -79,6 +79,8 @@ class EmergencyParser { static void update(State &state, const uint8_t c); + static bool isEnabled() { return enabled;} + private: static bool enabled; }; diff --git a/Marlin/src/gcode/control/M108_M112_M410.cpp b/Marlin/src/gcode/control/M108_M112_M410.cpp index 39f9c04e1915..f208d656bc73 100644 --- a/Marlin/src/gcode/control/M108_M112_M410.cpp +++ b/Marlin/src/gcode/control/M108_M112_M410.cpp @@ -21,9 +21,6 @@ */ #include "../../inc/MarlinConfig.h" - -#if DISABLED(EMERGENCY_PARSER) - #include "../gcode.h" #include "../../MarlinCore.h" // for wait_for_heatup, kill, M112_KILL_STR #include "../../module/motion.h" // for quickstop_stepper @@ -53,4 +50,3 @@ void GcodeSuite::M410() { quickstop_stepper(); } -#endif // !EMERGENCY_PARSER diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp index 1ff643dc2174..a9520905abef 100644 --- a/Marlin/src/gcode/gcode.cpp +++ b/Marlin/src/gcode/gcode.cpp @@ -585,17 +585,11 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) { case 110: M110(); break; // M110: Set Current Line Number case 111: M111(); break; // M111: Set debug level - #if DISABLED(EMERGENCY_PARSER) - case 108: M108(); break; // M108: Cancel Waiting - case 112: M112(); break; // M112: Full Shutdown - case 410: M410(); break; // M410: Quickstop - Abort all the planned moves. - #if ENABLED(HOST_PROMPT_SUPPORT) - case 876: M876(); break; // M876: Handle Host prompt responses - #endif - #else - case 108: case 112: case 410: - TERN_(HOST_PROMPT_SUPPORT, case 876:) - break; + case 108: M108(); break; // M108: Cancel Waiting + case 112: M112(); break; // M112: Full Shutdown + case 410: M410(); break; // M410: Quickstop - Abort all the planned moves. + #if ENABLED(HOST_PROMPT_SUPPORT) + case 876: M876(); break; // M876: Handle Host prompt responses #endif #if ENABLED(HOST_KEEPALIVE_FEATURE) diff --git a/Marlin/src/gcode/gcode.h b/Marlin/src/gcode/gcode.h index 8004187903dd..caf7511ea0b3 100644 --- a/Marlin/src/gcode/gcode.h +++ b/Marlin/src/gcode/gcode.h @@ -751,13 +751,11 @@ class GcodeSuite { static void M107(); #endif - #if DISABLED(EMERGENCY_PARSER) - static void M108(); - static void M112(); - static void M410(); - #if ENABLED(HOST_PROMPT_SUPPORT) - static void M876(); - #endif + static void M108(); + static void M112(); + static void M410(); + #if ENABLED(HOST_PROMPT_SUPPORT) + static void M876(); #endif static void M110(); diff --git a/Marlin/src/gcode/host/M876.cpp b/Marlin/src/gcode/host/M876.cpp index c2a519d0ac60..691a379434fe 100644 --- a/Marlin/src/gcode/host/M876.cpp +++ b/Marlin/src/gcode/host/M876.cpp @@ -24,6 +24,9 @@ #if HAS_GCODE_M876 +#if ENABLED(EMERGENCY_PARSER) + #include "../../feature/e_parser.h" +#endif #include "../../feature/host_actions.h" #include "../gcode.h" #include "../../MarlinCore.h" @@ -32,8 +35,8 @@ * M876: Handle Prompt Response */ void GcodeSuite::M876() { - - if (parser.seenval('S')) hostui.handle_response((uint8_t)parser.value_int()); + if(TERN1(EMERGENCY_PARSER, emergency_parser.isEnabled())) + if (parser.seenval('S')) hostui.handle_response((uint8_t)parser.value_int()); } diff --git a/Marlin/src/gcode/queue.cpp b/Marlin/src/gcode/queue.cpp index 6b34a3b46b04..aa27378b4600 100644 --- a/Marlin/src/gcode/queue.cpp +++ b/Marlin/src/gcode/queue.cpp @@ -535,14 +535,12 @@ void GCodeQueue::get_serial_commands() { } } - #if DISABLED(EMERGENCY_PARSER) - // Process critical commands early - if (command[0] == 'M') switch (command[3]) { - case '8': if (command[2] == '0' && command[1] == '1') { wait_for_heatup = false; TERN_(HAS_MARLINUI_MENU, wait_for_user = false); } break; - case '2': if (command[2] == '1' && command[1] == '1') kill(FPSTR(M112_KILL_STR), nullptr, true); break; - case '0': if (command[1] == '4' && command[2] == '1') quickstop_stepper(); break; - } - #endif + // Process critical commands early + if (command[0] == 'M') switch (command[3]) { + case '8': if (command[2] == '0' && command[1] == '1') { wait_for_heatup = false; TERN_(HAS_MARLINUI_MENU, wait_for_user = false); } break; + case '2': if (command[2] == '1' && command[1] == '1') kill(FPSTR(M112_KILL_STR), nullptr, true); break; + case '0': if (command[1] == '4' && command[2] == '1') quickstop_stepper(); break; + } #if NO_TIMEOUTS > 0 last_command_time = ms; diff --git a/Marlin/src/inc/Conditionals_adv.h b/Marlin/src/inc/Conditionals_adv.h index aa55731d90ab..ada0ce6437d2 100644 --- a/Marlin/src/inc/Conditionals_adv.h +++ b/Marlin/src/inc/Conditionals_adv.h @@ -1027,7 +1027,7 @@ #undef SERIAL_XON_XOFF #endif -#if ENABLED(HOST_PROMPT_SUPPORT) && DISABLED(EMERGENCY_PARSER) +#if ENABLED(HOST_PROMPT_SUPPORT) #define HAS_GCODE_M876 1 #endif diff --git a/ini/features.ini b/ini/features.ini index 1100216867bb..00f7fd0aab77 100644 --- a/ini/features.ini +++ b/ini/features.ini @@ -232,7 +232,7 @@ USE_CONTROLLER_FAN = build_src_filter=+ HAS_MOTOR_CURRENT_DAC = build_src_filter=+ DIRECT_STEPPING = build_src_filter=+ + -EMERGENCY_PARSER = build_src_filter=+ - +EMERGENCY_PARSER = build_src_filter=+ EASYTHREED_UI = build_src_filter=+ I2C_POSITION_ENCODERS = build_src_filter=+ IIC_BL24CXX_EEPROM = build_src_filter=+