![]() |
Leosac
0.8.0
Open Source Access Control
|
This is a implementation class. More...
#include <LibgpiodPin.hpp>
Collaboration diagram for Leosac::Module::Libgpiod::LibgpiodPin:Public Types | |
| enum | InterruptMode { InterruptMode::None, InterruptMode::Rising, InterruptMode::Falling, InterruptMode::Both } |
| using | Direction = Hardware::GPIO::Direction |
Public Member Functions | |
| LibgpiodPin (zmqpp::context &ctx, const std::string &name, const std::string &gpio_device, int gpio_offset, Direction direction, InterruptMode interrupt_mode, bool initial_value, LibgpiodModule &module) | |
| ~LibgpiodPin () | |
| LibgpiodPin (const LibgpiodPin &)=delete | |
| LibgpiodPin & | operator= (const LibgpiodPin &)=delete |
| LibgpiodPin & | operator= (LibgpiodPin &&)=delete |
| LibgpiodPin (LibgpiodPin &&o)=delete | |
| void | release () |
| Release Libgpiod resources. More... | |
| 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 | |
| zmqpp::socket | sock_ |
| listen to command from other component. More... | |
| std::string | name_ |
| std::string | gpio_device_ |
| File descriptor of the GPIO in sysfs. More... | |
| int | gpio_offset_ |
| Offset of the GPIO. More... | |
| const Direction | direction_ |
| Direction of the PIN. More... | |
| const bool | initial_value_ |
| Initial value of the PIN. More... | |
| LibgpiodModule & | module_ |
| Reference to the module. More... | |
| std::chrono::system_clock::time_point | next_update_time_ |
| Time point of next wished update. More... | |
| gpiod_chip * | gpiod_chip_ |
| gpiod_line * | gpiod_line_ |
| int | gpiod_fd_ |
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 42 of file LibgpiodPin.hpp.
Definition at line 45 of file LibgpiodPin.hpp.
| Enumerator | |
|---|---|
| None | |
| Rising | |
| Falling | |
| Both | |
Definition at line 47 of file LibgpiodPin.hpp.
| LibgpiodPin::LibgpiodPin | ( | zmqpp::context & | ctx, |
| const std::string & | name, | ||
| const std::string & | gpio_device, | ||
| int | gpio_offset, | ||
| Direction | direction, | ||
| InterruptMode | interrupt_mode, | ||
| bool | initial_value, | ||
| LibgpiodModule & | module | ||
| ) |
Definition at line 27 of file LibgpiodPin.cpp.
| LibgpiodPin::~LibgpiodPin | ( | ) |
Definition at line 54 of file LibgpiodPin.cpp.
|
delete |
|
delete |
|
private |
Interrupt happened for this GPIO ping.
Definition at line 162 of file LibgpiodPin.cpp.
|
private |
The SysFsGpioModule will register this method so its called when a message is ready on the pin socket.
Definition at line 100 of file LibgpiodPin.cpp.
| std::chrono::system_clock::time_point LibgpiodPin::next_update | ( | ) | const |
This method shall returns the time point at which we want to be updated.
Definition at line 183 of file LibgpiodPin.cpp.
|
delete |
|
delete |
|
private |
Read value from filesystem.
Definition at line 155 of file LibgpiodPin.cpp.
| void LibgpiodPin::register_sockets | ( | zmqpp::reactor * | reactor | ) |
Register own socket to the module's reactor.
| reactor | Reactor object owned by the module. |
Definition at line 171 of file LibgpiodPin.cpp.
| void LibgpiodPin::release | ( | ) |
Release Libgpiod resources.
Definition at line 59 of file LibgpiodPin.cpp.
|
private |
Write direction to the direction file.
Definition at line 71 of file LibgpiodPin.cpp.
|
private |
Write interrupt mode to the edge file.
Definition at line 83 of file LibgpiodPin.cpp.
|
private |
Read to sysfs and then write the opposite value.
Definition at line 148 of file LibgpiodPin.cpp.
|
private |
Write to sysfs to turn the gpio on.
Definition at line 142 of file LibgpiodPin.cpp.
|
private |
Write to sysfs to turn the gpio on.
Definition at line 121 of file LibgpiodPin.cpp.
| void LibgpiodPin::update | ( | ) |
Update the PIN.
The update will simply turn the PIN off (as a timeout for ON command).
Definition at line 188 of file LibgpiodPin.cpp.
|
private |
Direction of the PIN.
Definition at line 156 of file LibgpiodPin.hpp.
|
private |
File descriptor of the GPIO in sysfs.
Definition at line 146 of file LibgpiodPin.hpp.
|
private |
Offset of the GPIO.
Definition at line 151 of file LibgpiodPin.hpp.
|
private |
Definition at line 173 of file LibgpiodPin.hpp.
|
private |
Definition at line 177 of file LibgpiodPin.hpp.
|
private |
Definition at line 175 of file LibgpiodPin.hpp.
|
private |
Initial value of the PIN.
We set the pin's value to this on module shutdown.
Definition at line 161 of file LibgpiodPin.hpp.
|
private |
Reference to the module.
We use this to publish on the bus.
Definition at line 166 of file LibgpiodPin.hpp.
|
private |
Definition at line 141 of file LibgpiodPin.hpp.
|
private |
Time point of next wished update.
(Used for timeout on ON)
Definition at line 171 of file LibgpiodPin.hpp.
|
private |
listen to command from other component.
Definition at line 139 of file LibgpiodPin.hpp.