From adb24cd410f591fc9c674ca1a9abcca4314727c8 Mon Sep 17 00:00:00 2001 From: "D.R.racer" Date: Sat, 19 Nov 2022 15:34:16 +0100 Subject: [PATCH] Increment errors in ReportError --- Firmware/mmu2.cpp | 10 ++++++++++ Firmware/mmu2_reporting.cpp | 8 -------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Firmware/mmu2.cpp b/Firmware/mmu2.cpp index baa43ede1..c36943a06 100644 --- a/Firmware/mmu2.cpp +++ b/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) ) { diff --git a/Firmware/mmu2_reporting.cpp b/Firmware/mmu2_reporting.cpp index eae3ef8ab..c45b8fd7c 100644 --- a/Firmware/mmu2_reporting.cpp +++ b/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;