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 <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2021-02-28 16:44:03 -05:00
parent a1a7b5e480
commit c9b81e698e
1 changed files with 10 additions and 1 deletions

View File

@ -109,7 +109,16 @@ class TMCErrorCheck:
last_value, reg_name, mask, err_mask = reg_info
count = 0
while 1:
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)