libgpiod  0.3.2
Data Structures | Enumerations | Functions
Line event operations

Functions and data structures for requesting and reading GPIO line events. More...

Collaboration diagram for Line event operations:

Data Structures

struct  gpiod_line_evreq_config
 Structure holding configuration of a line event request. More...
 
struct  gpiod_line_event
 Structure holding event info. More...
 

Enumerations

enum  { GPIOD_EVENT_RISING_EDGE, GPIOD_EVENT_FALLING_EDGE, GPIOD_EVENT_BOTH_EDGES }
 Event types. More...
 

Functions

int gpiod_line_event_request (struct gpiod_line *line, struct gpiod_line_evreq_config *config) GPIOD_API
 Request event notifications for a single line. More...
 
int gpiod_line_event_request_rising (struct gpiod_line *line, const char *consumer, bool active_low) GPIOD_API
 Request rising edge event notifications on a single line. More...
 
int gpiod_line_event_request_falling (struct gpiod_line *line, const char *consumer, bool active_low) GPIOD_API
 Request falling edge event notifications on a single line. More...
 
int gpiod_line_event_request_all (struct gpiod_line *line, const char *consumer, bool active_low) GPIOD_API
 Request all event type notifications on a single line. More...
 
void gpiod_line_event_release (struct gpiod_line *line) GPIOD_API
 Stop listening for events and release the line. More...
 
bool gpiod_line_event_configured (struct gpiod_line *line) GPIOD_API
 Check if event notifications are configured on this line. More...
 
int gpiod_line_event_wait (struct gpiod_line *line, const struct timespec *timeout) GPIOD_API
 Wait for an event on a single line. More...
 
int gpiod_line_event_wait_bulk (struct gpiod_line_bulk *bulk, const struct timespec *timeout, struct gpiod_line **line) GPIOD_API
 Wait for the first event on a set of lines. More...
 
int gpiod_line_event_read (struct gpiod_line *line, struct gpiod_line_event *event) GPIOD_API
 Read the last event from the GPIO line. More...
 
int gpiod_line_event_get_fd (struct gpiod_line *line) GPIOD_API
 Get the event file descriptor. More...
 
int gpiod_line_event_read_fd (int fd, struct gpiod_line_event *event) GPIOD_API
 Read the last GPIO event directly from a file descriptor. More...
 

Detailed Description

Functions and data structures for requesting and reading GPIO line events.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

Event types.

Enumerator
GPIOD_EVENT_RISING_EDGE 

Rising edge event.

GPIOD_EVENT_FALLING_EDGE 

Falling edge event.

GPIOD_EVENT_BOTH_EDGES 

Rising or falling edge event: only relevant for event requests.

Definition at line 626 of file gpiod.h.

Function Documentation

◆ gpiod_line_event_configured()

bool gpiod_line_event_configured ( struct gpiod_line *  line)

Check if event notifications are configured on this line.

Parameters
lineGPIO line object.
Returns
True if event notifications are configured. False otherwise.

◆ gpiod_line_event_get_fd()

int gpiod_line_event_get_fd ( struct gpiod_line *  line)

Get the event file descriptor.

Parameters
lineGPIO line object.
Returns
Number of the event file descriptor or -1 on error.

Users may want to poll the event file descriptor on their own. This routine allows to access it.

◆ gpiod_line_event_read()

int gpiod_line_event_read ( struct gpiod_line *  line,
struct gpiod_line_event event 
)

Read the last event from the GPIO line.

Parameters
lineGPIO line object.
eventBuffer to which the event data will be copied.
Returns
0 if the event was read correctly, -1 on error.

◆ gpiod_line_event_read_fd()

int gpiod_line_event_read_fd ( int  fd,
struct gpiod_line_event event 
)

Read the last GPIO event directly from a file descriptor.

Parameters
fdFile descriptor.
eventBuffer to which the event data will be copied.
Returns
0 if the event was read correctly, -1 on error.

Users who directly poll the file descriptor for incoming events can also directly read the event data from it using this routine. This function translates the kernel representation of the event to the libgpiod format.

◆ gpiod_line_event_release()

void gpiod_line_event_release ( struct gpiod_line *  line)

Stop listening for events and release the line.

Parameters
lineGPIO line object.

◆ gpiod_line_event_request()

int gpiod_line_event_request ( struct gpiod_line *  line,
struct gpiod_line_evreq_config config 
)

Request event notifications for a single line.

Parameters
lineGPIO line object.
configEvent request configuration.
Returns
0 if the operation succeeds. In case of an error this routine returns -1 and sets the last error number.

◆ gpiod_line_event_request_all()

int gpiod_line_event_request_all ( struct gpiod_line *  line,
const char *  consumer,
bool  active_low 
)

Request all event type notifications on a single line.

Parameters
lineGPIO line object.
consumerName of the consumer.
active_lowActive state of the line - true if low.
Returns
0 if the operation succeeds, -1 on failure.

◆ gpiod_line_event_request_falling()

int gpiod_line_event_request_falling ( struct gpiod_line *  line,
const char *  consumer,
bool  active_low 
)

Request falling edge event notifications on a single line.

Parameters
lineGPIO line object.
consumerName of the consumer.
active_lowActive state of the line - true if low.
Returns
0 if the operation succeeds, -1 on failure.

◆ gpiod_line_event_request_rising()

int gpiod_line_event_request_rising ( struct gpiod_line *  line,
const char *  consumer,
bool  active_low 
)

Request rising edge event notifications on a single line.

Parameters
lineGPIO line object.
consumerName of the consumer.
active_lowActive state of the line - true if low.
Returns
0 if the operation succeeds, -1 on failure.

◆ gpiod_line_event_wait()

int gpiod_line_event_wait ( struct gpiod_line *  line,
const struct timespec *  timeout 
)

Wait for an event on a single line.

Parameters
lineGPIO line object.
timeoutWait time limit.
Returns
0 if wait timed out, -1 if an error occurred, 1 if an event occurred.

◆ gpiod_line_event_wait_bulk()

int gpiod_line_event_wait_bulk ( struct gpiod_line_bulk bulk,
const struct timespec *  timeout,
struct gpiod_line **  line 
)

Wait for the first event on a set of lines.

Parameters
bulkSet of GPIO lines to monitor.
timeoutWait time limit.
lineThe handle of the line on which an event occurs is stored in this variable. Can be NULL.
Returns
0 if wait timed out, -1 if an error occurred, 1 if an event occurred.