2010-11-25 02:38:18 -04:00
|
|
|
/// @file GCS_MAVLink.h
|
|
|
|
/// @brief One size fits all header for MAVLink integration.
|
2016-02-17 21:25:55 -04:00
|
|
|
#pragma once
|
2010-11-25 02:38:18 -04:00
|
|
|
|
2019-07-17 01:50:12 -03:00
|
|
|
#include <AP_HAL/AP_HAL_Boards.h>
|
2011-08-31 02:23:18 -03:00
|
|
|
|
2012-04-24 09:17:20 -03:00
|
|
|
// we have separate helpers disabled to make it possible
|
|
|
|
// to select MAVLink 1.0 in the arduino GUI build
|
2012-08-30 23:09:52 -03:00
|
|
|
#define MAVLINK_SEPARATE_HELPERS
|
2018-05-03 23:12:15 -03:00
|
|
|
#define MAVLINK_NO_CONVERSION_HELPERS
|
2011-09-17 22:03:27 -03:00
|
|
|
|
2013-01-08 00:58:40 -04:00
|
|
|
#define MAVLINK_SEND_UART_BYTES(chan, buf, len) comm_send_buffer(chan, buf, len)
|
|
|
|
|
2018-08-06 02:51:38 -03:00
|
|
|
#define MAVLINK_START_UART_SEND(chan, size) comm_send_lock(chan)
|
|
|
|
#define MAVLINK_END_UART_SEND(chan, size) comm_send_unlock(chan)
|
|
|
|
|
2018-03-31 06:05:01 -03:00
|
|
|
#if CONFIG_HAL_BOARD == HAL_BOARD_SITL
|
|
|
|
// allow extra mavlink channels in SITL for:
|
|
|
|
// Vicon
|
|
|
|
#define MAVLINK_COMM_NUM_BUFFERS 6
|
|
|
|
#else
|
2016-04-19 00:49:12 -03:00
|
|
|
// allow five telemetry ports
|
|
|
|
#define MAVLINK_COMM_NUM_BUFFERS 5
|
2018-03-31 06:05:01 -03:00
|
|
|
#endif
|
2013-01-08 00:58:40 -04:00
|
|
|
|
2014-07-25 02:46:20 -03:00
|
|
|
/*
|
|
|
|
The MAVLink protocol code generator does its own alignment, so
|
|
|
|
alignment cast warnings can be ignored
|
|
|
|
*/
|
|
|
|
#pragma GCC diagnostic push
|
|
|
|
#pragma GCC diagnostic ignored "-Wcast-align"
|
2019-05-02 06:34:52 -03:00
|
|
|
|
|
|
|
#if defined(__GNUC__) && __GNUC__ >= 9
|
2019-05-01 21:49:36 -03:00
|
|
|
#pragma GCC diagnostic ignored "-Waddress-of-packed-member"
|
2019-05-02 06:34:52 -03:00
|
|
|
#endif
|
2014-07-25 02:46:20 -03:00
|
|
|
|
2016-01-11 18:22:05 -04:00
|
|
|
#include "include/mavlink/v2.0/ardupilotmega/version.h"
|
2011-09-04 05:51:51 -03:00
|
|
|
|
2014-03-10 23:48:25 -03:00
|
|
|
#define MAVLINK_MAX_PAYLOAD_LEN 255
|
2011-09-04 05:51:51 -03:00
|
|
|
|
2016-01-11 18:22:05 -04:00
|
|
|
#include "include/mavlink/v2.0/mavlink_types.h"
|
2010-11-25 02:38:18 -04:00
|
|
|
|
2013-11-22 04:17:34 -04:00
|
|
|
/// MAVLink stream used for uartA
|
2015-05-15 02:40:23 -03:00
|
|
|
extern AP_HAL::UARTDriver *mavlink_comm_port[MAVLINK_COMM_NUM_BUFFERS];
|
2018-03-25 07:45:48 -03:00
|
|
|
extern bool gcs_alternative_active[MAVLINK_COMM_NUM_BUFFERS];
|
2015-05-02 09:38:07 -03:00
|
|
|
|
2010-11-25 02:38:18 -04:00
|
|
|
/// MAVLink system definition
|
|
|
|
extern mavlink_system_t mavlink_system;
|
|
|
|
|
2016-03-28 11:33:59 -03:00
|
|
|
/// Sanity check MAVLink channel
|
|
|
|
///
|
|
|
|
/// @param chan Channel to send to
|
|
|
|
static inline bool valid_channel(mavlink_channel_t chan)
|
|
|
|
{
|
|
|
|
#pragma clang diagnostic push
|
|
|
|
#pragma clang diagnostic ignored "-Wtautological-constant-out-of-range-compare"
|
2016-03-29 23:45:09 -03:00
|
|
|
return chan < MAVLINK_COMM_NUM_BUFFERS;
|
2016-03-28 11:33:59 -03:00
|
|
|
#pragma clang diagnostic pop
|
|
|
|
}
|
|
|
|
|
2013-01-08 00:31:01 -04:00
|
|
|
void comm_send_buffer(mavlink_channel_t chan, const uint8_t *buf, uint8_t len);
|
|
|
|
|
2011-09-04 18:23:24 -03:00
|
|
|
/// Check for available transmit space on the nominated MAVLink channel
|
|
|
|
///
|
|
|
|
/// @param chan Channel to check
|
2012-09-24 18:20:43 -03:00
|
|
|
/// @returns Number of bytes available
|
2014-04-03 23:19:15 -03:00
|
|
|
uint16_t comm_get_txspace(mavlink_channel_t chan);
|
2011-09-04 18:23:24 -03:00
|
|
|
|
2010-11-25 02:38:18 -04:00
|
|
|
#define MAVLINK_USE_CONVENIENCE_FUNCTIONS
|
2016-01-11 18:22:05 -04:00
|
|
|
#include "include/mavlink/v2.0/ardupilotmega/mavlink.h"
|
2010-11-25 02:38:18 -04:00
|
|
|
|
2018-08-06 02:51:38 -03:00
|
|
|
// lock and unlock a channel, for multi-threaded mavlink send
|
|
|
|
void comm_send_lock(mavlink_channel_t chan);
|
|
|
|
void comm_send_unlock(mavlink_channel_t chan);
|
|
|
|
|
2014-07-25 02:46:20 -03:00
|
|
|
#pragma GCC diagnostic pop
|