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().
This commit is contained in:
AnHardt 2015-05-25 12:44:03 +02:00
parent ffc39dc182
commit 959da98d8e

View file

@ -448,6 +448,7 @@ void checkExtruderAutoFans()
// Temperature Error Handlers // Temperature Error Handlers
// //
inline void _temp_error(int e, const char *serial_msg, const char *lcd_msg) { inline void _temp_error(int e, const char *serial_msg, const char *lcd_msg) {
static bool killed = false;
if (IsRunning()) { if (IsRunning()) {
SERIAL_ERROR_START; SERIAL_ERROR_START;
serialprintPGM(serial_msg); 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); if (e >= 0) SERIAL_ERRORLN((int)e); else SERIAL_ERRORLNPGM(MSG_HEATER_BED);
} }
#ifndef BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE #ifndef BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE
if (!killed) {
Running = false;
killed = true;
kill(lcd_msg); kill(lcd_msg);
}
else
disable_all_heaters(); // paranoia
#endif #endif
} }
void max_temp_error(uint8_t e) { void max_temp_error(uint8_t e) {
disable_all_heaters();
_temp_error(e, PSTR(MSG_T_MAXTEMP), PSTR(MSG_ERR_MAXTEMP)); _temp_error(e, PSTR(MSG_T_MAXTEMP), PSTR(MSG_ERR_MAXTEMP));
} }
void min_temp_error(uint8_t e) { void min_temp_error(uint8_t e) {
disable_all_heaters();
_temp_error(e, PSTR(MSG_T_MINTEMP), PSTR(MSG_ERR_MINTEMP)); _temp_error(e, PSTR(MSG_T_MINTEMP), PSTR(MSG_ERR_MINTEMP));
} }
void bed_max_temp_error(void) { 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)); _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 #ifdef TEMP_SENSOR_1_AS_REDUNDANT
if (fabs(current_temperature[0] - redundant_temperature) > MAX_REDUNDANT_TEMP_SENSOR_DIFF) { 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)); _temp_error(0, PSTR(MSG_EXTRUDER_SWITCHED_OFF), PSTR(MSG_ERR_REDUNDANT_TEMP));
} }
#endif #endif
@ -1580,10 +1581,7 @@ ISR(TIMER0_COMPB_vect) {
#else #else
#define GEBED >= #define GEBED >=
#endif #endif
if (current_temperature_bed_raw GEBED bed_maxttemp_raw) { if (current_temperature_bed_raw GEBED bed_maxttemp_raw) bed_max_temp_error();
target_temperature_bed = 0;
bed_max_temp_error();
}
#endif #endif
} // temp_count >= OVERSAMPLENR } // temp_count >= OVERSAMPLENR