From b34134ed3d47b92ff034bb3af3cc3af3861e1861 Mon Sep 17 00:00:00 2001 From: AnHardt Date: Wed, 5 Sep 2018 08:39:49 +0200 Subject: [PATCH] [1.1.x] SECURITYFIX missing max temp error when PID is used (#11718) --- Marlin/temperature.cpp | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/Marlin/temperature.cpp b/Marlin/temperature.cpp index 1e765a242..cf28f6d8b 100644 --- a/Marlin/temperature.cpp +++ b/Marlin/temperature.cpp @@ -1786,14 +1786,12 @@ void Temperature::readings_ready() { for (uint8_t e = 0; e < COUNT(temp_dir); e++) { const int16_t tdir = temp_dir[e], rawtemp = current_temperature_raw[e] * tdir; - const bool heater_on = 0 < + const bool heater_on = (target_temperature[e] > 0) #if ENABLED(PIDTEMP) - soft_pwm_amount[e] - #else - target_temperature[e] + || (soft_pwm_amount[e] > 0) #endif ; - if (rawtemp > maxttemp_raw[e] * tdir && heater_on) max_temp_error(e); + if (rawtemp > maxttemp_raw[e] * tdir) max_temp_error(e); if (rawtemp < minttemp_raw[e] * tdir && !is_preheating(e) && heater_on) { #ifdef MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED if (++consecutive_low_temperature_error[e] >= MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED) @@ -1812,20 +1810,18 @@ void Temperature::readings_ready() { #else #define GEBED >= #endif - const bool bed_on = 0 < + const bool bed_on = (target_temperature_bed > 0) #if ENABLED(PIDTEMPBED) - soft_pwm_amount_bed - #else - target_temperature_bed + || (soft_pwm_amount_bed > 0) #endif ; - if (current_temperature_bed_raw GEBED bed_maxttemp_raw && bed_on) max_temp_error(-1); + if (current_temperature_bed_raw GEBED bed_maxttemp_raw) max_temp_error(-1); if (bed_minttemp_raw GEBED current_temperature_bed_raw && bed_on) min_temp_error(-1); #endif } /** - * Timer 0 is shared with millies so don't change the prescaler. + * Timer 0 is shared with millis so don't change the prescaler. * * This ISR uses the compare method so it runs at the base * frequency (16 MHz / 64 / 256 = 976.5625 Hz), but at the TCNT0 set