mcu: Raise a config error on an invalid pin name in the config file

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2016-11-30 15:05:26 -05:00
parent ce7e7c4048
commit 3806ed882a
2 changed files with 9 additions and 2 deletions

View File

@ -34,6 +34,7 @@ Printer is shutdown
"""
class ConfigWrapper:
error = ConfigParser.Error
def __init__(self, printer, section):
self.printer = printer
self.section = section

View File

@ -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