Leosac
0.8.0
Open Source Access Control
|
This is a implementation class. More...
#include <SysFSGPIOPin.hpp>
Public Types | |
enum | InterruptMode { InterruptMode::None, InterruptMode::Rising, InterruptMode::Falling, InterruptMode::Both } |
using | Direction = Hardware::GPIO::Direction |
Public Member Functions | |
SysFsGpioPin (zmqpp::context &ctx, const std::string &name, int gpio_no, Direction direction, InterruptMode interrupt_mode, bool initial_value, SysFsGpioModule &module) | |
~SysFsGpioPin () | |
SysFsGpioPin (const SysFsGpioPin &)=delete | |
SysFsGpioPin & | operator= (const SysFsGpioPin &)=delete |
SysFsGpioPin & | operator= (SysFsGpioPin &&)=delete |
SysFsGpioPin (SysFsGpioPin &&o)=delete | |
void | register_sockets (zmqpp::reactor *reactor) |
Register own socket to the module's reactor. More... | |
std::chrono::system_clock::time_point | next_update () const |
This method shall returns the time point at which we want to be updated. More... | |
void | update () |
Update the PIN. More... | |
Private Member Functions | |
void | handle_interrupt () |
Interrupt happened for this GPIO ping. More... | |
bool | read_value () |
Read value from filesystem. More... | |
bool | turn_on (zmqpp::message *msg=nullptr) |
Write to sysfs to turn the gpio on. More... | |
bool | turn_off () |
Write to sysfs to turn the gpio on. More... | |
bool | toggle () |
Read to sysfs and then write the opposite value. More... | |
void | handle_message () |
The SysFsGpioModule will register this method so its called when a message is ready on the pin socket. More... | |
void | set_direction (Direction dir) |
Write direction to the direction file. More... | |
void | set_interrupt (InterruptMode mode) |
Write interrupt mode to the edge file. More... | |
Private Attributes | |
int | file_fd_ |
File descriptor of the GPIO in sysfs. More... | |
int | gpio_no_ |
Number of the GPIO. More... | |
zmqpp::socket | sock_ |
listen to command from other component. More... | |
std::string | name_ |
const Direction | direction_ |
Direction of the PIN. More... | |
const bool | initial_value_ |
Initial value of the PIN. More... | |
SysFsGpioModule & | module_ |
Reference to the module. More... | |
const SysFsGpioConfig & | path_cfg_ |
std::chrono::system_clock::time_point | next_update_time_ |
Time point of next wished update. More... | |
This is a implementation class.
It's not exposed to the user and is for this module internal code only.
It abstract a GPIO pin.
Definition at line 41 of file SysFSGPIOPin.hpp.
Definition at line 44 of file SysFSGPIOPin.hpp.
Enumerator | |
---|---|
None | |
Rising | |
Falling | |
Both |
Definition at line 46 of file SysFSGPIOPin.hpp.
SysFsGpioPin::SysFsGpioPin | ( | zmqpp::context & | ctx, |
const std::string & | name, | ||
int | gpio_no, | ||
Direction | direction, | ||
InterruptMode | interrupt_mode, | ||
bool | initial_value, | ||
SysFsGpioModule & | module | ||
) |
Definition at line 29 of file SysFSGPIOPin.cpp.
SysFsGpioPin::~SysFsGpioPin | ( | ) |
Definition at line 59 of file SysFSGPIOPin.cpp.
|
delete |
|
delete |
|
private |
Interrupt happened for this GPIO ping.
Definition at line 172 of file SysFSGPIOPin.cpp.
|
private |
The SysFsGpioModule will register this method so its called when a message is ready on the pin socket.
Definition at line 112 of file SysFSGPIOPin.cpp.
std::chrono::system_clock::time_point SysFsGpioPin::next_update | ( | ) | const |
This method shall returns the time point at which we want to be updated.
Definition at line 195 of file SysFSGPIOPin.cpp.
|
delete |
|
delete |
|
private |
Read value from filesystem.
Definition at line 167 of file SysFSGPIOPin.cpp.
void SysFsGpioPin::register_sockets | ( | zmqpp::reactor * | reactor | ) |
Register own socket to the module's reactor.
reactor | Reactor object owned by the module. |
Definition at line 187 of file SysFSGPIOPin.cpp.
|
private |
Write direction to the direction
file.
Definition at line 90 of file SysFSGPIOPin.cpp.
|
private |
Write interrupt mode to the edge
file.
Definition at line 96 of file SysFSGPIOPin.cpp.
|
private |
Read to sysfs and then write the opposite value.
Definition at line 160 of file SysFSGPIOPin.cpp.
|
private |
Write to sysfs to turn the gpio on.
Definition at line 154 of file SysFSGPIOPin.cpp.
|
private |
Write to sysfs to turn the gpio on.
Definition at line 133 of file SysFSGPIOPin.cpp.
void SysFsGpioPin::update | ( | ) |
Update the PIN.
The update will simply turn the PIN off (as a timeout for ON
command).
Definition at line 200 of file SysFSGPIOPin.cpp.
|
private |
Direction of the PIN.
Definition at line 150 of file SysFSGPIOPin.hpp.
|
private |
File descriptor of the GPIO in sysfs.
Definition at line 133 of file SysFSGPIOPin.hpp.
|
private |
Number of the GPIO.
Definition at line 138 of file SysFSGPIOPin.hpp.
|
private |
Initial value of the PIN.
We set the pin's value to this on module shutdown.
Definition at line 155 of file SysFSGPIOPin.hpp.
|
private |
Reference to the module.
We use this to publish on the bus.
Definition at line 160 of file SysFSGPIOPin.hpp.
|
private |
Definition at line 145 of file SysFSGPIOPin.hpp.
|
private |
Time point of next wished update.
(Used for timeout on ON
)
Definition at line 167 of file SysFSGPIOPin.hpp.
|
private |
Definition at line 162 of file SysFSGPIOPin.hpp.
|
private |
listen to command from other component.
Definition at line 143 of file SysFSGPIOPin.hpp.