From b63e3ab7910446a63d6174c6a15ccb44f9773a63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arkadiusz=20Mi=C5=9Bkiewicz?= Date: Sun, 18 Sep 2022 03:51:37 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=B8=20Emergency=20Parse=20M524=20(#247?= =?UTF-8?q?61)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/feature/e_parser.cpp | 3 +++ Marlin/src/feature/e_parser.h | 20 +++++++++++++++++++- Marlin/src/module/temperature.cpp | 6 ++++++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/Marlin/src/feature/e_parser.cpp b/Marlin/src/feature/e_parser.cpp index d98afcfee71b..cfe0956aa789 100644 --- a/Marlin/src/feature/e_parser.cpp +++ b/Marlin/src/feature/e_parser.cpp @@ -33,6 +33,9 @@ // Static data members bool EmergencyParser::killed_by_M112, // = false EmergencyParser::quickstop_by_M410, + #if ENABLED(SDSUPPORT) + EmergencyParser::sd_abort_by_M524, + #endif EmergencyParser::enabled; #if ENABLED(HOST_PROMPT_SUPPORT) diff --git a/Marlin/src/feature/e_parser.h b/Marlin/src/feature/e_parser.h index bd17659a1e0f..9a3877d8095b 100644 --- a/Marlin/src/feature/e_parser.h +++ b/Marlin/src/feature/e_parser.h @@ -51,7 +51,7 @@ class EmergencyParser { public: - // Currently looking for: M108, M112, M410, M876 S[0-9], S000, P000, R000 + // Currently looking for: M108, M112, M410, M524, M876 S[0-9], S000, P000, R000 enum State : uint8_t { EP_RESET, EP_N, @@ -60,6 +60,9 @@ class EmergencyParser { EP_M10, EP_M108, EP_M11, EP_M112, EP_M4, EP_M41, EP_M410, + #if ENABLED(SDSUPPORT) + EP_M5, EP_M52, EP_M524, + #endif #if ENABLED(HOST_PROMPT_SUPPORT) EP_M8, EP_M87, EP_M876, EP_M876S, EP_M876SN, #endif @@ -78,6 +81,10 @@ class EmergencyParser { static bool killed_by_M112; static bool quickstop_by_M410; + #if ENABLED(SDSUPPORT) + static bool sd_abort_by_M524; + #endif + #if ENABLED(HOST_PROMPT_SUPPORT) static uint8_t M876_reason; #endif @@ -147,6 +154,9 @@ class EmergencyParser { case ' ': break; case '1': state = EP_M1; break; case '4': state = EP_M4; break; + #if ENABLED(SDSUPPORT) + case '5': state = EP_M5; break; + #endif #if ENABLED(HOST_PROMPT_SUPPORT) case '8': state = EP_M8; break; #endif @@ -167,6 +177,11 @@ class EmergencyParser { case EP_M4: state = (c == '1') ? EP_M41 : EP_IGNORE; break; case EP_M41: state = (c == '0') ? EP_M410 : EP_IGNORE; break; + #if ENABLED(SDSUPPORT) + case EP_M5: state = (c == '2') ? EP_M52 : EP_IGNORE; break; + case EP_M52: state = (c == '4') ? EP_M524 : EP_IGNORE; break; + #endif + #if ENABLED(HOST_PROMPT_SUPPORT) case EP_M8: state = (c == '7') ? EP_M87 : EP_IGNORE; break; @@ -202,6 +217,9 @@ class EmergencyParser { case EP_M108: wait_for_user = wait_for_heatup = false; print_job_timer.heating_stop(); break; case EP_M112: killed_by_M112 = true; break; case EP_M410: quickstop_by_M410 = true; break; + #if ENABLED(SDSUPPORT) + case EP_M524: sd_abort_by_M524 = true; break; + #endif #if ENABLED(HOST_PROMPT_SUPPORT) case EP_M876SN: hostui.handle_response(M876_reason); break; #endif diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 0b2259c87a8d..7f2ed8172d21 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -1863,6 +1863,12 @@ void Temperature::task() { emergency_parser.quickstop_by_M410 = false; // quickstop_stepper may call idle so clear this now! quickstop_stepper(); } + + 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")); + } #endif if (!updateTemperaturesIfReady()) return; // Will also reset the watchdog if temperatures are ready