From 530a13ab6cb681d0b14bbd9d73813f568c5ed68b Mon Sep 17 00:00:00 2001 From: AnHardt Date: Wed, 5 Sep 2018 08:41:45 +0200 Subject: [PATCH] [2.0.x] SECURITYFIX missing max temp error when PID is used (#11717) --- Marlin/src/module/temperature.cpp | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 6156545ef4..1c4d101e99 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -1722,14 +1722,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) @@ -1748,14 +1746,12 @@ 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 }