From a581b13a247f298d196f09032ccc5828c57b84d6 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Fri, 17 Aug 2012 12:11:29 -0400 Subject: [PATCH] Return to a safe state if calibcant-calibrate.py crashes during calibration. --- bin/calibcant-calibrate.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/bin/calibcant-calibrate.py b/bin/calibcant-calibrate.py index f12112f..3d20ab3 100755 --- a/bin/calibcant-calibrate.py +++ b/bin/calibcant-calibrate.py @@ -32,8 +32,13 @@ def main(args): calibrator = _Calibrator(config=config, afm=afm) calibrator.setup_config() deflection = afm.piezo.read_deflection() - afm.stepper_approach(target_deflection=deflection + 1e3) - k,k_s,data = calibrator.calibrate(filename=filename) + try: + afm.stepper_approach(target_deflection=deflection + 1e3) + k,k_s,data = calibrator.calibrate(filename=filename) + except: + afm.move_away_from_surface() + afm.piezo.zero() + raise finally: for device in devices: device.close() -- 2.26.2