Loading...
Searching...
No Matches
Line edge events handling

## Enumerations

enum | gpiod_edge_event_type { GPIOD_EDGE_EVENT_RISING_EDGE = 1 , GPIOD_EDGE_EVENT_FALLING_EDGE }
| Event types. More...

## Functions

void | gpiod_edge_event_free (struct gpiod_edge_event *event)
| Free the edge event object.
struct gpiod_edge_event * | gpiod_edge_event_copy (struct gpiod_edge_event *event)
| Copy the edge event object.
enum gpiod_edge_event_type | gpiod_edge_event_get_event_type (struct gpiod_edge_event *event)
| Get the event type.
uint64_t | gpiod_edge_event_get_timestamp_ns (struct gpiod_edge_event *event)
| Get the timestamp of the event.
unsigned int | gpiod_edge_event_get_line_offset (struct gpiod_edge_event *event)
| Get the offset of the line which triggered the event.
unsigned long | gpiod_edge_event_get_global_seqno (struct gpiod_edge_event *event)
| Get the global sequence number of the event.
unsigned long | gpiod_edge_event_get_line_seqno (struct gpiod_edge_event *event)
| Get the event sequence number specific to the line.
struct gpiod_edge_event_buffer * | gpiod_edge_event_buffer_new (size_t capacity)
| Create a new edge event buffer.
size_t | gpiod_edge_event_buffer_get_capacity (struct gpiod_edge_event_buffer *buffer)
| Get the capacity (the max number of events that can be stored) of the event buffer.
void | gpiod_edge_event_buffer_free (struct gpiod_edge_event_buffer *buffer)
| Free the edge event buffer and release all associated resources.
struct gpiod_edge_event * | gpiod_edge_event_buffer_get_event (struct gpiod_edge_event_buffer *buffer, unsigned long index)
| Get an event stored in the buffer.
size_t | gpiod_edge_event_buffer_get_num_events (struct gpiod_edge_event_buffer *buffer)
| Get the number of events a buffer has stored.

## Detailed Description

Functions and data types for handling edge events.

An edge event object contains information about a single line edge event. It contains the event type, timestamp and the offset of the line on which the event occurred as well as two sequence numbers (global for all lines in the associated request and local for this line only).

Edge events are stored into an edge-event buffer object to improve performance and to limit the number of memory allocations when a large number of events are being read.

## Enumeration Type Documentation

## gpiod_edge_event_type

enum gpiod_edge_event_type

Event types.

Enumerator
GPIOD_EDGE_EVENT_RISING_EDGE | Rising edge event.
GPIOD_EDGE_EVENT_FALLING_EDGE | Falling edge event.

## Function Documentation

## gpiod_edge_event_buffer_free()

void gpiod_edge_event_buffer_free | ( | struct gpiod_edge_event_buffer * | buffer | ) |

Free the edge event buffer and release all associated resources.

Parameters

  buffer | Edge event buffer to free.

## gpiod_edge_event_buffer_get_capacity()

size_t gpiod_edge_event_buffer_get_capacity | ( | struct gpiod_edge_event_buffer * | buffer | ) |

Get the capacity (the max number of events that can be stored) of the event buffer.

Parameters

  buffer | Edge event buffer.

Returns
  The capacity of the buffer.

## gpiod_edge_event_buffer_get_event()

struct gpiod_edge_event * gpiod_edge_event_buffer_get_event | ( | struct gpiod_edge_event_buffer * | buffer,
|  | unsigned long | index )

Get an event stored in the buffer.

Parameters

  buffer | Edge event buffer.
  index | Index of the event in the buffer.

Returns
  Pointer to an event stored in the buffer. The lifetime of the event is tied to the buffer object. Users must not free the event returned by this function.

Warning
  Thread-safety: Since events are tied to the buffer instance, different threads may not operate on the buffer and any associated events at the same time. Events can be copied using gpiod_edge_event_copy in order to create a standalone objects - which each may safely be used from a different thread concurrently.

## gpiod_edge_event_buffer_get_num_events()

size_t gpiod_edge_event_buffer_get_num_events | ( | struct gpiod_edge_event_buffer * | buffer | ) |

Get the number of events a buffer has stored.

Parameters

  buffer | Edge event buffer.

Returns
  Number of events stored in the buffer.

## gpiod_edge_event_buffer_new()

struct gpiod_edge_event_buffer * gpiod_edge_event_buffer_new | ( | size_t | capacity | ) |

Create a new edge event buffer.

Parameters

  capacity | Number of events the buffer can store (min = 1, max = 1024).

Returns
  New edge event buffer or NULL on error.

Note
  If capacity equals 0, it will be set to a default value of 64. If capacity is larger than 1024, it will be limited to 1024.
  The user space buffer is independent of the kernel buffer (gpiod_request_config_set_event_buffer_size). As the user space buffer is filled from the kernel buffer, there is no benefit making the user space buffer larger than the kernel buffer. The default kernel buffer size for each request is (16 * num_lines).

## gpiod_edge_event_copy()

struct gpiod_edge_event * gpiod_edge_event_copy | ( | struct gpiod_edge_event * | event | ) |

Copy the edge event object.

Parameters

  event | Edge event to copy.

Returns
  Copy of the edge event or NULL on error. The returned object must be freed by the caller using gpiod_edge_event_free.

## gpiod_edge_event_free()

void gpiod_edge_event_free | ( | struct gpiod_edge_event * | event | ) |

Free the edge event object.

Parameters

  event | Edge event object to free.

## gpiod_edge_event_get_event_type()

enum gpiod_edge_event_type gpiod_edge_event_get_event_type | ( | struct gpiod_edge_event * | event | ) |

Get the event type.

Parameters

  event | GPIO edge event.

Returns
  The event type (GPIOD_EDGE_EVENT_RISING_EDGE or GPIOD_EDGE_EVENT_FALLING_EDGE).

## gpiod_edge_event_get_global_seqno()

unsigned long gpiod_edge_event_get_global_seqno | ( | struct gpiod_edge_event * | event | ) |

Get the global sequence number of the event.

Parameters

  event | GPIO edge event.

Returns
  Sequence number of the event in the series of events for all lines in the associated line request.

## gpiod_edge_event_get_line_offset()

unsigned int gpiod_edge_event_get_line_offset | ( | struct gpiod_edge_event * | event | ) |

Get the offset of the line which triggered the event.

Parameters

  event | GPIO edge event.

Returns
  Line offset.

## gpiod_edge_event_get_line_seqno()

unsigned long gpiod_edge_event_get_line_seqno | ( | struct gpiod_edge_event * | event | ) |

Get the event sequence number specific to the line.

Parameters

  event | GPIO edge event.

Returns
  Sequence number of the event in the series of events only for this line within the lifetime of the associated line request.

## gpiod_edge_event_get_timestamp_ns()

uint64_t gpiod_edge_event_get_timestamp_ns | ( | struct gpiod_edge_event * | event | ) |

Get the timestamp of the event.

Parameters

  event | GPIO edge event.

Returns
  Timestamp in nanoseconds.

Note
  The source clock for the timestamp depends on the event_clock setting for the line.