aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/gcode.py
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2016-09-19 13:18:55 -0400
committerKevin O'Connor <kevin@koconnor.net>2016-09-22 11:15:17 -0400
commita7b81dc05cebc593ac4be2012142fbca9180e199 (patch)
tree0f3f4cc8591d2a59350fb5cee3bb58dd689ef6c3 /klippy/gcode.py
parent0824d3231975428429141dbd06cd6b04a4a74e14 (diff)
downloadkutter-a7b81dc05cebc593ac4be2012142fbca9180e199.tar.gz
kutter-a7b81dc05cebc593ac4be2012142fbca9180e199.tar.xz
kutter-a7b81dc05cebc593ac4be2012142fbca9180e199.zip
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 <kevin@koconnor.net>
Diffstat (limited to 'klippy/gcode.py')
-rw-r--r--klippy/gcode.py11
1 files changed, 9 insertions, 2 deletions
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