linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kent Gibson <warthog618@gmail.com>
To: "18711529674@163.com" <18711529674@163.com>
Cc: "linux-gpio@vger.kernel.org" <linux-gpio@vger.kernel.org>
Subject: Re: [libgpiod] How to gets gpio status but does not change it
Date: Fri, 15 Dec 2023 18:14:59 +0800	[thread overview]
Message-ID: <ZXwnIwtsQ2mf8L1C@rigel> (raw)
In-Reply-To: <TYZPR01MB462621CF5B056907A3340C1FF193A@TYZPR01MB4626.apcprd01.prod.exchangelabs.com>

On Fri, Dec 15, 2023 at 07:49:19AM +0000, 18711529674@163.com wrote:
> Hello.
>
>     According to the example get_line_value. I try to request the status of the gpio, but the return is always low.
>     try 
>       gpiod_line_settings_set_direction(settings, GPIOD_LINE_DIRECTION_AS_IS);
>   or
>       gpiod_line_settings_set_direction(settings, GPIOD_LINE_DIRECTION_INPUT);
>   Their result is always low
>
>   Is there any way to get the correct value without changing the original state?
>
>                                            Thank you in advance for your time.

By status you mean the electrical level of the line?
That is returned by this line from the example:

        value = gpiod_line_request_get_value(request, line_offset);

The gpiod_line_settings_set_direction() controls whether the line is
expected to electrically be an input or output or, in the case of
GPIOD_LINE_DIRECTION_AS_IS, left unchanged.
When the line is requested by gpiod_chip_request_lines() those settings
will be applied.

Assuming your line is already configured an input, neither of the examples
you provide would change the electrical settings of the line, so you are
already doing what you have asked for.

Are you sure you have the correct line?
Have you confirmed that the line is being pulled high externally?
What does gpioinfo report for that line?
Have you tried using gpioget on that line to see what value it reports?

Cheers,
Kent.

      reply	other threads:[~2023-12-15 10:15 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-15  7:49 How to gets gpio status but does not change it 18711529674
2023-12-15 10:14 ` 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=ZXwnIwtsQ2mf8L1C@rigel \
    --to=warthog618@gmail.com \
    --cc=18711529674@163.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).