Browse Source

Increment errors in ReportError

D.R.racer 2 years ago
parent
commit
adb24cd410
2 changed files with 10 additions and 8 deletions
  1. 10 0
      Firmware/mmu2.cpp
  2. 0 8
      Firmware/mmu2_reporting.cpp

+ 10 - 0
Firmware/mmu2.cpp

@@ -880,6 +880,16 @@ void MMU2::ReportError(ErrorCode ec, ErrorSource res) {
         lastErrorCode = ec;
         lastErrorSource = res;
         LogErrorEvent_P( _O(PrusaErrorTitle(PrusaErrorCodeIndex((uint16_t)ec))) );
+
+        if( ec != ErrorCode::OK ){
+            IncrementMMUFails();
+
+            // check if it is a "power" failure - we consider TMC-related errors as power failures
+            if( (uint16_t)ec & 0x7e00 ){ // @@TODO can be optimized to uint8_t operation
+                // TMC-related errors are from 0x8200 higher
+                IncrementTMCFailures();
+            }
+        }
     }
 
     if( !mmu2.RetryIfPossible((uint16_t)ec) ) {

+ 0 - 8
Firmware/mmu2_reporting.cpp

@@ -233,14 +233,6 @@ void ReportErrorHook(uint16_t ec) {
     case (uint8_t)ReportErrorHookStates::RENDER_ERROR_SCREEN:
         ReportErrorHookStaticRender(ei);
         ReportErrorHookState = ReportErrorHookStates::MONITOR_SELECTION;
-        IncrementMMUFails();
-
-        // check if it is a "power" failure - we consider TMC-related errors as power failures
-        if( (uint16_t)ec & 0x7e00 ){ // @@TODO can be optimized to uint8_t operation
-            // TMC-related errors are from 0x8200 higher
-            // we can increment a power error at this spot
-            mmu2.IncrementTMCFailures();
-        }
         [[fallthrough]];
     case (uint8_t)ReportErrorHookStates::MONITOR_SELECTION:
         mmu2.is_mmu_error_monitor_active = true;