From 5801e6f4d0d8c03b162d8547df38f58b9a5d0b6c Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Mon, 3 Sep 2018 18:13:15 -0400 Subject: [PATCH] pins: Verify the pin_map setting Raise an error if pin_map is not set to a valid value. Signed-off-by: Kevin O'Connor --- klippy/pins.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/klippy/pins.py b/klippy/pins.py index 7cbacd61..bc8e0fff 100644 --- a/klippy/pins.py +++ b/klippy/pins.py @@ -5,6 +5,9 @@ # This file may be distributed under the terms of the GNU GPLv3 license. import re +class error(Exception): + pass + ###################################################################### # Hardware pin names @@ -111,7 +114,9 @@ Arduino_from_mcu = { } def update_map_arduino(pins, mcu): - dpins, apins = Arduino_from_mcu.get(mcu, ([], [])) + if mcu not in Arduino_from_mcu: + raise error("Arduino aliases not supported on mcu '%s'" % (mcu,)) + dpins, apins = Arduino_from_mcu[mcu] for i in range(len(dpins)): pins['ar' + str(i)] = pins[dpins[i]] for i in range(len(apins)): @@ -152,6 +157,8 @@ beagleboneblack_mappings = { } def update_map_beaglebone(pins, mcu): + if mcu != 'pru': + raise error("Beaglebone aliases not supported on mcu '%s'" % (mcu,)) for pin, gpio in beagleboneblack_mappings.items(): pins[pin] = pins[gpio] @@ -174,6 +181,8 @@ class PinResolver: update_map_arduino(self.pins, self.mcu_type) elif mapping_name == 'beaglebone': update_map_beaglebone(self.pins, self.mcu_type) + else: + raise error("Unknown pin alias mapping '%s'" % (mapping_name,)) def update_command(self, cmd): def pin_fixup(m): name = m.group('name') @@ -192,9 +201,6 @@ class PinResolver: # Pin to chip mapping ###################################################################### -class error(Exception): - pass - class PrinterPins: error = error def __init__(self):