diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2021-02-21 22:09:51 -0500 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2021-02-27 10:39:46 -0500 |
commit | 0bdee6bc0488899172d4b2be6dbdffd1c439f7b6 (patch) | |
tree | 4719b12790eabddf32c3fc6e05d535e383351dd5 /klippy/mcu.py | |
parent | 3fc72da9ae13748b0444a9048393a0012579b01c (diff) | |
download | kutter-0bdee6bc0488899172d4b2be6dbdffd1c439f7b6.tar.gz kutter-0bdee6bc0488899172d4b2be6dbdffd1c439f7b6.tar.xz kutter-0bdee6bc0488899172d4b2be6dbdffd1c439f7b6.zip |
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 <kevin@koconnor.net>
Diffstat (limited to 'klippy/mcu.py')
-rw-r--r-- | klippy/mcu.py | 10 |
1 files 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) |