From c4de0bba507e50a3be537d6ffe731427f25fba91 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Sun, 14 Jun 2020 11:34:04 -0400 Subject: [PATCH] pid_calibrate: Avoid internal error on a shutdown If a shutdown occurs during a PID_CALIBRATE command (eg, due to a heater problem) then exit cleanly instead of throwing an internal error. Signed-off-by: Kevin O'Connor --- klippy/extras/pid_calibrate.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/klippy/extras/pid_calibrate.py b/klippy/extras/pid_calibrate.py index 0cad07f5..2bc6566c 100644 --- a/klippy/extras/pid_calibrate.py +++ b/klippy/extras/pid_calibrate.py @@ -34,6 +34,8 @@ class PIDCalibrate: heater.set_control(old_control) if write_file: calibrate.write_file('/tmp/heattest.txt') + if calibrate.check_busy(0., 0., 0.): + raise gcmd.error("pid_calibrate interrupted") # Log and report results Kp, Ki, Kd = calibrate.calc_final_pid() logging.info("Autotune: final: Kp=%f Ki=%f Kd=%f", Kp, Ki, Kd)