Variscite is introducing support for libgpiod, the new and recommended way for accessing GPIO from userspace. libgpiod was introduced in Linux 4.8 and provides both command line utilities and library bindings for C/C++ and Python. Variscite has added libgpiod support to all software releases starting from Yocto Dunfell, Boot2Qt Dunfell, and Debian Bullseye.
Previously, the recommended way of accessing GPIOs from Linux userspace was using the GPIO sysfs interface, which is limited and requires custom userspace libraries for higher level programming languages like C, C++, Python, etc.
Moving forward, the sysfs interface is being deprecated. For now, it will continue to be maintained, but no new features will be added. Please monitor the kernel documentation for the latest information.
Instead, it is now recommended to use libgpiod.
libgpiod has several significant improvements over the GPIO sysfs interface:
- Userspace libraries for C/C++ and Python provide a standardized API
- Each GPIO controller is registered as a character device in /dev so GPIO allocation is tied to the process that is using it
- Multiple GPIO pins can be read at once
- GPIO controllers and pins can be found by name
- GPIO pin settings can be configured at runtime (pull-up, pull-down, etc.)
- Interrupt driven event monitoring (rising, falling, etc.)