bdp_guard: one lock for all I2C transfers of the bd_pressure
The guard's timer read the sensor while G28 ran; bdpressure.py writes the
probe mode at every homing move, and Klipper allows only one I2C request
at a time per device: KeyError ('i2c_response', 1), Klipper shut down
during HOME. The guard now wraps the sensor's i2c in a reactor mutex at
connect; bdpressure and bdpressure_check (now looks up sensor.i2c at
every use) go through it too.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
61fa8acb05
commit
8eef0ee298
3 files changed
+47
-6
No files matched your search
@@ -35,7 +35,6 @@ class BDPressureCheck:
|
||||
def __init__(self, config):
|
||||
self.printer = config.get_printer()
|
||||
self.sensor_name = 'bdpressure ' + config.get('sensor', 'bd_pa')
|
||||
self.i2c = None
|
||||
self.sensor = None
|
||||
self.status = {'available': False, 'running': False, 'peak': 0,
|
||||
'above_ms': 0, 'longest_ms': 0, 'delta': 0}
|
||||
@@ -50,9 +49,13 @@ class BDPressureCheck:
|
||||
desc="Read the bd_pressure load check values")
|
||||
|
||||
def _handle_connect(self):
|
||||
sensor = self.printer.lookup_object(self.sensor_name)
|
||||
self.sensor = sensor
|
||||
self.i2c = getattr(sensor, 'i2c', None)
|
||||
self.sensor = self.printer.lookup_object(self.sensor_name)
|
||||
|
||||
@property
|
||||
def i2c(self):
|
||||
# Looked up at every use: bdp_guard replaces the sensor's i2c with a
|
||||
# locked wrapper at connect, possibly after this module's connect.
|
||||
return getattr(self.sensor, 'i2c', None)
|
||||
|
||||
def _read(self):
|
||||
if self.i2c is None:
|
||||
|
||||
Reference in new issue
Block a user