mavtables  0.2.1
MAVLink router and firewall.
Public Member Functions | Protected Member Functions | List of all members
UDPInterface Class Reference

#include <UDPInterface.hpp>

Inheritance diagram for UDPInterface:
Inheritance graph
Collaboration diagram for UDPInterface:
Collaboration graph

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
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ UDPInterface()

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.

Parameters
socketThe UDP socket to communicate over.
connection_poolThe connection pool to use for sending packets and to register new connections with.
connection_factoryThe connection factory to use for constructing new connections when an outside connection is made.
Exceptions
std::invalid_argumentif the serial port device pointer is null.
std::invalid_argumentif the connection_pool pointer is null.
std::invalid_argumentif the connection_factory pointer is null.

Definition at line 71 of file UDPInterface.cpp.

◆ ~UDPInterface()

UDPInterface::~UDPInterface ( )
default

Member Function Documentation

◆ print_()

std::ostream & UDPInterface::print_ ( std::ostream &  os) const
finalprotectedvirtual

Print the interface to the given output stream.

Parameters
osThe output stream to print to.
Returns
The output stream.

Example:

udp {
port 14500;
address 127.0.0.1;
}

Implements Interface.

Definition at line 180 of file UDPInterface.cpp.

◆ receive_packet()

void UDPInterface::receive_packet ( const std::chrono::nanoseconds &  timeout)
finalvirtual

Receive a packet on the interface.

Parameters
timeoutThe 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().

Here is the call graph for this function:

◆ send_packet()

void UDPInterface::send_packet ( const std::chrono::nanoseconds &  timeout)
finalvirtual

Send a packet from one of the interface's connections.

Note
Which connection to take this packet from is not defined but it must not starve any one of the Interface's connections.
Parameters
timeoutThe 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.


The documentation for this class was generated from the following files: