|
DUDS
|
Distributed Update of Data from Something
|
Public Member Functions | |
| void | open (DigitalPinConfig &conf, DigitalPinCap &cap, unsigned int pin) |
| Opens the value and direction files for the pin. More... | |
| bool | read () |
| Reads from the value file of the pin and returns the result. More... | |
| void | setDirection (bool output) |
| Changes the pin's direction between input and output. More... | |
| void | write (bool state) |
| Changes the output value of the pin. More... | |
Private Attributes | |
| bool | curoutval |
| The current output value for the pin. More... | |
| std::fstream | direction |
| The file used to control the I/O direction of the pin. More... | |
| unsigned int | fsid |
| The GPIO's ID number from the filesystem. More... | |
| bool | isoutput |
| True when the pin is configured as an output. More... | |
| bool | reqoutval |
| The requested output value for the pin. More... | |
| std::fstream | value |
| The file used to query the pin's input state and change the pins output state. More... | |
Definition at line 46 of file SysFsPort.hpp.
| void duds::hardware::interface::linux::SysFsPort::FsPin::open | ( | DigitalPinConfig & | conf, |
| DigitalPinCap & | cap, | ||
| unsigned int | pin | ||
| ) |
Opens the value and direction files for the pin.
| conf | The configuration to change based on the state of the pin. |
| cap | The capabilities to change based on file access. |
| pin | The number used by the kernel to identify the pin. |
| PinIoError | The pin's value or direction file cannot be opened, or the data read from the direction file is neither "in" nor "out". |
| PinUnsupportedOperation | The pin has read-only value and direction files with the direction set to output. |
Definition at line 116 of file SysFsPort.cpp.
| bool duds::hardware::interface::linux::SysFsPort::FsPin::read | ( | ) |
Reads from the value file of the pin and returns the result.
Definition at line 226 of file SysFsPort.cpp.
| void duds::hardware::interface::linux::SysFsPort::FsPin::setDirection | ( | bool | output | ) |
Changes the pin's direction between input and output.
The direction file is only written if the pin's direction changes. Some testing suggests that the pin's output state may strobe when the direction or value file is written with the same value that should already be there. This issue may not exist with all hardware, and the checks should prevent trouble when it does exist as long as other processes on the host are not also modifying the pin.
| output | True to make the pin an output, false for input. |
Definition at line 204 of file SysFsPort.cpp.
| void duds::hardware::interface::linux::SysFsPort::FsPin::write | ( | bool | state | ) |
Changes the output value of the pin.
If the pin is not an output, the requested value is stored and will be set later by setDirection() when the pin changes to an output. Ensuring a particular output state before beginning to output is not supported by the filesystem interface.
The output state is only written to the value file if it changed. Some testing suggests that the pin's output state may strobe when the value or direction file is written with the same value that should already be there. This issue may not exist with all hardware, and the checks should prevent trouble when it does exist as long as other processes on the host are not also modifying the pin.
| state | The output state, true for high. |
Definition at line 238 of file SysFsPort.cpp.
|
private |
The current output value for the pin.
This is meaningless when the pin is an input. When it is an output, this value is used to avoid writting state changes to the already current state to the value file.
Definition at line 76 of file SysFsPort.hpp.
|
private |
The file used to control the I/O direction of the pin.
If the file cannot be opened for reading and writing, it will be opened for reading only long enough to record the direction.
Definition at line 52 of file SysFsPort.hpp.
|
private |
The GPIO's ID number from the filesystem.
This may be different from the local and global IDs used by the port object.
Definition at line 62 of file SysFsPort.hpp.
|
private |
True when the pin is configured as an output.
This is easier, and possibly a little faster, to check than inspecting the pin configuration inside DigitalPort::PinEntry::conf, and it doesn't make this data structure any larger.
Definition at line 83 of file SysFsPort.hpp.
|
private |
The requested output value for the pin.
This may be changed while the pin is an input so that when it is changed to an output this software can quickly change the state to the requested value. This seems to be the best possible implementation with the filesystem interface.
Definition at line 69 of file SysFsPort.hpp.
|
private |
The file used to query the pin's input state and change the pins output state.
Definition at line 57 of file SysFsPort.hpp.