🚸 Extra parsing of safety commands (#26944)

Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
This commit is contained in:
InsanityAutomation
2025-12-02 16:12:35 -05:00
committed by GitHub
parent 333608a692
commit bfe9885603
11 changed files with 36 additions and 41 deletions

View File

@@ -86,6 +86,8 @@ public:
static void update(State &state, const uint8_t c);
static bool isEnabled() { return enabled; }
private:
static bool enabled;
};

View File

@@ -298,10 +298,10 @@ bool load_filament(const float slow_load_length/*=0*/, const float fast_load_len
// Show "Purge More" / "Resume" menu and wait for reply
KEEPALIVE_STATE(PAUSED_FOR_USER);
marlin.user_resume();
pause_menu_response = PAUSE_RESPONSE_WAIT_FOR;
#if ANY(HAS_MARLINUI_MENU, EXTENSIBLE_UI)
ui.pause_show_message(PAUSE_MESSAGE_OPTION); // MarlinUI and MKS UI also set PAUSE_RESPONSE_WAIT_FOR
#else
pause_menu_response = PAUSE_RESPONSE_WAIT_FOR;
TERN_(SOVOL_SV06_RTS, rts.gotoPage(ID_PurgeMore_L, ID_PurgeMore_D));
#endif
while (pause_menu_response == PAUSE_RESPONSE_WAIT_FOR) marlin.idle_no_sleep();

View File

@@ -21,9 +21,6 @@
*/
#include "../../inc/MarlinConfig.h"
#if DISABLED(EMERGENCY_PARSER)
#include "../gcode.h"
#include "../../module/motion.h" // for quickstop_stepper
@@ -50,5 +47,3 @@ void GcodeSuite::M112() {
void GcodeSuite::M410() {
quickstop_stepper();
}
#endif // !EMERGENCY_PARSER

View File

@@ -597,17 +597,11 @@ void GcodeSuite::process_parsed_command(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)

View File

@@ -140,7 +140,7 @@
* M105 - Report current temperatures.
* M106 - Set print fan speed.
* M107 - Print fan off.
* M108 - Break out of heating loops (M109, M190, M303). With no controller, breaks out of M0/M1. (Requires EMERGENCY_PARSER)
* M108 - Break out of heating loops (M109, M190, M303). With no controller, breaks out of M0/M1.
* M109 - S<temp> Wait for extruder current temp to reach target temp. ** Wait only when heating! **
* R<temp> Wait for extruder current temp to reach target temp. ** Wait for heating or cooling. **
* If AUTOTEMP is enabled, S<mintemp> B<maxtemp> F<factor>. Exit autotemp by any M109 without F
@@ -310,7 +310,7 @@
* M869 - Report position encoder module error.
*
* M871 - Print/Reset/Clear first layer temperature offset values. (Requires PTC_PROBE, PTC_BED, or PTC_HOTEND)
* M876 - Handle Prompt Response. (Requires HOST_PROMPT_SUPPORT and not EMERGENCY_PARSER)
* M876 - Handle Prompt Response. (Requires HOST_PROMPT_SUPPORT)
* M900 - Set / Report Linear Advance K-factor (Requires LIN_ADVANCE or FT_MOTION) and Smoothing Tau factor (Requires SMOOTH_LIN_ADVANCE).
* M906 - Set / Report motor current in milliamps using axis codes XYZE, etc. Report values if no axis codes given. (Requires *_DRIVER_TYPE TMC(2130|2160|5130|5160|2208|2209|2240|2660))
* M907 - Set digital trimpot motor current using axis codes. (Requires a board with digital trimpots)
@@ -354,6 +354,7 @@
*/
#include "../inc/MarlinConfig.h"
#include "../module/temperature.h"
#include "parser.h"
#if ENABLED(I2C_POSITION_ENCODERS)
@@ -382,6 +383,9 @@ typedef bits_t(NUM_REL_MODES) relative_t;
extern const char G28_STR[];
class GcodeSuite {
friend void Temperature::task();
public:
static relative_t axis_relative;
@@ -785,13 +789,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();

View File

@@ -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"

View File

@@ -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') { marlin.end_waiting(); } break;
case '2': if (command[2] == '1' && command[1] == '1') marlin.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') { marlin.end_waiting(); } break;
case '2': if (command[2] == '1' && command[1] == '1') marlin.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;

View File

@@ -1136,7 +1136,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

View File

@@ -2317,19 +2317,18 @@ void Temperature::task() {
REMEMBER(mh, no_reentry, true);
#if ENABLED(EMERGENCY_PARSER)
if (emergency_parser.killed_by_M112)
marlin.kill(FPSTR(M112_KILL_STR), nullptr, true);
if (emergency_parser.killed_by_M112) gcode.M112();
if (emergency_parser.quickstop_by_M410) {
emergency_parser.quickstop_by_M410 = false; // quickstop_stepper may call idle so clear this now!
quickstop_stepper();
gcode.M410();
}
#if HAS_MEDIA
if (emergency_parser.sd_abort_by_M524) { // abort SD print immediately
emergency_parser.sd_abort_by_M524 = false;
card.flag.abort_sd_printing = true;
gcode.process_subcommands_now(F("M524"));
gcode.M524();
}
#endif
#endif

View File

@@ -1103,7 +1103,9 @@ void CardReader::closefile(const bool store_location/*=false*/) {
flag.saving = flag.logging = false;
sdpos = 0;
TERN_(EMERGENCY_PARSER, emergency_parser.enable());
#if DISABLED(SDCARD_READONLY)
TERN_(EMERGENCY_PARSER, emergency_parser.enable());
#endif
if (store_location) {
// TODO: Store printer state, filename, position

View File

@@ -233,7 +233,7 @@ USE_CONTROLLER_FAN = build_src_filter=+<src/feature/controll
HAS_COOLER|LASER_COOLANT_FLOW_METER = build_src_filter=+<src/feature/cooler.cpp>
HAS_MOTOR_CURRENT_DAC = build_src_filter=+<src/feature/dac>
DIRECT_STEPPING = build_src_filter=+<src/feature/direct_stepping.cpp> +<src/gcode/motion/G6.cpp>
EMERGENCY_PARSER = build_src_filter=+<src/feature/e_parser.cpp> -<src/gcode/control/M108_*.cpp>
EMERGENCY_PARSER = build_src_filter=+<src/feature/e_parser.cpp>
EASYTHREED_UI = build_src_filter=+<src/feature/easythreed_ui.cpp>
I2C_POSITION_ENCODERS = build_src_filter=+<src/feature/encoder_i2c.cpp>
IIC_BL24CXX_EEPROM = build_src_filter=+<src/libs/BL24CXX.cpp>