GPIO control through libgpiod using the command gpiocli

Since /sys/class/gpio is deprecated, we need to use libgpiod to take control over the gpio pins.

However, using the command gpioset to set the output on a gpio-pin, it is not persistent! After the gpioset command is finished, the state of the pin is undetermined (either unchanged or set to default). The lock on the pin is released and the state of the pin is uncertain.

So they have come up with a dbus-daemon: Implement DBus API #47

It is however still a RFC patch. So you’ll need to build it from source here:

https://github.com/brgl/libgpiod-private/tree/topic/dbus

On archlinuxarm I have a prebuild package for it, so install with:

pacman -Syu libgpiod-dbus-git

Then do:

systemctl start gpio-manager
systemctl enable gpio-manager

Then you’re all set to use the gpiocli command.

I just build the package, so I also still need to try it out…

[root@rk3588 ~]# gpiocli --help
Usage:
  gpiocli [OPTION?] CMD [ARGS?] ...

Simple command-line client for controlling gpio-manager.

...

Available commands:
  detect - list GPIO chips and print their properties
  find - take a line name and find its parent chip's name and offset within it
  info - print information about GPIO lines
  get - get values of GPIO lines
  monitor - notify the user about edge events
  notify - notify the user about line property changes
  reconfigure - change the line configuration for an existing request
  release - release one of the line requests controlled by the manager
  request - request a set of GPIO lines for exclusive usage by the manager
  requests - list all line requests controlled by the manager
  set - set values of GPIO lines
  wait - wait for the gpio-manager interface to appear
1 Like