From 959da98d8ee6ed8b268e8cd939f35c95ba9df9f0 Mon Sep 17 00:00:00 2001 From: AnHardt Date: Mon, 25 May 2015 12:44:03 +0200 Subject: [PATCH] Call kill() only once when triggered by a temperature error to avoid stack overflow when called from interrupt. Some clean up for calls of disable_all_heaters(). 'disable_all_heaters()' is called in kill() and again when 'killed' is already set inside _temp_error(). --- Marlin/temperature.cpp | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/Marlin/temperature.cpp b/Marlin/temperature.cpp index 4d8973cad..a689759ef 100644 --- a/Marlin/temperature.cpp +++ b/Marlin/temperature.cpp @@ -448,6 +448,7 @@ void checkExtruderAutoFans() // Temperature Error Handlers // inline void _temp_error(int e, const char *serial_msg, const char *lcd_msg) { + static bool killed = false; if (IsRunning()) { SERIAL_ERROR_START; serialprintPGM(serial_msg); @@ -455,22 +456,23 @@ inline void _temp_error(int e, const char *serial_msg, const char *lcd_msg) { if (e >= 0) SERIAL_ERRORLN((int)e); else SERIAL_ERRORLNPGM(MSG_HEATER_BED); } #ifndef BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE - kill(lcd_msg); + if (!killed) { + Running = false; + killed = true; + kill(lcd_msg); + } + else + disable_all_heaters(); // paranoia #endif } void max_temp_error(uint8_t e) { - disable_all_heaters(); _temp_error(e, PSTR(MSG_T_MAXTEMP), PSTR(MSG_ERR_MAXTEMP)); } void min_temp_error(uint8_t e) { - disable_all_heaters(); _temp_error(e, PSTR(MSG_T_MINTEMP), PSTR(MSG_ERR_MINTEMP)); } void bed_max_temp_error(void) { - #if HAS_HEATER_BED - WRITE_HEATER_BED(0); - #endif _temp_error(-1, PSTR(MSG_T_MAXTEMP), PSTR(MSG_ERR_MAXTEMP_BED)); } @@ -637,7 +639,6 @@ void manage_heater() { #ifdef TEMP_SENSOR_1_AS_REDUNDANT if (fabs(current_temperature[0] - redundant_temperature) > MAX_REDUNDANT_TEMP_SENSOR_DIFF) { - disable_all_heaters(); _temp_error(0, PSTR(MSG_EXTRUDER_SWITCHED_OFF), PSTR(MSG_ERR_REDUNDANT_TEMP)); } #endif @@ -1580,10 +1581,7 @@ ISR(TIMER0_COMPB_vect) { #else #define GEBED >= #endif - if (current_temperature_bed_raw GEBED bed_maxttemp_raw) { - target_temperature_bed = 0; - bed_max_temp_error(); - } + if (current_temperature_bed_raw GEBED bed_maxttemp_raw) bed_max_temp_error(); #endif } // temp_count >= OVERSAMPLENR