mavtables
0.2.1
MAVLink router and firewall.
|
#include <UDPInterface.hpp>
Public Member Functions | |
UDPInterface (std::unique_ptr< UDPSocket > socket, std::shared_ptr< ConnectionPool > connection_pool, std::unique_ptr< ConnectionFactory<>> connection_factory) | |
~UDPInterface ()=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 UDP (User Datagram Protocol) interface.
An interface (for sending and receiving packets) implementing the user datagram protocol.
Definition at line 40 of file UDPInterface.hpp.
UDPInterface::UDPInterface | ( | std::unique_ptr< UDPSocket > | socket, |
std::shared_ptr< ConnectionPool > | connection_pool, | ||
std::unique_ptr< ConnectionFactory<>> | connection_factory | ||
) |
Construct a UDP interface using a given socket.
socket | The UDP socket to communicate over. |
connection_pool | The connection pool to use for sending packets and to register new connections with. |
connection_factory | The connection factory to use for constructing new connections when an outside connection is made. |
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_factory pointer is null. |
Definition at line 71 of file UDPInterface.cpp.
|
default |
|
finalprotectedvirtual |
Print the interface to the given output stream.
os | The output stream to print to. |
Example:
Implements Interface.
Definition at line 180 of file UDPInterface.cpp.
|
finalvirtual |
Receive a packet on the interface.
timeout | The maximum amount of time to wait for incoming data. |
Receives up to one UDP packet worth of data and parses it into MAVLink packets before passing these packets onto the connection pool. Will wait up to timeout
for a UDP packet to be received.
Implements Interface.
Definition at line 138 of file UDPInterface.cpp.
References PacketParser::clear(), and 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. |
Sends up to one packet from each connection, belonging to the interface, over the UDP socket.
Implements Interface.
Definition at line 103 of file UDPInterface.cpp.