GPIO_GetValue Function

Header: #include <applibs/gpio.h>

Gets the current value of a GPIO.

GPIO functions are thread-safe between calls to different GPIOs; however, it is the caller’s responsibility to ensure thread safety for accesses to the same GPIO.

int GPIO_GetValue(int gpioFd, GPIO_Value_Type *outValue);

Parameters

  • gpioFd The file descriptor for the GPIO.

  • outValue The GPIO_Value read from the GPIO - GPIO_Value_High or GPIO_Value_Low.

Errors

Returns -1 if an error is encountered and sets errno to the error value.

  • EFAULT: the outValue is NULL.

  • EBADF: the gpioFd is not valid.

Any other errno may also be specified; such errors aren't deterministic and the same behavior might not be retained through system updates.

Return value

Returns 0 for success, or -1 for failure, in which case errno will be set to the error value.

Application manifest requirements

To access individual GPIOs, your application must identify them in the Gpio field of the application manifest.