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. More... | |
void | Close () |
Close the port. More... | |
ssize_t | Read (void *const buffer, size_t count) |
Read from the port. More... | |
ssize_t | ReadFull (void *const buffer, size_t count) |
Read the requested quantity of data from the port. More... | |
ssize_t | Skip (size_t count) |
Dump data until the specified number of bytes have been read. More... | |
ssize_t | SkipUntil (uint8_t terminator, unsigned int count) |
Read and dump data until the specified termination character has been seen count times. More... | |
ssize_t | BytesAvailable () |
Get the number of bytes waiting to be read at the port. Returns immediatly. More... | |
ssize_t | BytesAvailableWait () |
Get the number of bytes waiting after blocking for the timeout. More... | |
ssize_t | Write (const void *const buffer, size_t count) |
Write data to the port. More... | |
void | Flush () |
Flush the port's input and output buffers, discarding all data. More... | |
void | Drain () |
Drain the port's input and output buffers. More... | |
std::string | GetStatus () const |
Get the status of the port (type, device, etc). More... | |
void | SetTimeout (Timeout timeout) |
Set the timeout value in milliseconds. More... | |
void | SetCanRead (bool canRead) |
Set the read permissions of the port. More... | |
void | SetCanWrite (bool canWrite) |
Set the write permissions of the port. More... | |
bool | IsOpen () const |
Check if the port is open. More... | |
![]() | |
virtual | ~Port () |
virtual ssize_t | ReadString (std::string &buffer) |
Read a string. More... | |
virtual ssize_t | ReadUntil (void *const buffer, size_t count, uint8_t terminator) |
Read data until a specified termination byte is received. More... | |
virtual ssize_t | ReadStringUntil (std::string &buffer, char terminator) |
Read a string until the specified termination character is received. More... | |
virtual ssize_t | ReadLine (char *const buffer, size_t count) |
Read a new-line terminated string of data. More... | |
virtual ssize_t | ReadLine (std::string &buffer) |
Read a new-line terminated string of data. More... | |
virtual ssize_t | WriteFull (const void *const buffer, size_t count) |
Write all the data to the port. More... | |
virtual ssize_t | WriteString (const char *const buffer) |
Write a string to the port. More... | |
virtual ssize_t | WriteString (const std::string &buffer) |
std::string | GetPortType () const |
Get the port type. More... | |
void | SetDebug (int debug) |
Set the debug level. More... | |
int | GetDebug () const |
Get the debug level. More... | |
virtual Timeout | GetTimeout () const |
Get the timeout. More... | |
virtual bool | IsBlocking () const |
Get the blocking property of the port. More... | |
virtual bool | CanRead () const |
Get the read permissions of the port. More... | |
virtual bool | CanWrite () const |
Get the write permissions of the port. More... | |
Additional Inherited Members | |
![]() | |
Port () | |
Port (unsigned int debug, Timeout timeout, bool canRead, bool canWrite, bool alwaysOpen) | |
void | ProcessOptions (const std::map< std::string, std::string > &options) |
virtual bool | ProcessOption (const std::string &option, const std::string &value) |
![]() | |
std::string | _type |
unsigned int | _debug |
Timeout | _timeout |
bool | _canRead |
bool | _canWrite |
bool | _alwaysOpen |
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 | ( | ) |
|
virtual |
Get the number of bytes waiting to be read at the port. Returns immediatly.
Implements flexiport::Port.
|
virtual |
Get the number of bytes waiting after blocking for the timeout.
Implements flexiport::Port.
|
virtual |
Close the port.
Implements flexiport::Port.
|
virtual |
Drain the port's input and output buffers.
Implements flexiport::Port.
|
virtual |
Flush the port's input and output buffers, discarding all data.
Implements flexiport::Port.
|
virtual |
Get the status of the port (type, device, etc).
Reimplemented from flexiport::Port.
|
virtual |
Check if the port is open.
Implements flexiport::Port.
|
virtual |
Open the port.
Implements flexiport::Port.
|
virtual |
Read from the port.
Implements flexiport::Port.
|
virtual |
Read the requested quantity of data from the port.
Implements flexiport::Port.
|
virtual |
Set the read permissions of the port.
Implements flexiport::Port.
|
virtual |
Set the write permissions of the port.
Implements flexiport::Port.
|
virtual |
Set the timeout value in milliseconds.
Implements flexiport::Port.
|
virtual |
Dump data until the specified number of bytes have been read.
Reimplemented from flexiport::Port.
|
virtual |
Read and dump data until the specified termination character has been seen count times.
Reimplemented from flexiport::Port.
|
virtual |
Write data to the port.
Implements flexiport::Port.