diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2018-01-10 18:34:42 -0500 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2018-01-10 19:26:06 -0500 |
commit | 3833669c3a41a26e944ffe891cc259ceaf2b9de0 (patch) | |
tree | 5a692dad035fba835d582f2755b0cc8ad463cdb7 /klippy/mcu.py | |
parent | df6528715e86305d77456efb8b76dad734ffda9f (diff) | |
download | kutter-3833669c3a41a26e944ffe891cc259ceaf2b9de0.tar.gz kutter-3833669c3a41a26e944ffe891cc259ceaf2b9de0.tar.xz kutter-3833669c3a41a26e944ffe891cc259ceaf2b9de0.zip |
pins: Check if the same pin is referenced via different aliases
Change the update_command() call to use a new PinResolver class. In
that new class, verify that the same pin isn't referenced in two
different parts of the config using different aliases for the pin.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy/mcu.py')
-rw-r--r-- | klippy/mcu.py | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/klippy/mcu.py b/klippy/mcu.py index b5631f4e..a415ba25 100644 --- a/klippy/mcu.py +++ b/klippy/mcu.py @@ -522,15 +522,14 @@ class MCU: self._oid_count,)) # Resolve pin names - mcu = self._serial.msgparser.get_constant('MCU') - pnames = pins.get_pin_map(mcu, self._pin_map) - updated_cmds = [] - for cmd in self._config_cmds: - try: - updated_cmds.append(pins.update_command(cmd, pnames)) - except: - raise pins.error("Unable to translate pin name: %s" % (cmd,)) - self._config_cmds = updated_cmds + mcu_type = self._serial.msgparser.get_constant('MCU') + pin_resolver = pins.PinResolver(mcu_type) + if self._pin_map is not None: + pin_resolver.update_aliases(self._pin_map) + for i, cmd in enumerate(self._config_cmds): + self._config_cmds[i] = pin_resolver.update_command(cmd) + for i, cmd in enumerate(self._init_cmds): + self._init_cmds[i] = pin_resolver.update_command(cmd) # Calculate config CRC self._config_crc = zlib.crc32('\n'.join(self._config_cmds)) & 0xffffffff |