From 8a1df52d79ec19328e05e69dbb54caff1e9d843f Mon Sep 17 00:00:00 2001 From: "D.R.racer" Date: Mon, 26 Jul 2021 08:45:27 +0200 Subject: [PATCH] Add support for reporting MMU errors via S3 msg --- src/main.cpp | 5 +++++ src/modules/globals.cpp | 8 ++++++++ src/modules/globals.h | 7 +++++++ 3 files changed, 20 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index 1f01c52..38ff65f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -190,6 +190,11 @@ void ReportVersion(const mp::RequestMsg &rq) { case 2: v = project_version_revision; break; + case 3: + // @@TODO may be allow reporting uint16_t number of errors, + // but anything beyond 255 errors means there is something seriously wrong with the MMU + v = mg::globals.DriveErrors(); + break; default: v = 0; break; diff --git a/src/modules/globals.cpp b/src/modules/globals.cpp index ac9649c..eaf86b7 100644 --- a/src/modules/globals.cpp +++ b/src/modules/globals.cpp @@ -28,5 +28,13 @@ void Globals::SetFilamentLoaded(bool newFilamentLoaded) { filamentLoaded = newFilamentLoaded; } +uint16_t Globals::DriveErrors() const { + return modules::permanent_storage::DriveError::get(); +} + +void Globals::IncDriveErrors() { + modules::permanent_storage::DriveError::increment(); +} + } // namespace globals } // namespace modules diff --git a/src/modules/globals.h b/src/modules/globals.h index f164c04..d64176c 100644 --- a/src/modules/globals.h +++ b/src/modules/globals.h @@ -33,6 +33,13 @@ public: /// @param newFilamentLoaded new state void SetFilamentLoaded(bool newFilamentLoaded); + /// @returns the total number of MMU errors so far + /// Errors are stored in the EEPROM + uint16_t DriveErrors() const; + + /// Increment MMU errors by 1 + void IncDriveErrors(); + private: uint8_t activeSlot; bool filamentLoaded;