diff --git a/common/gpio.py b/common/gpio.py index 5ec23bf7b..88a9479a6 100644 --- a/common/gpio.py +++ b/common/gpio.py @@ -1,3 +1,4 @@ +import os from functools import lru_cache from typing import Optional, List @@ -26,6 +27,9 @@ def gpio_read(pin: int) -> Optional[bool]: return val def gpio_export(pin: int) -> None: + if os.path.isdir(f"/sys/class/gpio/gpio{pin}"): + return + try: with open("/sys/class/gpio/export", 'w') as f: f.write(str(pin))