linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* How to gets gpio status but does not change it
@ 2023-12-15  7:49 18711529674
  2023-12-15 10:14 ` [libgpiod] " Kent Gibson
  0 siblings, 1 reply; 2+ messages in thread
From: 18711529674 @ 2023-12-15  7:49 UTC (permalink / raw)
  To: linux-gpio@vger.kernel.org

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.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [libgpiod] How to gets gpio status but does not change it
  2023-12-15  7:49 How to gets gpio status but does not change it 18711529674
@ 2023-12-15 10:14 ` Kent Gibson
  0 siblings, 0 replies; 2+ messages in thread
From: Kent Gibson @ 2023-12-15 10:14 UTC (permalink / raw)
  To: 18711529674@163.com; +Cc: linux-gpio@vger.kernel.org

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.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-12-15 10:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-15  7:49 How to gets gpio status but does not change it 18711529674
2023-12-15 10:14 ` [libgpiod] " Kent Gibson

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).