linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kent Gibson <warthog618@gmail.com>
To: Akash Borde <Akash.Borde@heilatech.com>
Cc: "linux-gpio@vger.kernel.org" <linux-gpio@vger.kernel.org>,
	Seth Drew <Seth.Drew@heilatech.com>
Subject: Re: How to set GPIOs persistently high with libgpiod
Date: Thu, 11 Jul 2024 09:44:23 +0800	[thread overview]
Message-ID: <20240711014423.GA7963@rigel> (raw)
In-Reply-To: <SA0PR01MB61705F8B19335B41339F2260E6A42@SA0PR01MB6170.prod.exchangelabs.com>

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


      reply	other threads:[~2024-07-11  1:44 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-10 22:36 How to set GPIOs persistently high with libgpiod Akash Borde
2024-07-11  1:44 ` Kent Gibson [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240711014423.GA7963@rigel \
    --to=warthog618@gmail.com \
    --cc=Akash.Borde@heilatech.com \
    --cc=Seth.Drew@heilatech.com \
    --cc=linux-gpio@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).