Flexiport 2.0.0
|
Logging implementation of the Port class. More...
#include <flexiport/logwriterport.h>
Public Member Functions | |
LogWriterPort (std::map< std::string, std::string > options) | |
~LogWriterPort () | |
void | Open () |
Open the port. | |
void | Close () |
Close the port. | |
ssize_t | Read (void *const buffer, size_t count) |
Read from the port. | |
ssize_t | ReadFull (void *const buffer, size_t count) |
Read the requested quantity of data from the port. | |
ssize_t | Skip (size_t count) |
Dump data until the specified number of bytes have been read. | |
ssize_t | SkipUntil (uint8_t terminator, unsigned int count) |
Read and dump data until the specified termination character has been seen count times. | |
ssize_t | BytesAvailable () |
Get the number of bytes waiting to be read at the port. Returns immediatly. | |
ssize_t | BytesAvailableWait () |
Get the number of bytes waiting after blocking for the timeout. | |
ssize_t | Write (const void *const buffer, size_t count) |
Write data to the port. | |
void | Flush () |
Flush the port's input and output buffers, discarding all data. | |
void | Drain () |
Drain the port's input and output buffers. | |
std::string | GetStatus () const |
Get the status of the port (type, device, etc). | |
void | SetTimeout (Timeout timeout) |
Set the timeout value in milliseconds. | |
void | SetCanRead (bool canRead) |
Set the read permissions of the port. | |
void | SetCanWrite (bool canWrite) |
Set the write permissions of the port. | |
bool | IsOpen () const |
Check if the port is open. |
Logging implementation of the Port class.
An underlying Port object is used to perform the actual communications. All actions taken by that port are logged, including data transferred. The log file can be used with a LogReaderPort to simulate a Port object and perform testing.
To create a LogWriterPort, append "log" to the port type in the port options passed to CreatePort. For example, a log writer that uses a serial port would be specified as the type "seriallog". Similarly, for a TCP port, use "tcplog".
See the Port class documentation for how to use the common API.
All unused options will be passed on to the underlying port used.
Definition at line 72 of file logwriterport.h.
flexiport::LogWriterPort::LogWriterPort | ( | std::map< std::string, std::string > | options | ) |
flexiport::LogWriterPort::~LogWriterPort | ( | ) |
ssize_t flexiport::LogWriterPort::BytesAvailable | ( | ) | [virtual] |
Get the number of bytes waiting to be read at the port. Returns immediatly.
Implements flexiport::Port.
ssize_t flexiport::LogWriterPort::BytesAvailableWait | ( | ) | [virtual] |
Get the number of bytes waiting after blocking for the timeout.
Implements flexiport::Port.
void flexiport::LogWriterPort::Close | ( | ) | [virtual] |
Close the port.
Implements flexiport::Port.
void flexiport::LogWriterPort::Drain | ( | ) | [virtual] |
Drain the port's input and output buffers.
Implements flexiport::Port.
void flexiport::LogWriterPort::Flush | ( | ) | [virtual] |
Flush the port's input and output buffers, discarding all data.
Implements flexiport::Port.
std::string flexiport::LogWriterPort::GetStatus | ( | ) | const [virtual] |
Get the status of the port (type, device, etc).
Reimplemented from flexiport::Port.
bool flexiport::LogWriterPort::IsOpen | ( | ) | const [virtual] |
Check if the port is open.
Implements flexiport::Port.
void flexiport::LogWriterPort::Open | ( | ) | [virtual] |
Open the port.
Implements flexiport::Port.
ssize_t flexiport::LogWriterPort::Read | ( | void *const | buffer, |
size_t | count | ||
) | [virtual] |
Read from the port.
Implements flexiport::Port.
ssize_t flexiport::LogWriterPort::ReadFull | ( | void *const | buffer, |
size_t | count | ||
) | [virtual] |
Read the requested quantity of data from the port.
Implements flexiport::Port.
void flexiport::LogWriterPort::SetCanRead | ( | bool | canRead | ) | [virtual] |
Set the read permissions of the port.
Implements flexiport::Port.
void flexiport::LogWriterPort::SetCanWrite | ( | bool | canWrite | ) | [virtual] |
Set the write permissions of the port.
Implements flexiport::Port.
void flexiport::LogWriterPort::SetTimeout | ( | Timeout | timeout | ) | [virtual] |
Set the timeout value in milliseconds.
Implements flexiport::Port.
ssize_t flexiport::LogWriterPort::Skip | ( | size_t | count | ) | [virtual] |
Dump data until the specified number of bytes have been read.
Reimplemented from flexiport::Port.
ssize_t flexiport::LogWriterPort::SkipUntil | ( | uint8_t | terminator, |
unsigned int | count | ||
) | [virtual] |
Read and dump data until the specified termination character has been seen count times.
Reimplemented from flexiport::Port.
ssize_t flexiport::LogWriterPort::Write | ( | const void *const | buffer, |
size_t | count | ||
) | [virtual] |
Write data to the port.
Implements flexiport::Port.