From fb9dba543c4084ca6cd03673f503539a9013832b Mon Sep 17 00:00:00 2001 From: Victor Mateus Oliveira Date: Thu, 15 Oct 2020 11:52:45 -0300 Subject: [PATCH 1/3] Handle M410 out of the UART IQR, as other EP commands. Running inside an IRQ dont work, because all other IRQ will stay blocked until that code returns, and it will prevent temp timer to run, that M410 depends to finish. --- Marlin/src/MarlinCore.cpp | 12 ++++++++++++ Marlin/src/feature/e_parser.cpp | 1 + Marlin/src/feature/e_parser.h | 3 ++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index 3a20cf3ee330..519304999d3a 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -221,6 +221,10 @@ #include "feature/password/password.h" #endif +#if ENABLED(EMERGENCY_PARSER) + #include "feature/e_parser.h" +#endif + PGMSTR(NUL_STR, ""); PGMSTR(M112_KILL_STR, "M112 Shutdown"); PGMSTR(G28_STR, "G28"); @@ -776,6 +780,14 @@ void idle(TERN_(ADVANCED_PAUSE_FEATURE, bool no_stepper_sleep/*=false*/)) { #if HAS_TFT_LVGL_UI LV_TASK_HANDLER(); #endif + + #if ENABLED(EMERGENCY_PARSER) + if (emergency_parser.quickstop_by_M410) { + // quickstop_stepper will call idle, so we must set it to false to avoid infinite loop + emergency_parser.quickstop_by_M410 = false; + quickstop_stepper(); + } + #endif } /** diff --git a/Marlin/src/feature/e_parser.cpp b/Marlin/src/feature/e_parser.cpp index a4c2d0dac92c..d98afcfee71b 100644 --- a/Marlin/src/feature/e_parser.cpp +++ b/Marlin/src/feature/e_parser.cpp @@ -32,6 +32,7 @@ // Static data members bool EmergencyParser::killed_by_M112, // = false + EmergencyParser::quickstop_by_M410, EmergencyParser::enabled; #if ENABLED(HOST_PROMPT_SUPPORT) diff --git a/Marlin/src/feature/e_parser.h b/Marlin/src/feature/e_parser.h index 085cbd4eab0e..0bb0253149eb 100644 --- a/Marlin/src/feature/e_parser.h +++ b/Marlin/src/feature/e_parser.h @@ -63,6 +63,7 @@ class EmergencyParser { }; static bool killed_by_M112; + static bool quickstop_by_M410; #if ENABLED(HOST_PROMPT_SUPPORT) static uint8_t M876_reason; @@ -168,7 +169,7 @@ class EmergencyParser { if (enabled) switch (state) { case EP_M108: wait_for_user = wait_for_heatup = false; break; case EP_M112: killed_by_M112 = true; break; - case EP_M410: quickstop_stepper(); break; + case EP_M410: quickstop_by_M410 = true; break; #if ENABLED(HOST_PROMPT_SUPPORT) case EP_M876SN: host_response_handler(M876_reason); break; #endif From c97d19febc539848f70332fabd0f051f34680d73 Mon Sep 17 00:00:00 2001 From: Victor Mateus Oliveira Date: Thu, 15 Oct 2020 12:35:57 -0300 Subject: [PATCH 2/3] moved to temp.manage_heater, as M112 is alread handled --- Marlin/src/MarlinCore.cpp | 12 ------------ Marlin/src/module/temperature.cpp | 11 +++++++++-- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index 519304999d3a..3a20cf3ee330 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -221,10 +221,6 @@ #include "feature/password/password.h" #endif -#if ENABLED(EMERGENCY_PARSER) - #include "feature/e_parser.h" -#endif - PGMSTR(NUL_STR, ""); PGMSTR(M112_KILL_STR, "M112 Shutdown"); PGMSTR(G28_STR, "G28"); @@ -780,14 +776,6 @@ void idle(TERN_(ADVANCED_PAUSE_FEATURE, bool no_stepper_sleep/*=false*/)) { #if HAS_TFT_LVGL_UI LV_TASK_HANDLER(); #endif - - #if ENABLED(EMERGENCY_PARSER) - if (emergency_parser.quickstop_by_M410) { - // quickstop_stepper will call idle, so we must set it to false to avoid infinite loop - emergency_parser.quickstop_by_M410 = false; - quickstop_stepper(); - } - #endif } /** diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 9ecbb7c766fd..1a4558e06655 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -1032,8 +1032,15 @@ void Temperature::manage_heater() { if (!inited) return watchdog_refresh(); #endif - if (TERN0(EMERGENCY_PARSER, emergency_parser.killed_by_M112)) - kill(M112_KILL_STR, nullptr, true); + #if ENABLED(EMERGENCY_PARSER) + if (emergency_parser.killed_by_M112) kill(M112_KILL_STR, nullptr, true); + + if (emergency_parser.quickstop_by_M410) { + // quickstop_stepper will call idle, so we must set it to false to avoid infinite loop + emergency_parser.quickstop_by_M410 = false; + quickstop_stepper(); + } + #endif if (!raw_temps_ready) return; From 10ff04374f854572c512befbb8e3582ff4970575 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 16 Oct 2020 16:07:21 -0500 Subject: [PATCH 3/3] Update temperature.cpp --- Marlin/src/module/temperature.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 1a4558e06655..4b352e738e36 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -1036,8 +1036,7 @@ void Temperature::manage_heater() { if (emergency_parser.killed_by_M112) kill(M112_KILL_STR, nullptr, true); if (emergency_parser.quickstop_by_M410) { - // quickstop_stepper will call idle, so we must set it to false to avoid infinite loop - emergency_parser.quickstop_by_M410 = false; + emergency_parser.quickstop_by_M410 = false; // quickstop_stepper may call idle so clear this now! quickstop_stepper(); } #endif