aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimofey Titovets <nefelim4ag@gmail.com>2025-06-09 18:33:21 +0200
committerKevinOConnor <kevin@koconnor.net>2025-07-12 16:17:22 -0400
commit9c0d0f6a72897dd8eea8a95a7fabcc3c28f3a12c (patch)
treec4b436e8843e4ac407a79806abd709c40dd77651
parent5923a2e3a1501c700ea4e357fa8491324b7ce7f3 (diff)
downloadkutter-9c0d0f6a72897dd8eea8a95a7fabcc3c28f3a12c.tar.gz
kutter-9c0d0f6a72897dd8eea8a95a7fabcc3c28f3a12c.tar.xz
kutter-9c0d0f6a72897dd8eea8a95a7fabcc3c28f3a12c.zip
tmc: add enriched UART read
Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
-rw-r--r--klippy/extras/tmc_uart.py20
1 files changed, 14 insertions, 6 deletions
diff --git a/klippy/extras/tmc_uart.py b/klippy/extras/tmc_uart.py
index 4d5ec1d5..93935042 100644
--- a/klippy/extras/tmc_uart.py
+++ b/klippy/extras/tmc_uart.py
@@ -175,7 +175,10 @@ class MCU_TMC_uart_bitbang:
self.analog_mux.activate(instance_id)
msg = self._encode_read(0xf5, addr, reg)
params = self.tmcuart_send_cmd.send([self.oid, msg, 10])
- return self._decode_read(reg, params['read'])
+ return {
+ 'data': self._decode_read(reg, params['read']),
+ '#receive_time': params['#receive_time']
+ }
def reg_write(self, instance_id, addr, reg, val, print_time=None):
minclock = 0
if print_time is not None:
@@ -225,16 +228,21 @@ class MCU_TMC_uart:
def _do_get_register(self, reg_name):
reg = self.name_to_reg[reg_name]
if self.printer.get_start_args().get('debugoutput') is not None:
- return 0
+ return {
+ 'data': 0,
+ '#receive_time': 0.
+ }
for retry in range(5):
val = self.mcu_uart.reg_read(self.instance_id, self.addr, reg)
- if val is not None:
+ if val['data'] is not None:
return val
raise self.printer.command_error(
"Unable to read tmc uart '%s' register %s" % (self.name, reg_name))
- def get_register(self, reg_name):
+ def get_register_raw(self, reg_name):
with self.mutex:
return self._do_get_register(reg_name)
+ def get_register(self, reg_name):
+ return self.get_register_raw(reg_name)['data']
def set_register(self, reg_name, val, print_time=None):
reg = self.name_to_reg[reg_name]
if self.printer.get_start_args().get('debugoutput') is not None:
@@ -243,10 +251,10 @@ class MCU_TMC_uart:
for retry in range(5):
ifcnt = self.ifcnt
if ifcnt is None:
- self.ifcnt = ifcnt = self._do_get_register("IFCNT")
+ self.ifcnt = ifcnt = self._do_get_register("IFCNT")['data']
self.mcu_uart.reg_write(self.instance_id, self.addr, reg, val,
print_time)
- self.ifcnt = self._do_get_register("IFCNT")
+ self.ifcnt = self._do_get_register("IFCNT")['data']
if self.ifcnt == (ifcnt + 1) & 0xff:
return
raise self.printer.command_error(