Skip to content

Commit

Permalink
🚸 Warning alerts for non-fatal errors (MarlinFirmware#26306)
Browse files Browse the repository at this point in the history
Co-authored-by: Scott Lahteine <[email protected]>
  • Loading branch information
2 people authored and EvilGremlin committed Oct 26, 2023
1 parent 7a1c71f commit 619493a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
4 changes: 4 additions & 0 deletions Marlin/src/core/debug_out.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@

#define DEBUG_ECHO_START SERIAL_ECHO_START
#define DEBUG_ERROR_START SERIAL_ERROR_START
#define DEBUG_WARN_START SERIAL_WARN_START
#define DEBUG_CHAR SERIAL_CHAR
#define DEBUG_ECHO SERIAL_ECHO
#define DEBUG_ECHOLN SERIAL_ECHOLN
Expand All @@ -63,6 +64,7 @@
#define DEBUG_ECHOLNPGM_P SERIAL_ECHOLNPGM_P
#define DEBUG_ECHO_MSG SERIAL_ECHO_MSG
#define DEBUG_ERROR_MSG SERIAL_ERROR_MSG
#define DEBUG_WARN_MSG SERIAL_WARN_MSG
#define DEBUG_EOL SERIAL_EOL
#define DEBUG_FLUSH SERIAL_FLUSH
#define DEBUG_POS SERIAL_POS
Expand All @@ -75,6 +77,7 @@
#define DEBUG_SECTION(...) NOOP
#define DEBUG_ECHO_START() NOOP
#define DEBUG_ERROR_START() NOOP
#define DEBUG_WARN_START() NOOP
#define DEBUG_CHAR(...) NOOP
#define DEBUG_ECHO(...) NOOP
#define DEBUG_ECHOLN(...) NOOP
Expand All @@ -84,6 +87,7 @@
#define DEBUG_ECHOLNPGM_P(...) NOOP
#define DEBUG_ECHO_MSG(...) NOOP
#define DEBUG_ERROR_MSG(...) NOOP
#define DEBUG_WARN_MSG(...) NOOP
#define DEBUG_EOL() NOOP
#define DEBUG_FLUSH() NOOP
#define DEBUG_POS(...) NOOP
Expand Down
1 change: 1 addition & 0 deletions Marlin/src/core/serial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ void SERIAL_ECHOLN_P(PGM_P pstr) { SERIAL_ECHO_P(pstr); SERIAL_EOL(); }

void SERIAL_ECHO_START() { SERIAL_ECHO(F("echo:")); }
void SERIAL_ERROR_START() { SERIAL_ECHO(F("Error:")); }
void SERIAL_WARN_START() { SERIAL_ECHO(F("Warning:")); }

void SERIAL_ECHO_SP(uint8_t count) { count *= (PROPORTIONAL_FONT_RATIO); while (count--) SERIAL_CHAR(' '); }

Expand Down
2 changes: 2 additions & 0 deletions Marlin/src/core/serial.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ void SERIAL_FLUSHTX();
// Start an echo: or error: output
void SERIAL_ECHO_START();
void SERIAL_ERROR_START();
void SERIAL_WARN_START();

// Serial end-of-line
void SERIAL_EOL();
Expand Down Expand Up @@ -227,6 +228,7 @@ void SERIAL_ECHOLN(T arg1, Args ... args) { SERIAL_ECHO(arg1); SERIAL_ECHO(args

#define SERIAL_ECHO_MSG(V...) do{ SERIAL_ECHO_START(); SERIAL_ECHOLNPGM(V); }while(0)
#define SERIAL_ERROR_MSG(V...) do{ SERIAL_ERROR_START(); SERIAL_ECHOLNPGM(V); }while(0)
#define SERIAL_WARN_MSG(V...) do{ SERIAL_WARN_START(); SERIAL_ECHOLNPGM(V); }while(0)

// Print a prefix, conditional string, and suffix
void serial_ternary(FSTR_P const pre, const bool onoff, FSTR_P const on, FSTR_P const off, FSTR_P const post=nullptr);
Expand Down
10 changes: 5 additions & 5 deletions Marlin/src/module/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,7 @@ void MarlinSettings::postprocess() {

#if ENABLED(EEPROM_SETTINGS)

#define EEPROM_ASSERT(TST,ERR) do{ if (!(TST)) { SERIAL_ERROR_MSG(ERR); eeprom_error = ERR_EEPROM_SIZE; } }while(0)
#define EEPROM_ASSERT(TST,ERR) do{ if (!(TST)) { SERIAL_WARN_MSG(ERR); eeprom_error = ERR_EEPROM_SIZE; } }while(0)

#define TWO_BYTE_HASH(A,B) uint16_t((uint16_t(A ^ 0xC3) << 4) ^ (uint16_t(B ^ 0xC3) << 12))

Expand Down Expand Up @@ -796,7 +796,7 @@ void MarlinSettings::postprocess() {

EEPROM_Error MarlinSettings::size_error(const uint16_t size) {
if (size != datasize()) {
DEBUG_ERROR_MSG("EEPROM datasize error."
DEBUG_WARN_MSG("EEPROM datasize error."
#if ENABLED(MARLIN_DEV_MODE)
" (Actual:", size, " Expected:", datasize(), ")"
#endif
Expand Down Expand Up @@ -2865,10 +2865,10 @@ void MarlinSettings::postprocess() {
DEBUG_ECHO_MSG("Index: ", eeprom_index - (EEPROM_OFFSET), " Size: ", datasize());
break;
case ERR_EEPROM_CORRUPT:
DEBUG_ERROR_MSG(STR_ERR_EEPROM_CORRUPT);
DEBUG_WARN_MSG(STR_ERR_EEPROM_CORRUPT);
break;
case ERR_EEPROM_CRC:
DEBUG_ERROR_MSG("EEPROM CRC mismatch - (stored) ", stored_crc, " != ", working_crc, " (calculated)!");
DEBUG_WARN_MSG("EEPROM CRC mismatch - (stored) ", stored_crc, " != ", working_crc, " (calculated)!");
TERN_(HOST_EEPROM_CHITCHAT, hostui.notify(GET_TEXT_F(MSG_ERR_EEPROM_CRC)));
break;
default: break;
Expand Down Expand Up @@ -3048,7 +3048,7 @@ void MarlinSettings::postprocess() {
#else // !EEPROM_SETTINGS

bool MarlinSettings::save() {
DEBUG_ERROR_MSG("EEPROM disabled");
DEBUG_WARN_MSG("EEPROM disabled");
return false;
}

Expand Down

0 comments on commit 619493a

Please sign in to comment.