From bca0f55a5e83d9f8325b9395b168ccbf3939c2c1 Mon Sep 17 00:00:00 2001 From: InsanityAutomation Date: Sun, 7 Apr 2024 13:13:15 -0400 Subject: [PATCH] Always parse safety commands at all levels --- Marlin/src/feature/e_parser.h | 1 - Marlin/src/gcode/control/M108_M112_M410.cpp | 4 ---- Marlin/src/gcode/gcode.cpp | 16 +++++----------- Marlin/src/gcode/gcode.h | 12 +++++------- Marlin/src/gcode/host/M876.cpp | 7 +++++-- Marlin/src/gcode/queue.cpp | 14 ++++++-------- ini/features.ini | 2 +- 7 files changed, 22 insertions(+), 34 deletions(-) diff --git a/Marlin/src/feature/e_parser.h b/Marlin/src/feature/e_parser.h index 8dacb0581c..665dd708b8 100644 --- a/Marlin/src/feature/e_parser.h +++ b/Marlin/src/feature/e_parser.h @@ -79,7 +79,6 @@ public: static void update(State &state, const uint8_t c); -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 39f9c04e19..f208d656bc 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 1ff643dc21..a9520905ab 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 8004187903..caf7511ea0 100644 --- a/Marlin/src/gcode/gcode.h +++ b/Marlin/src/gcode/gcode.h @@ -751,13 +751,11 @@ private: 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 c2a519d0ac..2a8a5fadd0 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.enabled)) + 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 6b34a3b46b..aa27378b46 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/ini/features.ini b/ini/features.ini index 1100216867..00f7fd0aab 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=+