2017-07-08 21:24:43 -03:00
|
|
|
#include "GCS.h"
|
|
|
|
|
|
|
|
extern const AP_HAL::HAL& hal;
|
|
|
|
|
|
|
|
/*
|
|
|
|
send a text message to all GCS
|
|
|
|
*/
|
|
|
|
void GCS::send_text(MAV_SEVERITY severity, const char *fmt, ...)
|
|
|
|
{
|
|
|
|
char text[MAVLINK_MSG_STATUSTEXT_FIELD_TEXT_LEN+1] {};
|
|
|
|
va_list arg_list;
|
|
|
|
va_start(arg_list, fmt);
|
|
|
|
hal.util->vsnprintf((char *)text, sizeof(text)-1, fmt, arg_list);
|
|
|
|
va_end(arg_list);
|
|
|
|
text[MAVLINK_MSG_STATUSTEXT_FIELD_TEXT_LEN] = 0;
|
|
|
|
send_statustext(severity, GCS_MAVLINK::active_channel_mask() | GCS_MAVLINK::streaming_channel_mask(), text);
|
|
|
|
}
|
2017-07-08 03:26:34 -03:00
|
|
|
|
|
|
|
#define FOR_EACH_ACTIVE_CHANNEL(methodcall) \
|
|
|
|
do { \
|
|
|
|
for (uint8_t i=0; i<num_gcs(); i++) { \
|
|
|
|
if (!chan(i).initialised) { \
|
|
|
|
continue; \
|
|
|
|
} \
|
2017-08-29 03:04:40 -03:00
|
|
|
if (!(GCS_MAVLINK::active_channel_mask() & (1 << (chan(i).get_chan()-MAVLINK_COMM_0)))) { \
|
2017-07-08 03:26:34 -03:00
|
|
|
continue; \
|
|
|
|
} \
|
|
|
|
chan(i).methodcall; \
|
|
|
|
} \
|
2017-08-29 03:04:40 -03:00
|
|
|
} while (0)
|
2017-07-08 03:26:34 -03:00
|
|
|
|
|
|
|
void GCS::send_home(const Location &home) const
|
|
|
|
{
|
|
|
|
FOR_EACH_ACTIVE_CHANNEL(send_home(home));
|
|
|
|
}
|
|
|
|
|
2017-09-17 22:35:12 -03:00
|
|
|
void GCS::send_ekf_origin(const Location &ekf_origin) const
|
|
|
|
{
|
|
|
|
FOR_EACH_ACTIVE_CHANNEL(send_ekf_origin(ekf_origin));
|
|
|
|
}
|
|
|
|
|
2018-03-25 07:45:48 -03:00
|
|
|
/*
|
|
|
|
install an alternative protocol handler. This allows another
|
|
|
|
protocol to take over the link if MAVLink goes idle. It is used to
|
|
|
|
allow for the AP_BLHeli pass-thru protocols to run on hal.uartA
|
|
|
|
*/
|
|
|
|
bool GCS::install_alternative_protocol(mavlink_channel_t c, GCS_MAVLINK::protocol_handler_fn_t handler)
|
|
|
|
{
|
|
|
|
if (c >= num_gcs()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (chan(c).alternative.handler) {
|
|
|
|
// already have one installed - we may need to add support for
|
|
|
|
// multiple alternative handlers
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
chan(c).alternative.handler = handler;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-07-08 03:26:34 -03:00
|
|
|
#undef FOR_EACH_ACTIVE_CHANNEL
|