Loading...
Searching...
No Matches
gpiod::line_request Class Referencefinal

Stores the context of a set of requested GPIO lines. More...

`#include <line-request.hpp>`

## Public Member Functions

| line_request (const line_request &other)=delete
| line_request (line_request &&other) noexcept
| Move constructor.
| ~line_request ()
line_request & | operator= (const line_request &other)=delete
line_request & | operator= (line_request &&other) noexcept
| Move assignment operator.
| operator bool () const noexcept
| Check if this object is valid.
void | release ()
| Release the requested lines and free all associated resources.
::std::string | chip_name () const
| Get the name of the chip this request was made on.
::std::size_t | num_lines () const
| Get the number of requested lines.
line::offsets | offsets () const
| Get the list of offsets of requested lines.
line::value | get_value (line::offset offset)
| Get the value of a single requested line.
line::values | get_values (const line::offsets &offsets)
| Get the values of a subset of requested lines.
line::values | get_values ()
| Get the values of all requested lines.
void | get_values (const line::offsets &offsets, line::values &values)
| Get the values of a subset of requested lines into a vector supplied by the caller.
void | get_values (line::values &values)
| Get the values of all requested lines.
line_request & | set_value (line::offset offset, line::value value)
| Set the value of a single requested line.
line_request & | set_values (const line::value_mappings &values)
| Set the values of a subset of requested lines.
line_request & | set_values (const line::offsets &offsets, const line::values &values)
| Set the values of a subset of requested lines.
line_request & | set_values (const line::values &values)
| Set the values of all requested lines.
line_request & | reconfigure_lines (const line_config &config)
| Apply new config options to requested lines.
int | fd () const
| Get the file descriptor number associated with this line request.
bool | wait_edge_events (const ::std::chrono::nanoseconds &timeout) const
| Wait for edge events on any of the lines requested with edge detection enabled.
::std::size_t | read_edge_events (edge_event_buffer &buffer)
| Read a number of edge events from this request up to the maximum capacity of the buffer.
::std::size_t | read_edge_events (edge_event_buffer &buffer, ::std::size_t max_events)
| Read a number of edge events from this request.

## Detailed Description

Stores the context of a set of requested GPIO lines.

## Constructor & Destructor Documentation

## line_request() [1/2]

gpiod::line_request::line_request | ( | const line_request & | other | ) |

delete

## line_request() [2/2]

gpiod::line_request::line_request | ( | line_request && | other | ) |

noexcept

Move constructor.

Parameters

  other | Object to move.

## ~line_request()

gpiod::line_request::~line_request | ( |  | ) |

## Member Function Documentation

## chip_name()

::std::string gpiod::line_request::chip_name | ( |  | ) | const

Get the name of the chip this request was made on.

Returns
  Name to the GPIO chip.

## fd()

int gpiod::line_request::fd | ( |  | ) | const

Get the file descriptor number associated with this line request.

Returns
  File descriptor number.

## get_value()

line::value gpiod::line_request::get_value | ( | line::offset | offset | ) |

Get the value of a single requested line.

Parameters

  offset | Offset of the line to read within the chip.

Returns
  Current line value.

## get_values() [1/4]

line::values gpiod::line_request::get_values | ( |  | ) |

Get the values of all requested lines.

Returns
  List of read values.

## get_values() [2/4]

line::values gpiod::line_request::get_values | ( | const line::offsets & | offsets | ) |

Get the values of a subset of requested lines.

Parameters

  offsets | Vector of line offsets

Returns
  Vector of lines values with indexes of values corresponding to those of the offsets.

## get_values() [3/4]

void gpiod::line_request::get_values | ( | const line::offsets & | offsets,
|  | line::values & | values )

Get the values of a subset of requested lines into a vector supplied by the caller.

Parameters

  offsets | Vector of line offsets.
  values | Vector for storing the values. Its size must be at least that of the offsets vector. The indexes of read values will correspond with those in the offsets vector.

