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>
This commit is contained in:
Kevin O'Connor 2016-09-19 13:18:55 -04:00
parent 0824d32319
commit a7b81dc05c
3 changed files with 44 additions and 21 deletions

View file

@ -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