From a7b81dc05cebc593ac4be2012142fbca9180e199 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Mon, 19 Sep 2016 13:18:55 -0400 Subject: toolhead: Force a firmware shutdown on an unhandled exception Check for unhandled exceptions and force the MCU to shutdown in that case. Signed-off-by: Kevin O'Connor --- klippy/gcode.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'klippy/gcode.py') diff --git a/klippy/gcode.py b/klippy/gcode.py index ad05b0d5..f6f64d1e 100644 --- a/klippy/gcode.py +++ b/klippy/gcode.py @@ -101,7 +101,8 @@ class GCodeParser: handler(params) except: logging.exception("Exception in command handler") - self.respond('echo:Internal error on command:"%s"' % (cmd,)) + self.toolhead.force_shutdown() + self.respond('Error: Internal error on command:"%s"' % (cmd,)) # Check if machine can process next command or must stall input if self.busy_state is not None: break @@ -142,7 +143,13 @@ class GCodeParser: self.busy_state = busy_handler self.reactor.update_timer(self.busy_timer, self.reactor.NOW) def busy_handler(self, eventtime): - busy = self.busy_state.check_busy(eventtime) + try: + busy = self.busy_state.check_busy(eventtime) + except: + logging.exception("Exception in busy handler") + self.toolhead.force_shutdown() + self.respond('Error: Internal error in busy handler') + busy = False if busy: self.toolhead.reset_motor_off_time(eventtime) return eventtime + self.RETRY_TIME -- cgit v1.2.3-70-g09d2