## get_values() [4/4]

void gpiod::line_request::get_values | ( | line::values & | values | ) |

Get the values of all requested lines.

Parameters

  values | Array in which the values will be stored. Must hold at least the number of elements returned by line_request::num_lines.

## num_lines()

::std::size_t gpiod::line_request::num_lines | ( |  | ) | const

Get the number of requested lines.

Returns
  Number of lines in this request.

## offsets()

line::offsets gpiod::line_request::offsets | ( |  | ) | const

Get the list of offsets of requested lines.

Returns
  List of hardware offsets of the lines in this request.

## operator bool()

gpiod::line_request::operator bool | ( |  | ) | const

explicit noexcept

Check if this object is valid.

Returns
  True if this object's methods can be used, false otherwise. False usually means the request was released. If the user calls any of the methods of this class on an object for which this operator returned false, a logic_error will be thrown.

## operator=() [1/2]

line_request & gpiod::line_request::operator= | ( | const line_request & | other | ) |

delete

## operator=() [2/2]

line_request & gpiod::line_request::operator= | ( | line_request && | other | ) |

noexcept

Move assignment operator.

Parameters

  other | Object to move.

Returns
  Reference to self.

## read_edge_events() [1/2]

::std::size_t gpiod::line_request::read_edge_events | ( | edge_event_buffer & | buffer | ) |

Read a number of edge events from this request up to the maximum capacity of the buffer.

Parameters

  buffer | Edge event buffer to read events into.

Returns
  Number of events read.

## read_edge_events() [2/2]

::std::size_t gpiod::line_request::read_edge_events | ( | edge_event_buffer & | buffer,
|  | ::std::size_t | max_events )

Read a number of edge events from this request.

Parameters

  buffer | Edge event buffer to read events into.
  max_events | Maximum number of events to read. Limited by the capacity of the buffer.

Returns
  Number of events read.

## reconfigure_lines()

line_request & gpiod::line_request::reconfigure_lines | ( | const line_config & | config | ) |

Apply new config options to requested lines.

Parameters

  config | New configuration.

Returns
  Reference to self.

## release()

void gpiod::line_request::release | ( |  | ) |

Release the requested lines and free all associated resources.

Note
  The object can still be used after this method is called but using any of the mutators will result in throwing a logic_error exception.

## set_value()

line_request & gpiod::line_request::set_value | ( | line::offset | offset,
|  | line::value | value )

Set the value of a single requested line.

Parameters

  offset | Offset of the line to set within the chip.
  value | New line value.

Returns
  Reference to self.

## set_values() [1/3]

line_request & gpiod::line_request::set_values | ( | const line::offsets & | offsets,
|  | const line::values & | values )

Set the values of a subset of requested lines.

Parameters

  offsets | Vector containing the offsets of lines to set.
  values | Vector containing new values with indexes corresponding with those in the offsets vector.

Returns
  Reference to self.

## set_values() [2/3]

line_request & gpiod::line_request::set_values | ( | const line::value_mappings & | values | ) |

Set the values of a subset of requested lines.

Parameters

  values | Vector containing a set of offset->value mappings.

Returns
  Reference to self.

## set_values() [3/3]

line_request & gpiod::line_request::set_values | ( | const line::values & | values | ) |

Set the values of all requested lines.

Parameters

  values | Array of new line values. The size must be equal to the value returned by line_request::num_lines.

Returns
  Reference to self.

## wait_edge_events()

bool gpiod::line_request::wait_edge_events | ( | const ::std::chrono::nanoseconds & | timeout | ) | const

Wait for edge events on any of the lines requested with edge detection enabled.

Parameters

  timeout | Wait time limit in nanoseconds. If set to 0, the function returns immediately. If set to a negative number, the function blocks indefinitely until an event becomes available.

Returns
  True if at least one event is ready to be read. False if the wait timed out.

The documentation for this class was generated from the following file:

- line-request.hpp