From 1336d86de489a3ba5e6171ebe611361edcd956a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gu=C3=B0ni=20M=C3=A1r=20Gilbert?= Date: Sat, 9 Jul 2022 09:53:49 +0000 Subject: [PATCH] PFW-1375 MMU error reported by MK3S does not appear on LCD --- Firmware/mmu2.cpp | 14 +++++++------- Firmware/mmu2.h | 11 +++++++++-- Firmware/mmu2_reporting.cpp | 9 ++------- Firmware/mmu2_reporting.h | 10 ++++++++-- 4 files changed, 26 insertions(+), 18 deletions(-) diff --git a/Firmware/mmu2.cpp b/Firmware/mmu2.cpp index ba9b5216fe..ad073f276f 100644 --- a/Firmware/mmu2.cpp +++ b/Firmware/mmu2.cpp @@ -177,7 +177,7 @@ void MMU2::mmu_loop() { if (is_mmu_error_monitor_active){ // Call this every iteration to keep the knob rotation responsive // This includes when mmu_loop is called within manage_response - ReportErrorHook((uint16_t)lastErrorCode); + ReportErrorHook((uint16_t)lastErrorCode, mmu2.MMUCurrentErrorCode() == ErrorCode::OK ? ErrorSourcePrinter : ErrorSourceMMU); } avoidRecursion = false; @@ -667,22 +667,22 @@ StepStatus MMU2::LogicStep() { OnMMUProgressMsg(logic.Progress()); break; case CommandError: - ReportError(logic.Error()); + ReportError(logic.Error(), ErrorSourceMMU); CheckUserInput(); break; case CommunicationTimeout: state = xState::Connecting; - ReportError(ErrorCode::MMU_NOT_RESPONDING); + ReportError(ErrorCode::MMU_NOT_RESPONDING, ErrorSourcePrinter); CheckUserInput(); break; case ProtocolError: state = xState::Connecting; - ReportError(ErrorCode::PROTOCOL_ERROR); + ReportError(ErrorCode::PROTOCOL_ERROR, ErrorSourcePrinter); CheckUserInput(); break; case VersionMismatch: StopKeepPowered(); - ReportError(ErrorCode::VERSION_MISMATCH); + ReportError(ErrorCode::VERSION_MISMATCH, ErrorSourcePrinter); CheckUserInput(); break; case ButtonPushed: @@ -721,7 +721,7 @@ void MMU2::SetActiveExtruder(uint8_t ex){ active_extruder = ex; } -void MMU2::ReportError(ErrorCode ec) { +void MMU2::ReportError(ErrorCode ec, uint8_t res) { // Due to a potential lossy error reporting layers linked to this hook // we'd better report everything to make sure especially the error states // do not get lost. @@ -733,7 +733,7 @@ void MMU2::ReportError(ErrorCode ec) { // - report only changes of states (we can miss an error message) // - may be some combination of MMUAvailable + UseMMU flags and decide based on their state // Right now the filtering of MMU_NOT_RESPONDING is done in ReportErrorHook() as it is not a problem if mmu2.cpp - ReportErrorHook((uint16_t)ec); + ReportErrorHook((uint16_t)ec, res); if( ec != lastErrorCode ){ // deduplicate: only report changes in error codes into the log lastErrorCode = ec; diff --git a/Firmware/mmu2.h b/Firmware/mmu2.h index 5adb34da17..26caac6cd5 100644 --- a/Firmware/mmu2.h +++ b/Firmware/mmu2.h @@ -66,7 +66,13 @@ class MMU2 { Cooldown = 2, // The extruder was allowed to cool. CooldownPending = 4, }; - + + /// Source of operation error + enum ReportErrorSource: uint8_t { + ErrorSourcePrinter = 0, + ErrorSourceMMU = 1, + }; + /// Perform a reset of the MMU /// @param level physical form of the reset void Reset(ResetForm level); @@ -188,7 +194,8 @@ class MMU2 { /// Reports an error into attached ExtUIs /// @param ec error code, see ErrorCode - void ReportError(ErrorCode ec); + /// @param res reporter error source, is either Printer (0) or MMU (1) + void ReportError(ErrorCode ec, uint8_t res); /// Reports progress of operations into attached ExtUIs /// @param pc progress code, see ProgressCode diff --git a/Firmware/mmu2_reporting.cpp b/Firmware/mmu2_reporting.cpp index 4622703b2c..3ba935da13 100644 --- a/Firmware/mmu2_reporting.cpp +++ b/Firmware/mmu2_reporting.cpp @@ -198,13 +198,8 @@ enum class ReportErrorHookStates : uint8_t { enum ReportErrorHookStates ReportErrorHookState = ReportErrorHookStates::RENDER_ERROR_SCREEN; -/** - * @brief Render MMU error screen on the LCD. This must be non-blocking - * and allow the MMU and printer to communicate with each other. - * @param[in] ec Error code - */ -void ReportErrorHook(uint16_t ec) { - if (mmu2.MMUCurrentErrorCode() == ErrorCode::OK) +void ReportErrorHook(uint16_t ec, uint8_t res) { + if (mmu2.MMUCurrentErrorCode() == ErrorCode::OK && res == MMU2::ErrorSourceMMU) { // If the error code suddenly changes to OK, that means // a button was pushed on the MMU and the LCD should diff --git a/Firmware/mmu2_reporting.h b/Firmware/mmu2_reporting.h index 8cb5317805..7e9fa587fb 100644 --- a/Firmware/mmu2_reporting.h +++ b/Firmware/mmu2_reporting.h @@ -22,8 +22,14 @@ void BeginReport(CommandInProgress cip, uint16_t ec); /// Called at the end of every MMU operation void EndReport(CommandInProgress cip, uint16_t ec); -/// Called when the MMU sends operation error (even repeatedly) -void ReportErrorHook(uint16_t ec); +/** + * @brief Called when the MMU or MK3S sends operation error (even repeatedly). + * Render MMU error screen on the LCD. This must be non-blocking + * and allow the MMU and printer to communicate with each other. + * @param[in] ec error code + * @param[in] res reporter error source, is either Printer (0) or MMU (1) + */ +void ReportErrorHook(uint16_t ec, uint8_t res); /// Called when the MMU sends operation progress update void ReportProgressHook(CommandInProgress cip, uint16_t ec);