diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2024-05-01 21:10:17 -0400 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2024-05-21 20:16:31 -0400 |
commit | 4a92727eab61349f2e24fd4296c7fb06740dffe9 (patch) | |
tree | 16bfa09665a0ecc00d21937d171985d47ed81433 /klippy/extras | |
parent | 37482178b5482a013a4a5a62789705ccaf1e03c6 (diff) | |
download | kutter-4a92727eab61349f2e24fd4296c7fb06740dffe9.tar.gz kutter-4a92727eab61349f2e24fd4296c7fb06740dffe9.tar.xz kutter-4a92727eab61349f2e24fd4296c7fb06740dffe9.zip |
sensor_ldc1612: Halt homing if sensor reports a warning
Explicitly check for sensor warnings during homing and report an error
code back to the host.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy/extras')
-rw-r--r-- | klippy/extras/ldc1612.py | 9 | ||||
-rw-r--r-- | klippy/extras/probe_eddy_current.py | 9 |
2 files changed, 11 insertions, 7 deletions
diff --git a/klippy/extras/ldc1612.py b/klippy/extras/ldc1612.py index 08cab965..cdc01e04 100644 --- a/klippy/extras/ldc1612.py +++ b/klippy/extras/ldc1612.py @@ -121,7 +121,7 @@ class LDC1612: oid=self.oid, cq=cmdqueue) self.ldc1612_setup_home_cmd = self.mcu.lookup_command( "ldc1612_setup_home oid=%c clock=%u threshold=%u" - " trsync_oid=%c trigger_reason=%c", cq=cmdqueue) + " trsync_oid=%c trigger_reason=%c error_reason=%c", cq=cmdqueue) self.query_ldc1612_home_state_cmd = self.mcu.lookup_query_command( "query_ldc1612_home_state oid=%c", "ldc1612_home_state oid=%c homing=%c trigger_clock=%u", @@ -138,13 +138,14 @@ class LDC1612: def add_client(self, cb): self.batch_bulk.add_client(cb) # Homing - def setup_home(self, print_time, trigger_freq, trsync_oid, reason): + def setup_home(self, print_time, trigger_freq, + trsync_oid, hit_reason, err_reason): clock = self.mcu.print_time_to_clock(print_time) tfreq = int(trigger_freq * (1<<28) / float(LDC1612_FREQ) + 0.5) self.ldc1612_setup_home_cmd.send( - [self.oid, clock, tfreq, trsync_oid, reason]) + [self.oid, clock, tfreq, trsync_oid, hit_reason, err_reason]) def clear_home(self): - self.ldc1612_setup_home_cmd.send([self.oid, 0, 0, 0, 0]) + self.ldc1612_setup_home_cmd.send([self.oid, 0, 0, 0, 0, 0]) if self.mcu.is_fileoutput(): return 0. params = self.query_ldc1612_home_state_cmd.send([self.oid]) diff --git a/klippy/extras/probe_eddy_current.py b/klippy/extras/probe_eddy_current.py index 636c800d..3f4a5e20 100644 --- a/klippy/extras/probe_eddy_current.py +++ b/klippy/extras/probe_eddy_current.py @@ -185,6 +185,7 @@ class EddyCalibration: # Helper for implementing PROBE style commands class EddyEndstopWrapper: + REASON_SENSOR_ERROR = mcu.MCU_trsync.REASON_COMMS_TIMEOUT + 1 def __init__(self, config, sensor_helper, calibration): self._printer = config.get_printer() self._sensor_helper = sensor_helper @@ -236,7 +237,7 @@ class EddyEndstopWrapper: trigger_completion = self._dispatch.start(print_time) self._sensor_helper.setup_home( print_time, trigger_freq, self._dispatch.get_oid(), - mcu.MCU_trsync.REASON_ENDSTOP_HIT) + mcu.MCU_trsync.REASON_ENDSTOP_HIT, self.REASON_SENSOR_ERROR) return trigger_completion def home_wait(self, home_end_time): self._dispatch.wait_end(home_end_time) @@ -244,8 +245,10 @@ class EddyEndstopWrapper: self._stop_measurements(is_home=True) res = self._dispatch.stop() if res >= mcu.MCU_trsync.REASON_COMMS_TIMEOUT: - raise self._printer.command_error( - "Communication timeout during homing") + if res == mcu.MCU_trsync.REASON_COMMS_TIMEOUT: + raise self._printer.command_error( + "Communication timeout during homing") + raise self._printer.command_error("Eddy current sensor error") if res != mcu.MCU_trsync.REASON_ENDSTOP_HIT: return 0. if self._mcu.is_fileoutput(): |