From: W. Trevor King Date: Fri, 17 Aug 2012 16:11:29 +0000 (-0400) Subject: Return to a safe state if calibcant-calibrate.py crashes during calibration. X-Git-Tag: 0.9~13 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=a581b13a247f298d196f09032ccc5828c57b84d6;p=calibcant.git Return to a safe state if calibcant-calibrate.py crashes during calibration. --- 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()