bus: make i2c_write syncronous

When we introduce the host-side status check,
it will be synchronous.
There would be no sense in having an asynchronous call.
Preliminary migrate callers to synchronous call.

Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
This commit is contained in:
Timofey Titovets 2025-08-21 19:36:56 +02:00 committed by KevinOConnor
parent ae010215e7
commit fe44dd8baa

View File

@ -182,6 +182,7 @@ class MCU_I2C:
self.i2c_write_cmd = self.i2c_read_cmd = None self.i2c_write_cmd = self.i2c_read_cmd = None
printer = self.mcu.get_printer() printer = self.mcu.get_printer()
printer.register_event_handler("klippy:connect", self._handle_connect) printer.register_event_handler("klippy:connect", self._handle_connect)
self._debugoutput = printer.get_start_args().get('debugoutput')
# backward support i2c_write inside the init section # backward support i2c_write inside the init section
self._to_write = [] self._to_write = []
def _handle_connect(self): def _handle_connect(self):
@ -216,8 +217,12 @@ class MCU_I2C:
if self.i2c_write_cmd is None: if self.i2c_write_cmd is None:
self._to_write.append(data) self._to_write.append(data)
return return
self.i2c_write_cmd.send([self.oid, data], if self._debugoutput is not None:
minclock=minclock, reqclock=reqclock) self.i2c_write_cmd.send([self.oid, data],
minclock=minclock, reqclock=reqclock)
return
self.i2c_write_cmd.send_wait_ack([self.oid, data],
minclock=minclock, reqclock=reqclock)
def i2c_write_wait_ack(self, data, minclock=0, reqclock=0): def i2c_write_wait_ack(self, data, minclock=0, reqclock=0):
self.i2c_write_cmd.send_wait_ack([self.oid, data], self.i2c_write_cmd.send_wait_ack([self.oid, data],
minclock=minclock, reqclock=reqclock) minclock=minclock, reqclock=reqclock)