aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/mcu.py
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2021-06-09 15:02:56 -0400
committerKevin O'Connor <kevin@koconnor.net>2021-06-09 18:58:26 -0400
commitecbfa762425b81031357c68158fb5939f6d24675 (patch)
tree6c3b33734e714f7f3bc988e8f495c1f4fd8070bd /klippy/mcu.py
parent31fcd491fd9fd99f81599558b5256cfaaa078da0 (diff)
downloadkutter-ecbfa762425b81031357c68158fb5939f6d24675.tar.gz
kutter-ecbfa762425b81031357c68158fb5939f6d24675.tar.xz
kutter-ecbfa762425b81031357c68158fb5939f6d24675.zip
mcu: Raise config_error (not protocol error) on pin enumeration errors
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy/mcu.py')
-rw-r--r--klippy/mcu.py31
1 files changed, 20 insertions, 11 deletions
diff --git a/klippy/mcu.py b/klippy/mcu.py
index f03fd16d..3f88c3e5 100644
--- a/klippy/mcu.py
+++ b/klippy/mcu.py
@@ -4,7 +4,7 @@
#
# This file may be distributed under the terms of the GNU GPLv3 license.
import sys, os, zlib, logging, math
-import serialhdl, pins, chelper, clocksync
+import serialhdl, msgproto, pins, chelper, clocksync
class error(Exception):
pass
@@ -548,17 +548,26 @@ class MCU:
raise error("MCU '%s' CRC does not match config" % (self._name,))
# Transmit config messages (if needed)
self.register_response(self._handle_starting, 'starting')
- if prev_crc is None:
- logging.info("Sending MCU '%s' printer configuration...",
- self._name)
- for c in self._config_cmds:
- self._serial.send(c)
- else:
- for c in self._restart_cmds:
+ try:
+ if prev_crc is None:
+ logging.info("Sending MCU '%s' printer configuration...",
+ self._name)
+ for c in self._config_cmds:
+ self._serial.send(c)
+ else:
+ for c in self._restart_cmds:
+ self._serial.send(c)
+ # Transmit init messages
+ for c in self._init_cmds:
self._serial.send(c)
- # Transmit init messages
- for c in self._init_cmds:
- self._serial.send(c)
+ except msgproto.enumeration_error as e:
+ enum_name, enum_value = e.get_enum_params()
+ if enum_name == 'pin':
+ # Raise pin name errors as a config error (not a protocol error)
+ raise self._printer.config_error(
+ "Pin '%s' is not a valid pin name on mcu '%s'"
+ % (enum_value, self._name))
+ raise
def _send_get_config(self):
get_config_cmd = self.lookup_query_command(
"get_config",