mavtables
0.2.1
MAVLink router and firewall.
|
#include <SerialInterface.hpp>
Public Member Functions | |
SerialInterface (std::unique_ptr< SerialPort > port, std::shared_ptr< ConnectionPool > connection_pool, std::unique_ptr< Connection > connection) | |
~SerialInterface ()=default | |
void | send_packet (const std::chrono::nanoseconds &timeout) final |
void | receive_packet (const std::chrono::nanoseconds &timeout) final |
Protected Member Functions | |
std::ostream & | print_ (std::ostream &os) const final |
A serial port interface.
An interface (for sending and receiving packets) implementing the serial port protocol.
Definition at line 37 of file SerialInterface.hpp.
SerialInterface::SerialInterface | ( | std::unique_ptr< SerialPort > | port, |
std::shared_ptr< ConnectionPool > | connection_pool, | ||
std::unique_ptr< Connection > | connection | ||
) |
Construct a serial port interface using a given device.
port | The serial port device to communicate over. |
connection_pool | The connection pool to use for sending packets the interface has received and to register the connection with. |
connection | The connection to get packets to send packets from. This will be registered with the given ConnectionPool. |
std::invalid_argument | if the serial port device pointer is null. |
std::invalid_argument | if the connection_pool pointer is null. |
std::invalid_argument | if the connection pointer is null. |
Definition at line 39 of file SerialInterface.cpp.
|
default |
|
finalprotectedvirtual |
Print the interface to the given output stream.
os | The output stream to print to. |
Example:
os | The output stream to print to. |
Implements Interface.
Definition at line 121 of file SerialInterface.cpp.
|
finalvirtual |
Receive a packet on the interface.
timeout | The maximum amount of time to wait for incoming data. |
Reads the data in the serial port's receive buffer or waits for up to timeout
until data arrives if no data is present in the serial port buffer.
Implements Interface.
Definition at line 86 of file SerialInterface.cpp.
References PacketParser::parse_byte().
|
finalvirtual |
Send a packet from one of the interface's connections.
timeout | The maximum amount of time to wait for a packet to be available for sending. |
Writes up to one packet from the contained connection to the serial port.
Implements Interface.
Definition at line 70 of file SerialInterface.cpp.