diff --git a/klippy/extras/ads1220.py b/klippy/extras/ads1220.py index 891783922..f4ddaf9f8 100644 --- a/klippy/extras/ads1220.py +++ b/klippy/extras/ads1220.py @@ -85,8 +85,6 @@ class ADS1220: if drdy_pin_mcu != self.mcu: raise config.error("ADS1220 config error: SPI communication and" " data_ready_pin must be on the same MCU") - # Bulk Sensor Setup - self.bulk_queue = bulk_sensor.BulkDataQueue(self.mcu, oid=self.oid) # Clock tracking chip_smooth = self.sps * UPDATE_INTERVAL * 2 # Measurement conversion diff --git a/klippy/extras/bulk_sensor.py b/klippy/extras/bulk_sensor.py index b0aa320d0..651e14aa7 100644 --- a/klippy/extras/bulk_sensor.py +++ b/klippy/extras/bulk_sensor.py @@ -112,14 +112,16 @@ class BatchWebhooksClient: self.cconn.send(tmp) return True +SENSOR_BULK_FMT = "sensor_bulk_data oid=%c sequence=%hu data=%*s" + # Helper class to store incoming messages in a queue class BulkDataQueue: - def __init__(self, mcu, msg_name="sensor_bulk_data", oid=None): + def __init__(self, mcu, msg_fmt=SENSOR_BULK_FMT, oid=None): # Measurement storage (accessed from background thread) self.lock = threading.Lock() self.raw_samples = [] # Register callback with mcu - mcu.register_response(self._handle_data, msg_name, oid) + mcu.register_serial_response(self._handle_data, msg_fmt, oid) def _handle_data(self, params): with self.lock: self.raw_samples.append(params) diff --git a/klippy/extras/bus.py b/klippy/extras/bus.py index 3a6ef5842..6bd9bc750 100644 --- a/klippy/extras/bus.py +++ b/klippy/extras/bus.py @@ -248,8 +248,10 @@ class MCU_I2C: "i2c_transfer oid=%c write=%*s read_len=%u", cq=self.cmd_queue) if self.async_write_only: - self.mcu.register_response(self._async_write_status, - "i2c_response", self.oid) + self.mcu.register_serial_response( + self._async_write_status, + "i2c_response oid=%c i2c_bus_status=%c response=%*s", + self.oid) self._configured = True def i2c_write_noack(self, data, minclock=0, reqclock=0): if self.async_write_only: diff --git a/klippy/extras/buttons.py b/klippy/extras/buttons.py index 4ffb3c38b..50f2a5a9b 100644 --- a/klippy/extras/buttons.py +++ b/klippy/extras/buttons.py @@ -52,8 +52,9 @@ class MCU_buttons: " rest_ticks=%d retransmit_count=%d invert=%d" % ( self.oid, clock, rest_ticks, RETRANSMIT_COUNT, self.invert), is_init=True) - self.mcu.register_response(self.handle_buttons_state, - "buttons_state", self.oid) + self.mcu.register_serial_response( + self.handle_buttons_state, + "buttons_state oid=%c ack_count=%c state=%*s", self.oid) def handle_buttons_state(self, params): # Expand the message ack_count from 8-bit ack_count = self.ack_count diff --git a/klippy/extras/canbus_stats.py b/klippy/extras/canbus_stats.py index fb8c88c91..5bc609d06 100644 --- a/klippy/extras/canbus_stats.py +++ b/klippy/extras/canbus_stats.py @@ -40,8 +40,9 @@ class PrinterCANBusStats: "canbus_status rx_error=%u tx_error=%u tx_retries=%u" " canbus_bus_state=%u") # Register usb_canbus_state message handling (for usb to canbus bridge) - self.mcu.register_response(self.handle_usb_canbus_state, - "usb_canbus_state") + if self.mcu.check_valid_response("usb_canbus_state discard=%u"): + self.mcu.register_serial_response(self.handle_usb_canbus_state, + "usb_canbus_state discard=%u") # Register periodic query timer self.reactor.register_timer(self.query_event, self.reactor.NOW) def handle_usb_canbus_state(self, params): diff --git a/klippy/extras/ds18b20.py b/klippy/extras/ds18b20.py index 37b301046..8ad60ba25 100644 --- a/klippy/extras/ds18b20.py +++ b/klippy/extras/ds18b20.py @@ -26,8 +26,9 @@ class DS18B20: ) self._mcu = mcu.get_printer_mcu(self.printer, config.get('sensor_mcu')) self.oid = self._mcu.create_oid() - self._mcu.register_response(self._handle_ds18b20_response, - "ds18b20_result", self.oid) + self._mcu.register_serial_response( + self._handle_ds18b20_response, + "ds18b20_result oid=%c next_clock=%u value=%i fault=%u", self.oid) self._mcu.register_config_callback(self._build_config) def _build_config(self): diff --git a/klippy/extras/hx71x.py b/klippy/extras/hx71x.py index a1bc20529..76563d484 100644 --- a/klippy/extras/hx71x.py +++ b/klippy/extras/hx71x.py @@ -42,8 +42,6 @@ class HX71xBase: # gain/channel choices self.gain_channel = int(config.getchoice('gain', gain_options, default=default_gain)) - ## Bulk Sensor Setup - self.bulk_queue = bulk_sensor.BulkDataQueue(mcu, oid=self.oid) # Clock tracking chip_smooth = self.sps * UPDATE_INTERVAL * 2 self.ffreader = bulk_sensor.FixedFreqReader(mcu, chip_smooth, "