From c9b81e698e509d31527727e2b05f7036fe201997 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Sun, 28 Feb 2021 16:44:03 -0500 Subject: [PATCH] tmc: Allow more retries on a TMC UART read error during background checks Allow three retries if we can't contact the TMC driver at all when it is in UART mode. Signed-off-by: Kevin O'Connor --- klippy/extras/tmc.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/klippy/extras/tmc.py b/klippy/extras/tmc.py index 6d6e765b..11073e40 100644 --- a/klippy/extras/tmc.py +++ b/klippy/extras/tmc.py @@ -109,7 +109,16 @@ class TMCErrorCheck: last_value, reg_name, mask, err_mask = reg_info count = 0 while 1: - val = self.mcu_tmc.get_register(reg_name) + try: + val = self.mcu_tmc.get_register(reg_name) + except self.printer.command_error as e: + count += 1 + if count < 3 and str(e).startswith("Unable to read tmc uart"): + # Allow more retries on a TMC UART read error + reactor = self.printer.get_reactor() + reactor.pause(reactor.monotonic() + 0.050) + continue + raise if val & mask != last_value & mask: fmt = self.fields.pretty_format(reg_name, val) logging.info("TMC '%s' reports %s", self.stepper_name, fmt)