Go to the documentation of this file.
8 #ifndef __LIBGPIOD_GPIOD_CXX_HPP__
9 #define __LIBGPIOD_GPIOD_CXX_HPP__
108 GPIOD_API ::std::string
name(
void)
const;
114 GPIOD_API ::std::string
label(
void)
const;
203 void throw_if_noref(
void)
const;
205 ::std::shared_ptr<::gpiod_chip> _m_chip;
312 GPIOD_API ::std::string
name(
void)
const;
395 int value = 0)
const;
523 line(::gpiod_line*
line,
const chip& owner);
525 void throw_if_null(
void)
const;
526 line_event make_line_event(const ::gpiod_line_event& event)
const noexcept;
528 ::gpiod_line* _m_line;
666 const ::std::vector<int> default_vals = ::std::vector<int>())
const;
696 const ::std::vector<int> values = ::std::vector<int>())
const;
821 iterator(const ::std::vector<line>::iterator& it);
823 ::std::vector<line>::iterator _m_iter;
842 void throw_if_empty(
void)
const;
845 ::std::vector<line> _m_bulk;
951 ::std::shared_ptr<::gpiod_chip_iter> _m_iter;
1056 ::std::shared_ptr<::gpiod_line_iter> _m_iter;
static GPIOD_API const ::std::bitset< 32 > FLAG_BIAS_DISABLE
The line has neither pull-up nor pull-down resistor enabled.
static GPIOD_API const ::std::bitset< 32 > FLAG_BIAS_PULL_UP
The line has a configurable pull-up resistor enabled.
GPIOD_API iterator & operator=(iterator &&other)=default
Move assignment operator.
GPIOD_API bool empty(void) const noexcept
Check if this line_bulk doesn't hold any lines.
int event_type
Type of the event that occurred.
GPIOD_API line_bulk event_wait(const ::std::chrono::nanoseconds &timeout) const
Poll the set of lines for line events.
GPIOD_API void set_values(const ::std::vector< int > &values) const
Set values of all lines held by this object.
@ OPEN_BY_PATH
Assume the string is a path to the GPIO chardev.
GPIOD_API chip(void)=default
Default constructor.
GPIOD_API line_iter & operator++(void)
Advance the iterator by one element.
Helper structure for storing a set of GPIO line objects.
GPIOD_API ~chip_iter(void)=default
Destructor.
GPIOD_API ::std::string name(void) const
Get the name of this line (if any).
GPIOD_API iterator & operator++(void)
Advance the iterator by one element.
GPIOD_API bool is_open_drain(void) const
Check if this line represents an open-drain GPIO.
GPIOD_API void set_direction_output(int value=0) const
Change the direction this lines to output.
friend chip_iter make_chip_iter(void)
Create a new chip_iter.
GPIOD_API const chip & get_chip(void) const
Get the reference to the parent chip.
GPIOD_API chip_iter(chip_iter &&other)=default
Move constructor.
::std::bitset< 32 > flags
Additional request flags.
GPIOD_API ::std::string name(void) const
Return the name of the chip held by this object.
GPIOD_API unsigned int offset(void) const
Get the offset of this line.
GPIOD_API line_iter & operator=(line_iter &&other)=default
Move assignment operator.
@ OPEN_BY_NAME
Assume the string is the name of the chip.
GPIOD_API iterator begin(void) noexcept
Returns an iterator to the first line.
GPIOD_API line(void)
Default constructor.
GPIOD_API bool operator!(void) const noexcept
Check if this object doesn't hold any lines.
static GPIOD_API const ::std::bitset< 32 > FLAG_OPEN_DRAIN
The line is an open-drain port.
GPIOD_API ::std::string label(void) const
Return the label of the chip held by this object.
GPIOD_API ::std::vector< int > get_values(void) const
Read values from all lines held by this object.
GPIOD_API ~chip(void)=default
Destructor.
@ BIAS_PULL_DOWN
Line's internal pull-down bias is enabled.
@ ACTIVE_HIGH
Line's active state is high.
GPIOD_API bool operator==(const line_iter &rhs) const noexcept
Check if this operator points to the same element.
GPIOD_API iterator end(void) noexcept
Returns an iterator to the element following the last line.
GPIOD_API chip & operator=(chip &&other)=default
Move assignment operator.
GPIOD_API iterator(const iterator &other)=default
Copy constructor.
#define GPIOD_API
Makes symbol visible.
GPIOD_API int active_state(void) const
Get current active state of this line.
GPIOD_API void request(const line_request &config, const ::std::vector< int > default_vals=::std::vector< int >()) const
Request all lines held by this object.
int request_type
Type of the request.
GPIOD_API line & get(unsigned int offset)
Get the line at given offset.
GPIOD_API line get_line(unsigned int offset) const
Get the line exposed by this chip at given offset.
GPIOD_API void set_direction_input() const
Change the direction all lines held by this object to input.
Stores the configuration for line requests.
GPIOD_API line_iter(line_iter &&other)=default
Move constructor.
GPIOD_API chip_iter & operator=(const chip_iter &other)=default
Assignment operator.
Iterator for iterating over lines held by line_bulk.
GPIOD_API ~line_bulk(void)=default
Destructor.
GPIOD_API void release(void) const
Release all lines held by this object.
GPIOD_API chip(chip &&other)=default
Move constructor.
GPIOD_API unsigned int num_lines(void) const
Return the number of lines exposed by this chip.
GPIOD_API const line * operator->(void) const
Member access operator.
Represents a single GPIO line.
GPIOD_API line & operator=(const line &other)=default
Assignment operator.
GPIOD_API void clear(void)
Remove all lines from this object.
@ OPEN_BY_NUMBER
Assume the string is the number of the GPIO chip.
Represents a set of GPIO lines.
GPIOD_API void set_flags(::std::bitset< 32 > flags) const
Set configuration flags of all lines held by this object.
@ DIRECTION_OUTPUT
Request for driving the GPIO lines.
GPIOD_API line_iter(const line_iter &other)=default
Copy constructor.
@ EVENT_RISING_EDGE
Listen for rising edge events.
GPIOD_API bool operator==(const iterator &rhs) const noexcept
Check if this operator points to the same element.
GPIOD_API chip(const chip &other)=default
Copy constructor.
@ DIRECTION_INPUT
Request for reading line values.
::std::chrono::nanoseconds timestamp
Best estimate of time of event occurrence in nanoseconds.
GPIOD_API line_iter(void)=default
Default constructor.
GPIOD_API chip & operator=(const chip &other)=default
Assignment operator.
GPIOD_API line_bulk & operator=(line_bulk &&other)=default
Move assignment operator.
GPIOD_API line_iter(const chip &owner)
Constructor.
GPIOD_API chip(const ::std::string &device, int how=OPEN_LOOKUP)
Constructor.
@ DIRECTION_AS_IS
Request for values, don't change the direction.
GPIOD_API const chip * operator->(void) const
Member access operator.
GPIOD_API chip_iter & operator++(void)
Advance the iterator by one element.
GPIOD_API ~line(void)=default
Destructor.
GPIOD_API void request(const line_request &config, int default_val=0) const
Request this line.
GPIOD_API void append(const line &new_line)
Add a line to this line_bulk object.
GPIOD_API ~iterator(void)=default
Destructor.
GPIOD_API bool operator==(const chip_iter &rhs) const noexcept
Check if this operator points to the same element.
@ BIAS_DISABLE
Line's internal bias is disabled.
GPIOD_API line_bulk(line_bulk &&other)=default
Move constructor.
line source
Line object referencing the GPIO line on which the event occurred.
@ EVENT_FALLING_EDGE
Listen for falling edge events.
GPIOD_API iterator(iterator &&other)=default
Move constructor.
GPIOD_API int direction(void) const
Get current direction of this line.
Allows to iterate over all GPIO chips present on the system.
GPIOD_API void update(void) const
Re-read the line info from the kernel.
GPIOD_API chip_iter(void)=default
Default constructor.
GPIOD_API iterator & operator=(const iterator &other)=default
Assignment operator.
static GPIOD_API const ::std::bitset< 32 > FLAG_BIAS_PULL_DOWN
The line has a configurable pull-down resistor enabled.
GPIOD_API bool event_wait(const ::std::chrono::nanoseconds &timeout) const
Wait for an event on this line.
GPIOD_API unsigned int size(void) const noexcept
Get the number of lines currently held by this object.
GPIOD_API void set_config(int direction, ::std::bitset< 32 > flags, const ::std::vector< int > values=::std::vector< int >()) const
Set configuration of all lines held by this object.
GPIOD_API bool operator!=(const chip_iter &rhs) const noexcept
Check if this operator doesn't point to the same element.
GPIOD_API line_bulk(void)=default
Default constructor.
GPIOD_API line_iter end(const line_iter &iter) noexcept
Support for range-based loops for line iterators.
GPIOD_API line_bulk get_lines(const ::std::vector< unsigned int > &offsets) const
Get a set of lines exposed by this chip at given offsets.
GPIOD_API line find_line(const ::std::string &name) const
Get the line exposed by this chip by name.
GPIOD_API const line * operator->(void) const
Member access operator.
GPIOD_API bool operator!(void) const noexcept
Check if this object doesn't reference any GPIO line.
GPIOD_API bool operator==(const chip &rhs) const noexcept
Equality operator.
static GPIOD_API const unsigned int MAX_LINES
Max number of lines that this object can hold.
GPIOD_API void set_value(int val) const
Set the value of this line.
@ OPEN_LOOKUP
Open based on the best guess what the supplied string is.
@ ACTIVE_LOW
Line's active state is low.
GPIOD_API void reset(void) noexcept
Reset the internal smart pointer owned by this object.
GPIOD_API bool operator!=(const line_iter &rhs) const noexcept
Check if this operator doesn't point to the same element.
@ DIRECTION_OUTPUT
Line's direction setting is output.
GPIOD_API line_event event_read(void) const
Read a line event.
Allows to iterate over all lines owned by a GPIO chip.
GPIOD_API int bias(void) const
Get current bias of this line.
static GPIOD_API const ::std::bitset< 32 > FLAG_ACTIVE_LOW
Set the active state to 'low' (high is the default).
GPIOD_API line(const line &other)=default
Copy constructor.
GPIOD_API line_bulk(const line_bulk &other)=default
Copy constructor.
GPIOD_API void reset(void)
Reset the state of this object.
GPIOD_API chip_iter make_chip_iter(void)
Create a new chip_iter.
@ OPEN_BY_LABEL
Assume the string is the label of the GPIO chip.
GPIOD_API line_bulk find_lines(const ::std::vector<::std::string > &names) const
Get a set of lines exposed by this chip by their names.
@ EVENT_BOTH_EDGES
Listen for all types of events.
GPIOD_API void set_flags(::std::bitset< 32 > flags) const
Set configuration flags of this line.
GPIOD_API line find_line(const ::std::string &name)
Find a GPIO line by name.
GPIOD_API int get_value(void) const
Read the line value.
@ DIRECTION_INPUT
Line's direction setting is input.
GPIOD_API chip_iter(const chip_iter &other)=default
Copy constructor.
GPIOD_API bool is_open_source(void) const
Check if this line represents an open-source GPIO.
GPIOD_API bool is_requested(void) const
Check if this user has ownership of this line.
::std::string consumer
Consumer name to pass to the request.
GPIOD_API bool is_used(void) const
Check if this line is used by the kernel or other user space process.
@ FALLING_EDGE
Falling edge event.
GPIOD_API void set_config(int direction, ::std::bitset< 32 > flags, int value=0) const
Set configuration of this line.
GPIOD_API bool operator==(const line &rhs) const noexcept
Check if two line objects reference the same GPIO line.
GPIOD_API line_bulk(const ::std::vector< line > &lines)
Construct a line_bulk from a vector of lines.
GPIOD_API bool operator!=(const iterator &rhs) const noexcept
Check if this operator doesn't point to the same element.
GPIOD_API void set_direction_input() const
Change the direction this line to input.
GPIOD_API line & operator[](unsigned int offset)
Get the line at given offset without bounds checking.
GPIOD_API const chip & operator*(void) const
Dereference current element.
GPIOD_API iterator(void)=default
Default constructor.
GPIOD_API bool operator!(void) const noexcept
Check if this object doesn't hold a reference to a GPIO chip.
GPIOD_API void release(void) const
Release the line if it was previously requested.
GPIOD_API ::std::string consumer(void) const
Get the consumer of this line (if any).
GPIOD_API line(line &&other)=default
Move constructor.
@ BIAS_PULL_UP
Line's internal pull-up bias is enabled.
GPIOD_API const line & operator*(void) const
Dereference current element.
GPIOD_API ~line_iter(void)=default
Destructor.
static GPIOD_API const ::std::bitset< 32 > FLAG_OPEN_SOURCE
The line is an open-source port.
GPIOD_API void open(const ::std::string &device, int how=OPEN_LOOKUP)
Open a GPIO chip.
GPIOD_API line & operator=(line &&other)=default
Move assignment operator.
GPIOD_API int event_get_fd(void) const
Get the event file descriptor associated with this line.
GPIOD_API bool operator!=(const line &rhs) const noexcept
Check if two line objects reference different GPIO lines.
GPIOD_API line_iter begin(line_iter iter) noexcept
Support for range-based loops for line iterators.
@ BIAS_AS_IS
Line's bias state is unknown.
GPIOD_API line_bulk get_all_lines(void) const
Get all lines exposed by this chip.
GPIOD_API ::std::vector< line_event > event_read_multiple(void) const
Read multiple line events.
GPIOD_API line_iter & operator=(const line_iter &other)=default
Assignment operator.
GPIOD_API void set_direction_output(const ::std::vector< int > &values) const
Change the direction all lines held by this object to output.
Describes a single GPIO line event.
GPIOD_API bool operator!=(const chip &rhs) const noexcept
Inequality operator.
GPIOD_API chip_iter & operator=(chip_iter &&other)=default
Move assignment operator.
GPIOD_API const line & operator*(void) const
Dereference current element.
@ RISING_EDGE
Rising edge event.
GPIOD_API line_bulk & operator=(const line_bulk &other)=default
Assignment operator.