From 0bdee6bc0488899172d4b2be6dbdffd1c439f7b6 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Sun, 21 Feb 2021 22:09:51 -0500 Subject: [PATCH] mcu: Raise a command_error on a command timeout event Raise a printer.command_error() instead of an mcu.error() if a query command does not succeed. That error is less likely to result in an unhandled exception error. Signed-off-by: Kevin O'Connor --- klippy/mcu.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/klippy/mcu.py b/klippy/mcu.py index 5e31602c..fe540962 100644 --- a/klippy/mcu.py +++ b/klippy/mcu.py @@ -358,18 +358,20 @@ class RetryAsyncCommand: query_time = self.reactor.monotonic() if query_time > first_query_time + self.TIMEOUT_TIME: self.serial.register_response(None, self.name, self.oid) - raise error("Timeout on wait for '%s' response" % (self.name,)) + raise serialhdl.error("Timeout on wait for '%s' response" + % (self.name,)) self.serial.raw_send(cmd, minclock, minclock, cmd_queue) # Wrapper around query commands class CommandQueryWrapper: def __init__(self, serial, msgformat, respformat, oid=None, - cmd_queue=None, is_async=False): + cmd_queue=None, is_async=False, error=serialhdl.error): self._serial = serial self._cmd = serial.get_msgparser().lookup_command(msgformat) serial.get_msgparser().lookup_command(respformat) self._response = respformat.split()[0] self._oid = oid + self._error = error self._xmit_helper = serialhdl.SerialRetryCommand if is_async: self._xmit_helper = RetryAsyncCommand @@ -383,7 +385,7 @@ class CommandQueryWrapper: try: return xh.get_response(cmd, self._cmd_queue, minclock, reqclock) except serialhdl.error as e: - raise error(str(e)) + raise self._error(str(e)) # Wrapper around command sending class CommandWrapper: @@ -688,7 +690,7 @@ class MCU: def lookup_query_command(self, msgformat, respformat, oid=None, cq=None, is_async=False): return CommandQueryWrapper(self._serial, msgformat, respformat, oid, - cq, is_async) + cq, is_async, self._printer.command_error) def try_lookup_command(self, msgformat): try: return self.lookup_command(msgformat)