Re: How to set GPIOs persistently high with libgpiod

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jul 10, 2024 at 10:36:08PM +0000, Akash Borde wrote:
> Hi!
>
> I wanted to look for a way that we can set output values for gpios using Linux’s libgpiod library such that we can write a value to a (chip,pin) combo and be able to read the value we wrote from that same pin.
>
> For example,
>
> heila@device# gpioset gpiochip4 29=1 ### Sets GPIO Output Pin to 1
> heila@device# gpioget gpiochip4 29 0 ### Reads a 0 at the same Output Pin
>

There is no way to do that with the libgpiod v1 tools that you are using.
It can be done with the library directly, but you need to write some code.

With the libgpiod v2 tools there is a --as-is option on gpioget that
does not switch the line to an input and so can read back the output value.
Note though that the value of an output AFTER gpioset exits depends on
the device driver, so it may get reset to its default value.  YMMV.

And there is a gpio-manager daemon in development that would provide a
solution independent of the driver.

> Happy to provide more details on our hardware/product/application if that’s needed as well.
>

Generally speaking you shouldn't use GPIO outputs as a persistent store.
Have a process manage the line.

> I’m not sure if this email address is monitored, please let me know if there is another one I should reach out to.
> https://manpages.debian.org/testing/gpiod/gpioset.1.en.html I found the email at the bottom of this manpage.
>

That email address is correct, though it would be helpful to prefix the
subject with [libgpiod], as per the CONTRIBUTING section of the README[1],
as the list also serves other purposes.

Cheers,
Kent.
[1] https://github.com/brgl/libgpiod





[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux