libgpiod  2.0.1
Functions
Line request operations

Functions allowing interactions with requested lines. More...

Functions

void gpiod_line_request_release (struct gpiod_line_request *request)
 Release the requested lines and free all associated resources. More...
 
size_t gpiod_line_request_get_num_requested_lines (struct gpiod_line_request *request)
 Get the number of lines in the request. More...
 
size_t gpiod_line_request_get_requested_offsets (struct gpiod_line_request *request, unsigned int *offsets, size_t max_offsets)
 Get the offsets of the lines in the request. More...
 
enum gpiod_line_value gpiod_line_request_get_value (struct gpiod_line_request *request, unsigned int offset)
 Get the value of a single requested line. More...
 
int gpiod_line_request_get_values_subset (struct gpiod_line_request *request, size_t num_values, const unsigned int *offsets, enum gpiod_line_value *values)
 Get the values of a subset of requested lines. More...
 
int gpiod_line_request_get_values (struct gpiod_line_request *request, enum gpiod_line_value *values)
 Get the values of all requested lines. More...
 
int gpiod_line_request_set_value (struct gpiod_line_request *request, unsigned int offset, enum gpiod_line_value value)
 Set the value of a single requested line. More...
 
int gpiod_line_request_set_values_subset (struct gpiod_line_request *request, size_t num_values, const unsigned int *offsets, const enum gpiod_line_value *values)
 Set the values of a subset of requested lines. More...
 
int gpiod_line_request_set_values (struct gpiod_line_request *request, const enum gpiod_line_value *values)
 Set the values of all lines associated with a request. More...
 
int gpiod_line_request_reconfigure_lines (struct gpiod_line_request *request, struct gpiod_line_config *config)
 Update the configuration of lines associated with a line request. More...
 
int gpiod_line_request_get_fd (struct gpiod_line_request *request)
 Get the file descriptor associated with a line request. More...
 
int gpiod_line_request_wait_edge_events (struct gpiod_line_request *request, int64_t timeout_ns)
 Wait for edge events on any of the requested lines. More...
 
int gpiod_line_request_read_edge_events (struct gpiod_line_request *request, struct gpiod_edge_event_buffer *buffer, size_t max_events)
 Read a number of edge events from a line request. More...
 

Detailed Description

Functions allowing interactions with requested lines.

Function Documentation

◆ gpiod_line_request_get_fd()

int gpiod_line_request_get_fd ( struct gpiod_line_request request)

Get the file descriptor associated with a line request.

Parameters
requestGPIO line request.
Returns
The file descriptor associated with the request. This function never fails. The returned file descriptor must not be closed by the caller. Call gpiod_line_request_release to close the file.

◆ gpiod_line_request_get_num_requested_lines()

size_t gpiod_line_request_get_num_requested_lines ( struct gpiod_line_request request)

Get the number of lines in the request.

Parameters
requestLine request object.
Returns
Number of requested lines.

◆ gpiod_line_request_get_requested_offsets()

size_t gpiod_line_request_get_requested_offsets ( struct gpiod_line_request request,
unsigned int *  offsets,
size_t  max_offsets 
)

Get the offsets of the lines in the request.

Parameters
requestLine request object.
offsetsArray to store offsets.
max_offsetsNumber of offsets that can be stored in the offsets array.
Returns
Number of offsets stored in the offsets array.

If max_offsets is lower than the number of lines actually requested (this value can be retrieved using gpiod_line_request_get_num_requested_lines), then only up to max_lines offsets will be stored in offsets.

◆ gpiod_line_request_get_value()

enum gpiod_line_value gpiod_line_request_get_value ( struct gpiod_line_request request,
unsigned int  offset 
)

Get the value of a single requested line.

Parameters
requestLine request object.
offsetThe offset of the line of which the value should be read.
Returns
Returns 1 or 0 on success and -1 on error.

◆ gpiod_line_request_get_values()

int gpiod_line_request_get_values ( struct gpiod_line_request request,
enum gpiod_line_value values 
)

Get the values of all requested lines.

