public inbox for linux-gpio@vger.kernel.org
 help / color / mirror / Atom feed
From: Kent Gibson <warthog618@gmail.com>
To: Mathis Joussemet <joussemetmathis@gmail.com>
Cc: linux-gpio@vger.kernel.org
Subject: Re: Help regarding IO configuration of multiple lines
Date: Tue, 31 Mar 2026 22:33:55 +0800	[thread overview]
Message-ID: <20260331143355.GA64085@rigel> (raw)
In-Reply-To: <CAOdiGsteopFY2-A9X65cBxMKbW9uWeZvfaKbMhwFT1E5gceOLQ@mail.gmail.com>

On Tue, Mar 31, 2026 at 03:23:16PM +0200, Mathis Joussemet wrote:
> Hi Kent,
> 
> Sorry for the late reply, was up until now in exam hell.
> It indeed works! I can now drive 2 LEDs at the same time!
> 
> I just have 2 new questions:
> - I am now using a button to toggle one of the two LEDs by checking the
> buttons value using
> gpiod_line_request_get_value(request, offset[2])!=0)
> in a if statement.

I don't see any obvious reason that wouldn't read the button, assuming it is
the third line in your offset array, and the condition is tested at the time
you are pushing the button.

Have you tried the equivalent with the gpiod tools (gpioget) or some of the
example code (e.g. get_line_value) to confirm your hardware setup is working
as expected?

> I've setup the correct input bias, but when I press on
> it, the LED doesn't toggle. Checking with a scope still shows the voltage
> jumping to 3.3v when pressed and 0v at other times. Is there something I'm
> missing?

That being the input voltage?  For an input pulled down when the button is
not pressed and pulled high when it is pressed?
That is what I would expect to see.

> - I'm trying to switch from an snapshot based line change reporting to an
> event one. however when using a watch line event before/after the request,
> the program still blocks. How should i code it to prevent blocking while
> still having infos like output values types when there is a change?
> 

You can use edge events in a polling scenario by testing if the request
fd is ready to read using poll() or select() or similar.
It will become ready when an event is available.
You can then read the event as usual and the read will not block.
So similar to the async_watch_line_value example, but with a 0 timeout in
the poll() and checking the ret:

  ret = poll(&pollfd, 1, 0);
  if (ret > 0) {
    // read event...
  }

and doing whatever else you want in the polling loop.

Cheers,
Kent.

      reply	other threads:[~2026-03-31 14:34 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-06 11:09 Help regarding IO configuration of multiple lines joussemetmathis
2026-03-07  2:13 ` Kent Gibson
2026-03-31 13:23   ` Mathis Joussemet
2026-03-31 14:33     ` 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=20260331143355.GA64085@rigel \
    --to=warthog618@gmail.com \
    --cc=joussemetmathis@gmail.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