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

Represents a GPIO chip. More...

`#include <chip.hpp>`

## Public Member Functions

| chip (const ::std::filesystem::path &path)
| Instantiates a new chip object by opening the device file indicated by the `path` argument.
| chip (chip &&other) noexcept
| Move constructor.
| ~chip ()
chip & | operator= (const chip &other)=delete
chip & | operator= (chip &&other) noexcept
| Move assignment operator.
| operator bool () const noexcept
| Check if this object is valid.
void | close ()
| Close the GPIO chip device file and free associated resources.
::std::filesystem::path | path () const
| Get the filesystem path that was used to open this GPIO chip.
chip_info | get_info () const
| Get information about the chip.
line_info | get_line_info (line::offset offset) const
| Retrieve the current snapshot of line information for a single line.
line_info | watch_line_info (line::offset offset) const
| Wrapper around gpiod::chip::get_line_info that retrieves the line info and starts watching the line for changes.
void | unwatch_line_info (line::offset offset) const
| Stop watching the line at given offset for info events.
int | fd () const
| Get the file descriptor associated with this chip.
bool | wait_info_event (const ::std::chrono::nanoseconds &timeout) const
| Wait for line status events on any of the watched lines exposed by this chip.
info_event | read_info_event () const
| Read a single line status change event from this chip.
int | get_line_offset_from_name (const ::std::string &name) const
| Map a GPIO line's name to its offset within the chip.
request_builder | prepare_request ()
| Create a request_builder associated with this chip.

## Detailed Description

Represents a GPIO chip.

## Constructor & Destructor Documentation

## chip() [1/2]

gpiod::chip::chip | ( | const ::std::filesystem::path & | path | ) |

explicit

Instantiates a new chip object by opening the device file indicated by the `path` argument.

Parameters

  path | Path to the device file to open.

## chip() [2/2]

gpiod::chip::chip | ( | chip && | other | ) |

noexcept

Move constructor.

Parameters

  other | Object to move.

## ~chip()

gpiod::chip::~chip | ( |  | ) |

## Member Function Documentation

## close()

void gpiod::chip::close | ( |  | ) |

Close the GPIO chip device file and free associated resources.

Note
  The chip object can live after calling this method but any of the chip's mutators will throw a logic_error exception.

## fd()

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

Get the file descriptor associated with this chip.

Returns
  File descriptor number.

## get_info()

chip_info gpiod::chip::get_info | ( |  | ) | const

Get information about the chip.

Returns
  New chip_info object.

## get_line_info()

line_info gpiod::chip::get_line_info | ( | line::offset | offset | ) | const

Retrieve the current snapshot of line information for a single line.

Parameters

  offset | Offset of the line to get the info for.

Returns
  New gpiod::line_info object.

## get_line_offset_from_name()

int gpiod::chip::get_line_offset_from_name | ( | const ::std::string & | name | ) | const

Map a GPIO line's name to its offset within the chip.

Parameters

  name | Name of the GPIO line to map.

Returns
  Offset of the line within the chip or -1 if the line with given name is not exposed by this chip.

## operator bool()

gpiod::chip::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 chip was closed. 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]

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

noexcept

Move assignment operator.

Parameters

  other | Object to move.

Returns
  Reference to self.

## operator=() [2/2]

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

delete

## path()

::std::filesystem::path gpiod::chip::path | ( |  | ) | const

Get the filesystem path that was used to open this GPIO chip.

Returns
  Path to the underlying character device file.

## prepare_request()

request_builder gpiod::chip::prepare_request | ( |  | ) |

Create a request_builder associated with this chip.

Returns
  New request_builder object.

## read_info_event()

info_event gpiod::chip::read_info_event | ( |  | ) | const

Read a single line status change event from this chip.

Returns
  New info_event object.

## unwatch_line_info()

void gpiod::chip::unwatch_line_info | ( | line::offset | offset | ) | const

Stop watching the line at given offset for info events.

Parameters

  offset | Offset of the line to get the info for.

## wait_info_event()

bool gpiod::chip::wait_info_event | ( | const ::std::chrono::nanoseconds & | timeout | ) | const

Wait for line status events on any of the watched lines exposed by this chip.

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.

## watch_line_info()

line_info gpiod::chip::watch_line_info | ( | line::offset | offset | ) | const

Wrapper around gpiod::chip::get_line_info that retrieves the line info and starts watching the line for changes.

Parameters

  offset | Offset of the line to get the info for.

Returns
  New gpiod::line_info object.

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

- chip.hpp