libgpiod  2.0.1
Public Member Functions
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. More...
 
line_requestoperator= (const line_request &other)=delete
 
line_requestoperator= (line_request &&other) noexcept
 Move assignment operator. More...
 
 operator bool () const noexcept
 Check if this object is valid. More...
 
void release ()
 Release the GPIO chip and free all associated resources. More...
 
::std::size_t num_lines () const
 Get the number of requested lines. More...
 
line::offsets offsets () const
 Get the list of offsets of requested lines. More...
 
line::value get_value (line::offset offset)
 Get the value of a single requested line. More...
 
line::values get_values (const line::offsets &offsets)
 Get the values of a subset of requested lines. More...
 
line::values get_values ()
 Get the values of all requested lines. More...
 
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. More...
 
void get_values (line::values &values)
 Get the values of all requested lines. More...
 
line_requestset_value (line::offset offset, line::value value)
 Set the value of a single requested line. More...
 
line_requestset_values (const line::value_mappings &values)
 Set the values of a subset of requested lines. More...
 
line_requestset_values (const line::offsets &offsets, const line::values &values)
 Set the values of a subset of requested lines. More...
 
line_requestset_values (const line::values &values)
 Set the values of all requested lines. More...
 
line_requestreconfigure_lines (const line_config &config)
 Apply new config options to requested lines. More...
 
int fd () const
 Get the file descriptor number associated with this line request. More...
 
bool wait_edge_events (const ::std::chrono::nanoseconds &timeout) const
 Wait for edge events on any of the lines requested with edge detection enabled. More...
 
::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. More...
 
::std::size_t read_edge_events (edge_event_buffer &buffer, ::std::size_t max_events)
 Read a number of edge events from this request. More...
 

Detailed Description

Stores the context of a set of requested GPIO lines.

Definition at line 37 of file line-request.hpp.

Constructor & Destructor Documentation

◆ line_request()

gpiod::line_request::line_request ( line_request &&  other)
noexcept

Move constructor.

Parameters
otherObject to move.

Member Function Documentation

◆ 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
offsetOffset 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
offsetsVector 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
offsetsVector of line offsets.
valuesVector 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
valuesArray 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
explicitnoexcept

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=()

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

Move assignment operator.

Parameters
otherObject 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
bufferEdge 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
bufferEdge event buffer to read events into.
max_eventsMaximum 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
configNew configuration.
Returns
Reference to self.

◆ release()

void gpiod::line_request::release ( )

Release the GPIO chip 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
offsetOffset of the line to set within the chip.
valueNew 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
offsetsVector containing the offsets of lines to set.
valuesVector 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
valuesVector 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
valuesArray 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
timeoutWait time limit in nanoseconds.
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: