Functions allowing interactions with requested lines.
More...
|
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...
|
|
Functions allowing interactions with requested lines.
◆ gpiod_line_request_get_fd()
Get the file descriptor associated with a line request.
- Parameters
-
request | GPIO 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()
Get the number of lines in the request.
- Parameters
-
request | Line 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
-
request | Line request object. |
offsets | Array to store offsets. |
max_offsets | Number 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()
Get the value of a single requested line.
- Parameters
-
request | Line request object. |
offset | The 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()
Get the values of all requested lines.
- Parameters
-
- Returns
- 0 on success, -1 on failure.
◆ gpiod_line_request_get_values_subset()
Get the values of a subset of requested lines.
- Parameters
-
request | GPIO line request. |
num_values | Number of lines for which to read values. |
offsets | Array of offsets identifying the subset of requested lines from which to read values. |
values | Array 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()
Read a number of edge events from a line request.
- Parameters
-
request | GPIO line request. |
buffer | Edge event buffer, sized to hold at least max_events . |
max_events | Maximum 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()
Update the configuration of lines associated with a line request.
- Parameters
-
request | GPIO line request. |
config | New 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()
Release the requested lines and free all associated resources.
- Parameters
-
request | Line request object to release. |
◆ gpiod_line_request_set_value()
Set the value of a single requested line.
- Parameters
-
request | Line request object. |
offset | The offset of the line for which the value should be set. |
value | Value to set. |
◆ gpiod_line_request_set_values()
Set the values of all lines associated with a request.
- Parameters
-
◆ gpiod_line_request_set_values_subset()
Set the values of a subset of requested lines.
- Parameters
-
request | GPIO line request. |
num_values | Number of lines for which to set values. |
offsets | Array of offsets, containing the number of entries specified by num_values , identifying the requested lines for which to set values. |
values | Array 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
-
request | GPIO line request. |
timeout_ns | Wait 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.