diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2018-09-03 18:13:15 -0400 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2018-09-03 18:16:44 -0400 |
commit | 5801e6f4d0d8c03b162d8547df38f58b9a5d0b6c (patch) | |
tree | 9be4bba4f03a3fcfae81e0dd27b2872f5b2572a0 /klippy | |
parent | 30013a1fb82c15ba67b15a478ad63d636258cf5b (diff) | |
download | kutter-5801e6f4d0d8c03b162d8547df38f58b9a5d0b6c.tar.gz kutter-5801e6f4d0d8c03b162d8547df38f58b9a5d0b6c.tar.xz kutter-5801e6f4d0d8c03b162d8547df38f58b9a5d0b6c.zip |
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 <kevin@koconnor.net>
Diffstat (limited to 'klippy')
-rw-r--r-- | klippy/pins.py | 14 |
1 files 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): |