From 9485c76a9369a25373f0e17a68b7e9379a51b353 Mon Sep 17 00:00:00 2001 From: Desuuuu Date: Sun, 22 May 2022 18:15:34 +0200 Subject: [PATCH] pin_resolver: Add hardware interface reservation --- klippy/pins.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/klippy/pins.py b/klippy/pins.py index 35fc58a2..b32331be 100644 --- a/klippy/pins.py +++ b/klippy/pins.py @@ -19,6 +19,7 @@ class PinResolver: def __init__(self, validate_aliases=True): self.validate_aliases = validate_aliases self.reserved = {} + self.reserved_interfaces = {} self.aliases = {} self.active_pins = {} def reserve_pin(self, pin, reserve_name): @@ -26,6 +27,13 @@ class PinResolver: raise error("Pin %s reserved for %s - can't reserve for %s" % ( pin, self.reserved[pin], reserve_name)) self.reserved[pin] = reserve_name + def reserve_interface(self, interface, reserve_name): + if (interface in self.reserved_interfaces + and self.reserved_interfaces[interface] != reserve_name): + raise error("Interface %s reserved for %s - can't reserve for %s" + % (interface, self.reserved_interfaces[interface], + reserve_name)) + self.reserved_interfaces[interface] = reserve_name def alias_pin(self, alias, pin): if alias in self.aliases and self.aliases[alias] != pin: raise error("Alias %s mapped to %s - can't alias to %s" % (