From 3806ed882a262b2001d672c0829280c63d1628d6 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Wed, 30 Nov 2016 15:05:26 -0500 Subject: [PATCH] mcu: Raise a config error on an invalid pin name in the config file Signed-off-by: Kevin O'Connor --- klippy/klippy.py | 1 + klippy/mcu.py | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/klippy/klippy.py b/klippy/klippy.py index 151bd1c6..849c5b8b 100644 --- a/klippy/klippy.py +++ b/klippy/klippy.py @@ -34,6 +34,7 @@ Printer is shutdown """ class ConfigWrapper: + error = ConfigParser.Error def __init__(self, printer, section): self.printer = printer self.section = section diff --git a/klippy/mcu.py b/klippy/mcu.py index e039f2d5..09942df8 100644 --- a/klippy/mcu.py +++ b/klippy/mcu.py @@ -399,8 +399,14 @@ class MCU: pnames = pins.mcu_to_pins(mcu) else: pnames = pins.map_pins(pin_map, mcu) - self._config_cmds = [pins.update_command(c, pnames) - for c in self._config_cmds] + updated_cmds = [] + for cmd in self._config_cmds: + try: + updated_cmds.append(pins.update_command(cmd, pnames)) + except: + raise self._config.error("Unable to translate pin name: %s" % ( + cmd,)) + self._config_cmds = updated_cmds # Calculate config CRC self._config_crc = zlib.crc32('\n'.join(self._config_cmds)) & 0xffffffff