From 0f70b420f24302a11c29cc0e68a4ea2cb17934fc Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Wed, 8 Mar 2017 21:42:51 -0500 Subject: [PATCH] mcu: Improve error messages on failure to config printer Don't report a CRC mismatch if a shutdown or other failure occurs during config - instead report the appropriate details. Signed-off-by: Kevin O'Connor --- klippy/mcu.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/klippy/mcu.py b/klippy/mcu.py index 38e34270..73f99c54 100644 --- a/klippy/mcu.py +++ b/klippy/mcu.py @@ -339,6 +339,7 @@ class MCU: serialport = config.get('serial', '/dev/ttyS0') self.serial = serialhdl.SerialReader(printer.reactor, serialport, baud) self.is_shutdown = False + self._shutdown_msg = "" self._is_fileoutput = False self._timeout_timer = printer.reactor.register_timer( self.timeout_handler) @@ -371,9 +372,10 @@ class MCU: if self.is_shutdown: return self.is_shutdown = True - logging.info("%s: %s" % (params['#name'], params['#msg'])) + self._shutdown_msg = params['#msg'] + logging.info("%s: %s" % (params['#name'], self._shutdown_msg)) self.serial.dump_debug() - self._printer.note_shutdown(params['#msg']) + self._printer.note_shutdown(self._shutdown_msg) # Connection phase def connect(self): if not self._is_fileoutput: @@ -474,6 +476,11 @@ class MCU: self.send(self.create_command(c)) if not self._is_fileoutput: config_params = self.serial.send_with_response(msg, 'config') + if not config_params['is_config']: + if self.is_shutdown: + raise error("Firmware error during config: %s" % ( + self._shutdown_msg,)) + raise error("Unable to configure printer") if self._config_crc != config_params['crc']: raise error("Printer CRC does not match config") move_count = config_params['move_count']