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 <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2020-06-14 11:34:04 -04:00
parent 35bbd989e4
commit c4de0bba50
1 changed files with 2 additions and 0 deletions

View File

@ -34,6 +34,8 @@ class PIDCalibrate:
heater.set_control(old_control) heater.set_control(old_control)
if write_file: if write_file:
calibrate.write_file('/tmp/heattest.txt') calibrate.write_file('/tmp/heattest.txt')
if calibrate.check_busy(0., 0., 0.):
raise gcmd.error("pid_calibrate interrupted")
# Log and report results # Log and report results
Kp, Ki, Kd = calibrate.calc_final_pid() Kp, Ki, Kd = calibrate.calc_final_pid()
logging.info("Autotune: final: Kp=%f Ki=%f Kd=%f", Kp, Ki, Kd) logging.info("Autotune: final: Kp=%f Ki=%f Kd=%f", Kp, Ki, Kd)