Go to the documentation of this file.
24 #include <boost/system/system_error.hpp>
36 #include <unordered_map>
37 #include <mavconn/mavlink_dialect.h>
42 using lock_guard = std::lock_guard<std::recursive_mutex>;
49 incomplete = mavlink::MAVLINK_FRAMING_INCOMPLETE,
50 ok = mavlink::MAVLINK_FRAMING_OK,
51 bad_crc = mavlink::MAVLINK_FRAMING_BAD_CRC,
76 std::ostringstream ss;
86 return ::strerror(errnum);
102 using ReceivedCb = std::function<void (
const mavlink::mavlink_message_t *message,
const Framing framing)>;
104 using Ptr = std::shared_ptr<MAVConnInterface>;
105 using ConstPtr = std::shared_ptr<MAVConnInterface const>;
106 using WeakPtr = std::weak_ptr<MAVConnInterface>;
131 virtual void close() = 0;
143 virtual void send_message(
const mavlink::mavlink_message_t *message) = 0;
169 virtual void send_message(
const mavlink::Message &message,
const uint8_t src_compid) = 0;
175 virtual void send_bytes(
const uint8_t *bytes,
size_t length) = 0;
204 virtual mavlink::mavlink_status_t
get_status();
246 uint8_t system_id = 1,
256 uint8_t system_id = 1,
271 static std::unordered_map<mavlink::msgid_t, const mavlink::mavlink_msg_entry_t*>
message_entries;
287 void parse_buffer(
const char *pfx, uint8_t *buf,
const size_t bufsize,
size_t bytes_received);
292 void log_recv(
const char *pfx, mavlink::mavlink_message_t &msg,
Framing framing);
293 void log_send(
const char *pfx,
const mavlink::mavlink_message_t *msg);
294 void log_send_obj(
const char *pfx,
const mavlink::Message &msg);
297 friend const mavlink::mavlink_msg_entry_t* mavlink::mavlink_get_msg_entry(uint32_t msgid);
virtual void close()=0
Close connection.
ReceivedCb message_received_cb
Message receive callback.
DeviceError(const char *module, T msg)
static constexpr size_t MAX_TXQ_SIZE
Maximum count of transmission buffers.
void set_protocol_version(Protocol pver)
void iostat_tx_add(size_t bytes)
size_t conn_id
Channel number used for logging.
void set_component_id(uint8_t compid)
virtual IOStat get_iostat()
virtual void send_message(const mavlink::Message &message)
Send message (child of mavlink::Message)
static std::string msg_to_string(int errnum)
float rx_speed
current receive speed [B/s]
mavlink::mavlink_status_t m_parse_status
std::atomic< size_t > tx_total_bytes
Common exception for communication error.
std::lock_guard< std::recursive_mutex > lock_guard
std::chrono::time_point< steady_clock > last_iostat
void log_recv(const char *pfx, mavlink::mavlink_message_t &msg, Framing framing)
void iostat_rx_add(size_t bytes)
uint8_t get_component_id()
std::shared_ptr< MAVConnInterface const > ConstPtr
size_t tx_total_bytes
total bytes transferred
static void init_msg_entry()
MAVConnInterface(const MAVConnInterface &)=delete
static Ptr open_url_no_connect(std::string url, uint8_t system_id=1, uint8_t component_id=MAV_COMP_ID_UDP_BRIDGE)
version of open_url() which do not perform connect()
size_t last_rx_total_bytes
static std::string msg_to_string(boost::system::system_error &err)
std::weak_ptr< MAVConnInterface > WeakPtr
void log_send(const char *pfx, const mavlink::mavlink_message_t *msg)
Protocol
MAVLink protocol version.
size_t rx_total_bytes
total bytes received
static Ptr open_url(std::string url, uint8_t system_id=1, uint8_t component_id=MAV_COMP_ID_UDP_BRIDGE, const ReceivedCb &cb_handle_message=ReceivedCb(), const ClosedCb &cb_handle_closed_port=ClosedCb())
Construct connection from URL.
void set_system_id(uint8_t sysid)
Generic mavlink interface.
std::chrono::steady_clock steady_clock
virtual mavlink::mavlink_status_t get_status()
static std::vector< std::string > get_known_dialects()
static std::once_flag init_flag
init_msg_entry() once flag
static std::string msg_to_string(const char *description)
size_t last_tx_total_bytes
Framing
Rx packer framing status. (same as mavlink::mavlink_framing_t)
static std::atomic< size_t > conn_id_counter
monotonic counter (increment only)
void parse_buffer(const char *pfx, uint8_t *buf, const size_t bufsize, size_t bytes_received)
static constexpr auto MAV_COMP_ID_UDP_BRIDGE
Same as mavlink::common::MAV_COMPONENT::COMP_ID_UDP_BRIDGE.
std::shared_ptr< MAVConnInterface > Ptr
uint8_t sys_id
Connection System Id.
uint8_t comp_id
Connection Component Id.
void send_message_ignore_drop(const mavlink::mavlink_message_t *message)
Send message and ignore possible drop due to Tx queue limit.
std::recursive_mutex iostat_mutex
void log_send_obj(const char *pfx, const mavlink::Message &msg)
mavlink::mavlink_status_t * get_status_p()
virtual void connect(const ReceivedCb &cb_handle_message, const ClosedCb &cb_handle_closed_port=ClosedCb())=0
Establish connection, automatically called by open_url()
void send_message_ignore_drop(const mavlink::Message &message)
Send message and ignore possible drop due to Tx queue limit.
static constexpr size_t MAX_PACKET_SIZE
Maximum mavlink packet size + some extra bytes for padding.
std::function< void(void)> ClosedCb
float tx_speed
current transfer speed [B/s]
static std::unordered_map< mavlink::msgid_t, const mavlink::mavlink_msg_entry_t * > message_entries
This map merge all dialect mavlink_msg_entry_t structs. Needed for packet parser.
ClosedCb port_closed_cb
Port closed notification callback.
mavlink::mavlink_message_t m_buffer
virtual void send_message(const mavlink::mavlink_message_t *message)=0
Send message (mavlink_message_t)
mavlink::mavlink_message_t * get_buffer_p()
mavlink::mavlink_status_t m_mavlink_status
std::atomic< size_t > rx_total_bytes
static std::string make_message(const char *module, T msg)
Protocol get_protocol_version()
virtual void send_bytes(const uint8_t *bytes, size_t length)=0
Send raw bytes (for some quirks)
std::function< void(const mavlink::mavlink_message_t *message, const Framing framing)> ReceivedCb
libmavconn
Author(s): Vladimir Ermakov
autogenerated on Tue May 6 2025 02:34:01