From 49a3083d6aa7b32c3ab2aff2ea9cb7492604282b Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Tue, 4 Jun 2019 20:36:30 -0400 Subject: [PATCH] manual_probe: Add extra checks to catch manual probe not finishing correctly Signed-off-by: Kevin O'Connor --- klippy/extras/manual_probe.py | 21 +++++++++++++-------- klippy/extras/probe.py | 2 ++ 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/klippy/extras/manual_probe.py b/klippy/extras/manual_probe.py index 2fabd4f6..38160fef 100644 --- a/klippy/extras/manual_probe.py +++ b/klippy/extras/manual_probe.py @@ -41,6 +41,16 @@ class ManualProbe: def cmd_Z_ENDSTOP_CALIBRATE(self, params): ManualProbeHelper(self.printer, params, self.z_endstop_finalize) +# Verify that a manual probe isn't already in progress +def verify_no_manual_probe(printer): + gcode = printer.lookup_object('gcode') + try: + gcode.register_command('ACCEPT', 'dummy') + except printer.config_error as e: + raise gcode.error( + "Already in a manual Z probe. Use ABORT to abort it.") + gcode.register_command('ACCEPT', None) + Z_BOB_MINIMUM = 0.500 BISECT_MAX = 0.200 @@ -55,14 +65,9 @@ class ManualProbeHelper: self.past_positions = [] self.last_toolhead_pos = self.last_kinematics_pos = None # Register commands - try: - self.gcode.register_command('ACCEPT', self.cmd_ACCEPT, - desc=self.cmd_ACCEPT_help) - except self.printer.config_error as e: - self.gcode.respond_error( - "Already in a manual Z probe. Use ABORT to abort it.") - self.finalize_callback(None) - return + verify_no_manual_probe(printer) + self.gcode.register_command('ACCEPT', self.cmd_ACCEPT, + desc=self.cmd_ACCEPT_help) self.gcode.register_command('NEXT', self.cmd_ACCEPT) self.gcode.register_command('ABORT', self.cmd_ABORT, desc=self.cmd_ABORT_help) diff --git a/klippy/extras/probe.py b/klippy/extras/probe.py index 4c62b891..204375bf 100644 --- a/klippy/extras/probe.py +++ b/klippy/extras/probe.py @@ -175,6 +175,7 @@ class PrinterProbe: configfile.set(self.name, 'z_offset', "%.3f" % (z_offset,)) cmd_PROBE_CALIBRATE_help = "Calibrate the probe's z_offset" def cmd_PROBE_CALIBRATE(self, params): + manual_probe.verify_no_manual_probe(self.printer) # Perform initial probe curpos = self.run_probe() # Move away from the bed @@ -292,6 +293,7 @@ class ProbePointsHelper: self.gcode.reset_last_position() return False def start_probe(self, params): + manual_probe.verify_no_manual_probe(self.printer) # Lookup objects probe = self.printer.lookup_object('probe', None) method = self.gcode.get_str('METHOD', params, 'automatic').lower()