Parameters
requestGPIO line request.
valuesArray in which the values will be stored. Must be sized to hold the number of lines filled by gpiod_line_request_get_num_requested_lines. Each value is associated with the line identified by the corresponding entry in the offset array filled by gpiod_line_request_get_requested_offsets.
Returns
0 on success, -1 on failure.

◆ gpiod_line_request_get_values_subset()

int gpiod_line_request_get_values_subset ( struct gpiod_line_request request,
size_t  num_values,
const unsigned int *  offsets,
enum gpiod_line_value values 
)

Get the values of a subset of requested lines.

Parameters
requestGPIO line request.
num_valuesNumber of lines for which to read values.
offsetsArray of offsets identifying the subset of requested lines from which to read values.
valuesArray in which the values will be stored. Must be sized to hold num_values entries. Each value is associated with the line identified by the corresponding entry in offsets.
Returns
0 on success, -1 on failure.

◆ gpiod_line_request_read_edge_events()

int gpiod_line_request_read_edge_events ( struct gpiod_line_request request,
struct gpiod_edge_event_buffer buffer,
size_t  max_events 
)

Read a number of edge events from a line request.

Parameters
requestGPIO line request.
bufferEdge event buffer, sized to hold at least max_events.
max_eventsMaximum number of events to read.
Returns
On success returns the number of events read from the file descriptor, on failure return -1.
Note
This function will block if no event was queued for the line request.
Any exising events in the buffer are overwritten. This is not an append operation.

◆ gpiod_line_request_reconfigure_lines()

int gpiod_line_request_reconfigure_lines ( struct gpiod_line_request request,
struct gpiod_line_config config 
)

Update the configuration of lines associated with a line request.

Parameters
requestGPIO line request.
configNew line config to apply.
Returns
0 on success, -1 on failure.
Note
The new line configuration completely replaces the old.
Any requested lines without overrides are configured to the requested defaults.
Any configured overrides for lines that have not been requested are silently ignored.

◆ gpiod_line_request_release()

void gpiod_line_request_release ( struct gpiod_line_request request)

Release the requested lines and free all associated resources.

Parameters
requestLine request object to release.

◆ gpiod_line_request_set_value()

int gpiod_line_request_set_value ( struct gpiod_line_request request,
unsigned int  offset,
enum gpiod_line_value  value 
)

Set the value of a single requested line.

Parameters
requestLine request object.
offsetThe offset of the line for which the value should be set.
valueValue to set.

◆ gpiod_line_request_set_values()

int gpiod_line_request_set_values ( struct gpiod_line_request request,
const enum gpiod_line_value values 
)

Set the values of all lines associated with a request.

Parameters
requestGPIO line request.
valuesArray containing the values to set. Must be sized to contain the number of lines filled by gpiod_line_request_get_num_requested_lines. Each value is associated with the line identified by the corresponding entry in the offset array filled by gpiod_line_request_get_requested_offsets.

◆ gpiod_line_request_set_values_subset()

int gpiod_line_request_set_values_subset ( struct gpiod_line_request request,
size_t  num_values,
const unsigned int *  offsets,
const enum gpiod_line_value values 
)

Set the values of a subset of requested lines.

Parameters
requestGPIO line request.
num_valuesNumber of lines for which to set values.
offsetsArray of offsets, containing the number of entries specified by num_values, identifying the requested lines for which to set values.
valuesArray of values to set, containing the number of entries specified by num_values. Each value is associated with the line identified by the corresponding entry in offsets.
Returns
0 on success, -1 on failure.

◆ gpiod_line_request_wait_edge_events()

int gpiod_line_request_wait_edge_events ( struct gpiod_line_request request,
int64_t  timeout_ns 
)

Wait for edge events on any of the requested lines.

Parameters
requestGPIO line request.
timeout_nsWait time limit in nanoseconds. If set to 0, the function returns immediatelly. If set to a negative number, the function blocks indefinitely until an event becomes available.
Returns
0 if wait timed out, -1 if an error occurred, 1 if an event is pending. q Lines must have edge detection set for edge events to be emitted. By default edge detection is disabled.