Return to a safe state if calibcant-calibrate.py crashes during calibration.
authorW. Trevor King <wking@tremily.us>
Fri, 17 Aug 2012 16:11:29 +0000 (12:11 -0400)
committerW. Trevor King <wking@tremily.us>
Fri, 17 Aug 2012 16:13:10 +0000 (12:13 -0400)
bin/calibcant-calibrate.py

index f12112fc473628ca5f55f47490dbf1e5a8f7eba2..3d20ab3dd0127ce1b145fcd227d137a3982927b9 100755 (executable)
@@ -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()