Browse Source

Fix PFW-1364 & possible comms timeout during reheat

VintagePC 2 years ago
parent
commit
ecef69012a
2 changed files with 16 additions and 6 deletions
  1. 10 4
      Firmware/mmu2.cpp
  2. 6 2
      Firmware/mmu2.h

+ 10 - 4
Firmware/mmu2.cpp

@@ -221,6 +221,13 @@ void MMU2::mmu_loop() {
         return;
     avoidRecursion = true;
 
+    mmu_loop_inner();
+
+    avoidRecursion = false;
+}
+
+void MMU2::mmu_loop_inner()
+{
     logicStepLastStatus = LogicStep(); // it looks like the mmu_loop doesn't need to be a blocking call
 
     if (is_mmu_error_monitor_active){
@@ -228,8 +235,6 @@ void MMU2::mmu_loop() {
         // This includes when mmu_loop is called within manage_response
         ReportErrorHook((uint16_t)lastErrorCode);
     }
-
-    avoidRecursion = false;
 }
 
 void MMU2::CheckFINDARunout()
@@ -630,9 +635,10 @@ void MMU2::ResumeHotendTemp() {
         lcd_display_message_fullscreen_P(_i("MMU Retry: Restoring temperature...")); ////MSG_MMU_RESTORE_TEMP c=20 r=4
         //@todo better report the event and let the GUI do its work somewhere else
         ReportErrorHookSensorLineRender();
-        waitForHotendTargetTemp(1000, []{
-            ReportErrorHookDynamicRender();
+        waitForHotendTargetTemp(100, [this]{
             manage_inactivity(true);
+            this->mmu_loop_inner(); // This keeps the comms alive, the call in manage_inactivity is blocked by recursion guard.
+            ReportErrorHookDynamicRender();
         });
         lcd_update_enable(true); // temporary hack to stop this locking the printer...
         LogEchoEvent_P(PSTR("Hotend temperature reached"));

+ 6 - 2
Firmware/mmu2.h

@@ -226,8 +226,12 @@ private:
     /// Along with the mmu_loop method, this loops until a response from the MMU is received and acts upon.
     /// In case of an error, it parks the print head and turns off nozzle heating
     void manage_response(const bool move_axes, const bool turn_off_nozzle);
-    
-    /// Performs one step of the protocol logic state machine 
+
+    /// The inner private implementation of mmu_loop()
+    /// which is NOT (!!!) recursion-guarded. Use caution - but we do need it during waiting for hotend resume to keep comms alive!
+    void mmu_loop_inner();
+
+    /// Performs one step of the protocol logic state machine
     /// and reports progress and errors if needed to attached ExtUIs.
     /// Updates the global state of MMU (Active/Connecting/Stopped) at runtime, see @ref State
     StepStatus LogicStep();