Loading...
Searching...
No Matches
chip.hpp
Go to the documentation of this file.
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/* SPDX-FileCopyrightText: 2021-2022 Bartosz Golaszewski <brgl@bgdev.pl> */
#ifndef __LIBGPIOD_CXX_CHIP_HPP__
#define __LIBGPIOD_CXX_CHIP_HPP__
#if !defined(__LIBGPIOD_GPIOD_CXX_INSIDE__)
#error "Only gpiod.hpp can be included directly."
#endif
#include <chrono>
#include <cstddef>
#include <iostream>
#include <filesystem>
#include <memory>
#include "line.hpp"
namespace gpiod {
class chip_info;
class info_event;
class line_config;
class line_info;
class line_request;
class request_builder;
class request_config;
class chip final
{
public:
explicit chip(const ::std::filesystem::path& path);
chip(chip&& other) noexcept;
~chip();
chip& operator=(const chip& other) = delete;
chip& operator=(chip&& other) noexcept;
explicit operator bool() const noexcept;
void close();
::std::filesystem::path path() const;
chip_info get_info() const;
line_info get_line_info(line::offset offset) const;
line_info watch_line_info(line::offset offset) const;
void unwatch_line_info(line::offset offset) const;
int fd() const;
bool wait_info_event(const ::std::chrono::nanoseconds& timeout) const;
info_event read_info_event() const;
int get_line_offset_from_name(const ::std::string& name) const;
request_builder prepare_request();
private:
struct impl;
::std::shared_ptr<impl> _m_priv;
chip(const chip& other);
friend request_builder;
};
::std::ostream& operator<<(::std::ostream& out, const chip& chip);
} /* namespace gpiod */
#endif /* __LIBGPIOD_CXX_CHIP_HPP__ */
gpiod::chip_info
Represents an immutable snapshot of GPIO chip information.
Definition chip-info.hpp:26
gpiod::chip
Represents a GPIO chip.
Definition chip.hpp:37
gpiod::chip::operator=
chip & operator=(chip &&other) noexcept
Move assignment operator.
gpiod::chip::operator=
chip & operator=(const chip &other)=delete
gpiod::chip::get_info
chip_info get_info() const
Get information about the chip.
gpiod::chip::close
void close()
Close the GPIO chip device file and free associated resources.
gpiod::chip::unwatch_line_info
void unwatch_line_info(line::offset offset) const
Stop watching the line at given offset for info events.
gpiod::chip::read_info_event
info_event read_info_event() const
Read a single line status change event from this chip.
gpiod::chip::prepare_request
request_builder prepare_request()
Create a request_builder associated with this chip.
gpiod::chip::fd
int fd() const
Get the file descriptor associated with this chip.
gpiod::chip::chip
chip(chip &&other) noexcept
Move constructor.
gpiod::chip::watch_line_info
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 f...
gpiod::chip::wait_info_event
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.
gpiod::chip::~chip
~chip()
gpiod::chip::get_line_offset_from_name
int get_line_offset_from_name(const ::std::string &name) const
Map a GPIO line's name to its offset within the chip.
gpiod::chip::chip
chip(const ::std::filesystem::path &path)
Instantiates a new chip object by opening the device file indicated by the path argument.
gpiod::chip::get_line_info
line_info get_line_info(line::offset offset) const
Retrieve the current snapshot of line information for a single line.
gpiod::chip::path
::std::filesystem::path path() const
Get the filesystem path that was used to open this GPIO chip.
gpiod::info_event
Immutable object containing data about a single line info event.
Definition info-event.hpp:30
gpiod::line_config
Contains a set of line config options used in line requests and reconfiguration.
Definition line-config.hpp:29
gpiod::line_info
Contains an immutable snapshot of the line's state at the time when the object of this class was inst...
Definition line-info.hpp:30
gpiod::line_request
Stores the context of a set of requested GPIO lines.
Definition line-request.hpp:33
gpiod::request_builder
Intermediate object storing the configuration for a line request.
Definition request-builder.hpp:29
gpiod::request_config
Stores a set of options passed to the kernel when making a line request.
Definition request-config.hpp:31
line.hpp
gpiod::line
Namespace containing various type definitions for GPIO lines.
Definition line.hpp:24
gpiod
Definition chip-info.hpp:18