mirror of https://github.com/Desuuuu/klipper.git
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>
This commit is contained in:
parent
3fc72da9ae
commit
0bdee6bc04
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue