mavtables
0.2.1
MAVLink router and firewall.
|
#include <SerialPort.hpp>
Public Types | |
enum | Parity { NONE, ODD, EVEN, MARK, SPACE } |
enum | Feature { DEFAULT = 0, FLOW_CONTROL = 1 << 0 } |
Public Member Functions | |
virtual | ~SerialPort () |
virtual std::vector< uint8_t > | read (const std::chrono::nanoseconds &timeout=std::chrono::nanoseconds::zero()) |
virtual void | read (std::back_insert_iterator< std::vector< uint8_t >> it, const std::chrono::nanoseconds &timeout=std::chrono::nanoseconds::zero()) |
virtual void | write (const std::vector< uint8_t > &data) |
virtual void | write (std::vector< uint8_t >::const_iterator first, std::vector< uint8_t >::const_iterator last) |
Protected Member Functions | |
virtual std::ostream & | print_ (std::ostream &os) const |
Friends | |
std::ostream & | operator<< (std::ostream &os, const SerialPort &serial_port) |
The base class of all serial port classes.
This provides an abstraction of serial ports across operating systems.
Definition at line 44 of file SerialPort.hpp.
enum SerialPort::Feature |
Feature bitflags.
Enumerator | |
---|---|
DEFAULT | No special features. |
FLOW_CONTROL | Enable flow control. |
Definition at line 59 of file SerialPort.hpp.
enum SerialPort::Parity |
Parity options.
Enumerator | |
---|---|
NONE | No parity. |
ODD | Odd parity, must have odd number of set bits. |
EVEN | Even parity, must have even number of set bits. |
MARK | Fill parity bit with 1. |
SPACE | Fill parity bit with 0. |
Definition at line 49 of file SerialPort.hpp.
|
virtual |
Definition at line 31 of file SerialPort.cpp.
|
protectedvirtual |
Print the serial port to the given output stream.
os | The output stream to print to. |
Reimplemented in UnixSerialPort.
Definition at line 104 of file SerialPort.cpp.
|
virtual |
Read data from the serial port.
timeout
is not guaranteed to be up to nanosecond precision, the actual precision is up to the operating system's implementation but is guaranteed to have at least millisecond precision.timeout | How long to wait for data to arrive on the serial port if there is not already data to read. The default is to not wait. |
Reimplemented in UnixSerialPort.
Definition at line 47 of file SerialPort.cpp.
|
virtual |
Read data from the serial port.
timeout
is not guaranteed to be up to nanosecond precision, the actual precision is up to the operating system's implementation but is guaranteed to have at least millisecond precision.it | A back insert iterator to read bytes into. |
timeout | How long to wait for data to arrive on the serial port if there is not already data to read. The default is to not wait. |
Definition at line 65 of file SerialPort.cpp.
References read().
|
virtual |
Write data to the serial port (blocking write).
data | The bytes to send. |
Reimplemented in UnixSerialPort.
Definition at line 78 of file SerialPort.cpp.
|
virtual |
Write data to the serial port (blocking write).
first | Iterator to first byte in range to send. |
last | Iterator to one past the last byte to send. |
Definition at line 89 of file SerialPort.cpp.
References write().
|
friend |
Print the given serial port to the given output stream.
An example:
The base SerialPort class will print:
os | The output stream to print to. |
serial_port | The serial port (or any child of SerialPort) to print. |
Definition at line 137 of file SerialPort.cpp.