33     , sock_(ctx, 
zmqpp::socket_type::rep)
    35     , direction_(direction)
    36     , initial_value_(initial_value)
    38     , path_cfg_(module.general_config())
    39     , next_update_time_(
std::chrono::system_clock::time_point::max())
    41     sock_.bind(
"inproc://" + name);
    55     file_fd_ = open(full_path.c_str(), O_RDONLY | O_NONBLOCK);
    79         ERROR(
"Error while unexporting GPIO: " << e.
what());
   107     zmqpp::message_t msg;
   115     else if (frame1 == 
"OFF")
   117     else if (frame1 == 
"TOGGLE")
   119     sock_.send(ok ? 
"OK" : 
"KO");
   128     DEBUG(
"Remaining = " << msg->remaining());
   129     if (msg && msg->remaining() == 1)
   137             std::chrono::system_clock::now() + std::chrono::milliseconds(duration);
   163     std::array<char, 64> buffer;
   168     ret = ::read(
file_fd_, &buffer[0], buffer.size());
   169     ASSERT_LOG(ret >= 0, 
"Read failed on GPIO pin.");
   170     ret = ::lseek(
file_fd_, 0, SEEK_SET);
   171     ASSERT_LOG(ret >= 0, 
"Lseek failed on GPIO pin.");
   181                      zmqpp::poller::poll_pri);
   191     DEBUG(
"Turning off SysFsGPIO pin.");
 std::string edge_path(int pin_no) const
Compute the absolute path the "edge" file for pin_no. 
 
int gpio_no_
Number of the GPIO. 
 
void handle_interrupt()
Interrupt happened for this GPIO ping. 
 
zmqpp::socket sock_
listen to command from other component. 
 
void register_sockets(zmqpp::reactor *reactor)
Register own socket to the module's reactor. 
 
SysFsGpioPin(zmqpp::context &ctx, const std::string &name, int gpio_no, Direction direction, InterruptMode interrupt_mode, bool initial_value, SysFsGpioModule &module)
 
void set_direction(Direction dir)
Write direction to the direction file. 
 
void set_interrupt(InterruptMode mode)
Write interrupt mode to the edge file. 
 
bool read_value()
Read value from filesystem. 
 
void handle_message()
The SysFsGpioModule will register this method so its called when a message is ready on the pin socket...
 
virtual const char * what() const noexcept final
 
std::string value_path(int pin_no) const
Compute the absolute path the "value" file for pin_no. 
 
bool toggle()
Read to sysfs and then write the opposite value. 
 
void publish_on_bus(zmqpp::message &msg)
Write the message eon the bus. 
 
Handle GPIO management over sysfs. 
 
const SysFsGpioConfig & path_cfg_
 
unix filesystem helper functions 
 
const Direction direction_
Direction of the PIN. 
 
std::chrono::system_clock::time_point next_update_time_
Time point of next wished update. 
 
bool turn_off()
Write to sysfs to turn the gpio on. 
 
#define ASSERT_LOG(cond, msg)
 
Namespace for the module that implements GPIO support using the Linux Kernel sysfs interface...
 
void update()
Update the PIN. 
 
std::chrono::system_clock::time_point next_update() const
This method shall returns the time point at which we want to be updated. 
 
int file_fd_
File descriptor of the GPIO in sysfs. 
 
const std::string & unexport_path() const
Returns the absolute path to the "unexport" sysfs file. 
 
std::string direction_path(int pin_no) const
Compute the absolute path the "direction" file for pin_no. 
 
SysFsGpioModule & module_
Reference to the module. 
 
const SysFsGpioConfig & general_config() const
Retrieve a reference to the config object. 
 
bool turn_on(zmqpp::message *msg=nullptr)
Write to sysfs to turn the gpio on. 
 
const bool initial_value_
Initial value of the PIN.