From 8c2991ceac06c23efae55d3bd428ba9cd0bc1545 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Sun, 30 Sep 2018 10:57:47 -0400 Subject: [PATCH] tmc2208: Improve error handling Configure the tmc2208 during the 'connect' phase so that a problem during configuration is properly raised as a config error. Catch errors during DUMP_TMC and raise them as g-code errors. Signed-off-by: Kevin O'Connor --- klippy/extras/tmc2208.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/klippy/extras/tmc2208.py b/klippy/extras/tmc2208.py index 64202d7d..d93d7d09 100644 --- a/klippy/extras/tmc2208.py +++ b/klippy/extras/tmc2208.py @@ -192,7 +192,7 @@ class TMC2208: self.tmcuart_send_cmd = self.mcu.lookup_command( "tmcuart_send oid=%c write=%*s read=%c", cq=cmd_queue) def printer_state(self, state): - if state == 'ready': + if state == 'connect': for reg_name, val in self.init_regs.items(): self.set_register(reg_name, val) def get_register(self, reg_name): @@ -225,7 +225,10 @@ class TMC2208: gcode = self.printer.lookup_object('gcode') logging.info("DUMP_TMC %s", self.name) for reg_name in ReadRegisters: - val = self.get_register(reg_name) + try: + val = self.get_register(reg_name) + except self.printer.config_error as e: + raise gcode.error(str(e)) msg = "%-15s %08x" % (reg_name + ":", val) logging.info(msg) gcode.respond_info(msg)