From c5aea89cac0261f0c56d1e64aac8fec79b666431 Mon Sep 17 00:00:00 2001 From: "D.R.racer" Date: Wed, 4 May 2022 10:23:12 +0200 Subject: [PATCH] Report FINDA/EEPROM disrepancy to the printer --- src/logic/error_codes.h | 2 ++ src/logic/no_command.h | 5 +++++ src/main.cpp | 3 +++ 3 files changed, 10 insertions(+) diff --git a/src/logic/error_codes.h b/src/logic/error_codes.h index 1b49589..bc495f9 100644 --- a/src/logic/error_codes.h +++ b/src/logic/error_codes.h @@ -39,6 +39,8 @@ enum class ErrorCode : uint_fast16_t { HOMING_IDLER_FAILED = HOMING_FAILED | TMC_IDLER_BIT, ///< E33031 the Idler was unable to home properly - that means something is blocking its movement STALLED_PULLEY = HOMING_FAILED | TMC_PULLEY_BIT, ///< E32839 for the Pulley "homing" means just stallguard detected during Pulley's operation (Pulley doesn't home) + FINDA_VS_EEPROM_DISREPANCY = 0x8008, ///< E32776 FINDA is pressed but we have no such record in EEPROM - this can only happen at the start of the MMU and can be resolved by issuing an Unload command + QUEUE_FULL = 0x802b, ///< E32811 internal logic error - attempt to move with a full queue VERSION_MISMATCH = 0x802c, ///< E32812 internal error of the printer - incompatible version of the MMU FW diff --git a/src/logic/no_command.h b/src/logic/no_command.h index 005bd3b..2064b3a 100644 --- a/src/logic/no_command.h +++ b/src/logic/no_command.h @@ -16,6 +16,11 @@ public: /// @returns true if the state machine finished its job, false otherwise bool StepInner() override { return true; } + + /// Used to report initialization errors (which can be reported if the UART started up). + /// Intentionally only available in the "noCommand" operation + /// which is only active when the MMU starts and before it gets any other command from the printer. + inline void SetInitError(ErrorCode ec) { error = ec; } }; /// The one and only instance of NoCommand state machine in the FW diff --git a/src/main.cpp b/src/main.cpp index 438b9f4..769441f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -27,6 +27,8 @@ #include "application.h" +#include "logic/no_command.h" + /// One-time setup of HW and SW components /// Called before entering the loop() function /// Green LEDs signalize the progress of initialization. If anything goes wrong we shall turn on a red LED @@ -90,6 +92,7 @@ void setup() { // For this we speculatively set the active slot to 2 (in the middle ;) ) // Ideally this should be signalled as an error state and displayed on the printer and recovered properly. mg::globals.SetFilamentLoaded(2, mg::InFSensor); + logic::noCommand.SetInitError(ErrorCode::FINDA_VS_EEPROM_DISREPANCY); } /// Turn off all leds