Re: [libgpiod] How to gets gpio status but does not change it

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

 



On Fri, Dec 15, 2023 at 07:49:19AM +0000, 18711529674@xxxxxxx 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.




[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