From: W. Trevor King Date: Wed, 20 Apr 2011 18:34:43 +0000 (-0400) Subject: Catch FlatFit errors from all .get_surface_position calls. X-Git-Tag: v0.3~4 X-Git-Url: http://git.tremily.us/?p=pyafm.git;a=commitdiff_plain;h=45f53f9796a35ef32369e66390d39b736651879a Catch FlatFit errors from all .get_surface_position calls. --- 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)'