代码拉取完成,页面将自动刷新
#pragma once
#include <gpiod.h>
#include <gpio_chips.hpp>
#include <gpio_json_config.hpp>
#include <gpio_status_handler.hpp>
#include <map>
#include <string>
namespace gpio_handler
{
/** @brief RAII manager of multiple opened gpio lines **/
class GpioLines
{
public:
/**
* @brief Open all the gpio lines listed under @ref
* GpioJsonConfig::configKeyGpioPin property ("gpio_pin") in the @jsonConfig
* configuration.
*
* By 'opened' it's meant that both @gpiod_chip_get_line and
* @gpiod_line_request_both_edges_events function calls from gpiod library
* succeeded. The pin name needed for @gpiod_line_request_both_edges_events
* is taken from the top-level attribute name of the @jsonConfig object. The
* same name is used to obtain the corresponding gpio device handler from
* @gpioChips.
*
* Throw @ref std::system_error if not all lines requested in @jsonConfig
* could be opened. Strong exception guarantee (the state of the program is
* rolled back to the state just before the constructor call).
*
* It's assumed that @gpioChips object stays alive for the
* whole lifetime of this object.
*/
GpioLines(const GpioChips& gpioChips, const GpioJsonConfig& jsonConfig);
~GpioLines();
/**
* @brief Get the mapping from pin names (root attributes in the @jsonConfig
* passed to the constructor) to the opened gpio lines handlers represented
* by @gpiod_line_t structs from the gpiod library.
*/
const std::map<std::string, gpiod_line_t*>& getDbusPropMapLineObj() const;
private:
std::map<std::string, gpiod_line_t*> dbusPropMapLineObj;
bool openGpioLines(
const std::map<std::string, gpiod_chip_t*>& dbusPropMapChipObj,
const nlohmann::json& jsonConfig, int& lastErrno) noexcept;
void closeGpioLines() noexcept;
bool requestBothEdgesEvents(int& lastErrno) noexcept;
};
} // namespace gpio_handler
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。