From 1981e53d68734e69d16cb3d1a33705eec32aed90 Mon Sep 17 00:00:00 2001 From: jbrazio Date: Sat, 12 Mar 2016 06:24:24 +0000 Subject: [PATCH] M109 R option if misused could cause a wait-forever situation --- Marlin/Marlin_main.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 1ccbed879..4eed87be1 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -3940,6 +3940,10 @@ inline void gcode_M109() { // Exit if the temperature is above target and not waiting for cooling if (no_wait_for_cooling && !isHeatingHotend(target_extruder)) return; + // Prevents a wait-forever situation if R is misused i.e. M109 R0 + // Try to calculate a ballpark safe margin by halving EXTRUDE_MINTEMP + if (degTargetHotend(target_extruder) < (EXTRUDE_MINTEMP/2)) return; + #ifdef TEMP_RESIDENCY_TIME long residency_start_ms = -1; // Loop until the temperature has stabilized