From 3833669c3a41a26e944ffe891cc259ceaf2b9de0 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Wed, 10 Jan 2018 18:34:42 -0500 Subject: 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 --- klippy/mcu.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'klippy/mcu.py') 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 -- cgit v1.2.3-70-g09d2