From 45f53f9796a35ef32369e66390d39b736651879a Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Wed, 20 Apr 2011 14:34:43 -0400 Subject: [PATCH] Catch FlatFit errors from all .get_surface_position calls. --- pyafm.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/pyafm.py b/pyafm.py index c46e47b..1d359de 100644 --- a/pyafm.py +++ b/pyafm.py @@ -109,8 +109,12 @@ class AFM (object): while pos_m < -stepper_tolerance: # step back if we need to LOG.debug('step back') self.stepper.step_relative(-1, backlash_safe=True) - pos = self.piezo.get_surface_position( - axis_name=self.axis_name, max_deflection=target_def) + try: + pos = self.piezo.get_surface_position( + axis_name=self.axis_name, max_deflection=target_def) + except _FlatFit, e: + LOG.debug(e) + continue pos_m = _convert_bits_to_meters( axis.axis_channel_config, axis.axis_config, pos) LOG.debug('located surface at stepper %d, piezo %d (%g m)' @@ -118,8 +122,12 @@ class AFM (object): while pos_m > stepper_tolerance: # step forward if we need to LOG.debug('step forward') self.stepper.step_relative(1) - pos = self.piezo.get_surface_position( - axis_name=self.axis_name, max_deflection=target_def) + try: + pos = self.piezo.get_surface_position( + axis_name=self.axis_name, max_deflection=target_def) + except _FlatFit, e: + LOG.debug(e) + continue pos_m = _convert_bits_to_meters( axis.axis_channel_config, axis.axis_config, pos) LOG.debug('located surface at stepper %d, piezo %d (%g m)' -- 2.26.2