tmc: Retry register init during connect

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2019-06-18 11:58:36 -04:00
parent cfdb60ca23
commit 274857357e
1 changed files with 12 additions and 4 deletions

View File

@ -101,10 +101,18 @@ class TMCCommandHelper:
for reg_name, val in self.fields.registers.items():
self.mcu_tmc.set_register(reg_name, val, print_time)
def _handle_connect(self):
retry_count = 0
while 1:
try:
self._init_registers(0.)
return
except self.printer.command_error as e:
logging.exception("TMC init error")
retry_count += 1
if retry_count > 5:
raise self.printer.config_error(str(e))
reactor = self.printer.get_reactor()
reactor.pause(reactor.monotonic() + 1.)
cmd_INIT_TMC_help = "Initialize TMC stepper driver registers"
def cmd_INIT_TMC(self, params):
logging.info("INIT_TMC %s", self.name)