|
|
|
@ -542,7 +542,7 @@ static void NOINLINE send_current_waypoint(mavlink_channel_t chan)
@@ -542,7 +542,7 @@ static void NOINLINE send_current_waypoint(mavlink_channel_t chan)
|
|
|
|
|
|
|
|
|
|
static void NOINLINE send_statustext(mavlink_channel_t chan) |
|
|
|
|
{ |
|
|
|
|
mavlink_statustext_t *s = (chan == MAVLINK_COMM_0?&gcs0.pending_status:&gcs3.pending_status); |
|
|
|
|
mavlink_statustext_t *s = &gcs[chan-MAVLINK_COMM_0].pending_status; |
|
|
|
|
mavlink_msg_statustext_send( |
|
|
|
|
chan, |
|
|
|
|
s->severity, |
|
|
|
@ -670,20 +670,12 @@ static bool mavlink_try_send_message(mavlink_channel_t chan, enum ap_message id,
@@ -670,20 +670,12 @@ static bool mavlink_try_send_message(mavlink_channel_t chan, enum ap_message id,
|
|
|
|
|
|
|
|
|
|
case MSG_NEXT_PARAM: |
|
|
|
|
CHECK_PAYLOAD_SIZE(PARAM_VALUE); |
|
|
|
|
if (chan == MAVLINK_COMM_0) { |
|
|
|
|
gcs0.queued_param_send(); |
|
|
|
|
} else if (gcs3.initialised) { |
|
|
|
|
gcs3.queued_param_send(); |
|
|
|
|
} |
|
|
|
|
gcs[chan-MAVLINK_COMM_0].queued_param_send(); |
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
case MSG_NEXT_WAYPOINT: |
|
|
|
|
CHECK_PAYLOAD_SIZE(MISSION_REQUEST); |
|
|
|
|
if (chan == MAVLINK_COMM_0) { |
|
|
|
|
gcs0.queued_waypoint_send(); |
|
|
|
|
} else if (gcs3.initialised) { |
|
|
|
|
gcs3.queued_waypoint_send(); |
|
|
|
|
} |
|
|
|
|
gcs[chan-MAVLINK_COMM_0].queued_waypoint_send(); |
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
case MSG_STATUSTEXT: |
|
|
|
@ -792,7 +784,7 @@ void mavlink_send_text(mavlink_channel_t chan, gcs_severity severity, const char
@@ -792,7 +784,7 @@ void mavlink_send_text(mavlink_channel_t chan, gcs_severity severity, const char
|
|
|
|
|
|
|
|
|
|
if (severity == SEVERITY_LOW) { |
|
|
|
|
// send via the deferred queuing system |
|
|
|
|
mavlink_statustext_t *s = (chan == MAVLINK_COMM_0?&gcs0.pending_status:&gcs3.pending_status); |
|
|
|
|
mavlink_statustext_t *s = &gcs[chan-MAVLINK_COMM_0].pending_status; |
|
|
|
|
s->severity = (uint8_t)severity; |
|
|
|
|
strncpy((char *)s->text, str, sizeof(s->text)); |
|
|
|
|
mavlink_send_message(chan, MSG_STATUSTEXT, 0); |
|
|
|
@ -905,9 +897,17 @@ GCS_MAVLINK::init(AP_HAL::UARTDriver *port)
@@ -905,9 +897,17 @@ GCS_MAVLINK::init(AP_HAL::UARTDriver *port)
|
|
|
|
|
if (port == (AP_HAL::BetterStream*)hal.uartA) { |
|
|
|
|
mavlink_comm_0_port = port; |
|
|
|
|
chan = MAVLINK_COMM_0; |
|
|
|
|
}else{ |
|
|
|
|
initialised = true; |
|
|
|
|
} else if (port == (AP_HAL::BetterStream*)hal.uartC) { |
|
|
|
|
mavlink_comm_1_port = port; |
|
|
|
|
chan = MAVLINK_COMM_1; |
|
|
|
|
initialised = true; |
|
|
|
|
#if MAVLINK_COMM_NUM_BUFFERS > 2 |
|
|
|
|
} else if (port == (AP_HAL::BetterStream*)hal.uartD) { |
|
|
|
|
mavlink_comm_2_port = port; |
|
|
|
|
chan = MAVLINK_COMM_2; |
|
|
|
|
initialised = true; |
|
|
|
|
#endif |
|
|
|
|
} |
|
|
|
|
_queued_parameter = NULL; |
|
|
|
|
reset_cli_timeout(); |
|
|
|
@ -2137,12 +2137,13 @@ mission_failed:
@@ -2137,12 +2137,13 @@ mission_failed:
|
|
|
|
|
|
|
|
|
|
default: |
|
|
|
|
// forward unknown messages to the other link if there is one |
|
|
|
|
if ((chan == MAVLINK_COMM_1 && gcs0.initialised) || |
|
|
|
|
(chan == MAVLINK_COMM_0 && gcs3.initialised)) { |
|
|
|
|
mavlink_channel_t out_chan = (mavlink_channel_t)(((uint8_t)chan)^1); |
|
|
|
|
// only forward if it would fit in our transmit buffer |
|
|
|
|
if (comm_get_txspace(out_chan) > ((uint16_t)msg->len) + MAVLINK_NUM_NON_PAYLOAD_BYTES) { |
|
|
|
|
_mavlink_resend_uart(out_chan, msg); |
|
|
|
|
for (uint8_t i=0; i<num_gcs; i++) { |
|
|
|
|
if (gcs[i].initialised && i != (uint8_t)chan) { |
|
|
|
|
mavlink_channel_t out_chan = (mavlink_channel_t)i; |
|
|
|
|
// only forward if it would fit in the transmit buffer |
|
|
|
|
if (comm_get_txspace(out_chan) > ((uint16_t)msg->len) + MAVLINK_NUM_NON_PAYLOAD_BYTES) { |
|
|
|
|
_mavlink_resend_uart(out_chan, msg); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
@ -2173,7 +2174,7 @@ GCS_MAVLINK::_count_parameters()
@@ -2173,7 +2174,7 @@ GCS_MAVLINK::_count_parameters()
|
|
|
|
|
void |
|
|
|
|
GCS_MAVLINK::queued_param_send() |
|
|
|
|
{ |
|
|
|
|
if (_queued_parameter == NULL) { |
|
|
|
|
if (!initialised || _queued_parameter == NULL) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -2223,7 +2224,8 @@ GCS_MAVLINK::queued_param_send()
@@ -2223,7 +2224,8 @@ GCS_MAVLINK::queued_param_send()
|
|
|
|
|
void |
|
|
|
|
GCS_MAVLINK::queued_waypoint_send() |
|
|
|
|
{ |
|
|
|
|
if (waypoint_receiving && |
|
|
|
|
if (initialised && |
|
|
|
|
waypoint_receiving && |
|
|
|
|
waypoint_request_i <= waypoint_request_last) { |
|
|
|
|
mavlink_msg_mission_request_send( |
|
|
|
|
chan, |
|
|
|
@ -2245,7 +2247,7 @@ void GCS_MAVLINK::reset_cli_timeout() {
@@ -2245,7 +2247,7 @@ void GCS_MAVLINK::reset_cli_timeout() {
|
|
|
|
|
static void mavlink_delay_cb() |
|
|
|
|
{ |
|
|
|
|
static uint32_t last_1hz, last_50hz, last_5s; |
|
|
|
|
if (!gcs0.initialised) return; |
|
|
|
|
if (!gcs[0].initialised) return; |
|
|
|
|
|
|
|
|
|
in_mavlink_delay = true; |
|
|
|
|
|
|
|
|
@ -2275,9 +2277,10 @@ static void mavlink_delay_cb()
@@ -2275,9 +2277,10 @@ static void mavlink_delay_cb()
|
|
|
|
|
*/ |
|
|
|
|
static void gcs_send_message(enum ap_message id) |
|
|
|
|
{ |
|
|
|
|
gcs0.send_message(id); |
|
|
|
|
if (gcs3.initialised) { |
|
|
|
|
gcs3.send_message(id); |
|
|
|
|
for (uint8_t i=0; i<num_gcs; i++) { |
|
|
|
|
if (gcs[i].initialised) { |
|
|
|
|
gcs[i].send_message(id); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -2286,9 +2289,10 @@ static void gcs_send_message(enum ap_message id)
@@ -2286,9 +2289,10 @@ static void gcs_send_message(enum ap_message id)
|
|
|
|
|
*/ |
|
|
|
|
static void gcs_data_stream_send(void) |
|
|
|
|
{ |
|
|
|
|
gcs0.data_stream_send(); |
|
|
|
|
if (gcs3.initialised) { |
|
|
|
|
gcs3.data_stream_send(); |
|
|
|
|
for (uint8_t i=0; i<num_gcs; i++) { |
|
|
|
|
if (gcs[i].initialised) { |
|
|
|
|
gcs[i].data_stream_send(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -2297,17 +2301,19 @@ static void gcs_data_stream_send(void)
@@ -2297,17 +2301,19 @@ static void gcs_data_stream_send(void)
|
|
|
|
|
*/ |
|
|
|
|
static void gcs_update(void) |
|
|
|
|
{ |
|
|
|
|
gcs0.update(); |
|
|
|
|
if (gcs3.initialised) { |
|
|
|
|
gcs3.update(); |
|
|
|
|
for (uint8_t i=0; i<num_gcs; i++) { |
|
|
|
|
if (gcs[i].initialised) { |
|
|
|
|
gcs[i].update(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void gcs_send_text_P(gcs_severity severity, const prog_char_t *str) |
|
|
|
|
{ |
|
|
|
|
gcs0.send_text_P(severity, str); |
|
|
|
|
if (gcs3.initialised) { |
|
|
|
|
gcs3.send_text_P(severity, str); |
|
|
|
|
for (uint8_t i=0; i<num_gcs; i++) { |
|
|
|
|
if (gcs[i].initialised) { |
|
|
|
|
gcs[i].send_text_P(severity, str); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
#if LOGGING_ENABLED == ENABLED |
|
|
|
|
DataFlash.Log_Write_Message_P(str); |
|
|
|
@ -2322,18 +2328,20 @@ static void gcs_send_text_P(gcs_severity severity, const prog_char_t *str)
@@ -2322,18 +2328,20 @@ static void gcs_send_text_P(gcs_severity severity, const prog_char_t *str)
|
|
|
|
|
void gcs_send_text_fmt(const prog_char_t *fmt, ...) |
|
|
|
|
{ |
|
|
|
|
va_list arg_list; |
|
|
|
|
gcs0.pending_status.severity = (uint8_t)SEVERITY_LOW; |
|
|
|
|
gcs[0].pending_status.severity = (uint8_t)SEVERITY_LOW; |
|
|
|
|
va_start(arg_list, fmt); |
|
|
|
|
hal.util->vsnprintf_P((char *)gcs0.pending_status.text, |
|
|
|
|
sizeof(gcs0.pending_status.text), fmt, arg_list); |
|
|
|
|
hal.util->vsnprintf_P((char *)gcs[0].pending_status.text, |
|
|
|
|
sizeof(gcs[0].pending_status.text), fmt, arg_list); |
|
|
|
|
va_end(arg_list); |
|
|
|
|
#if LOGGING_ENABLED == ENABLED |
|
|
|
|
DataFlash.Log_Write_Message(gcs0.pending_status.text); |
|
|
|
|
DataFlash.Log_Write_Message(gcs[0].pending_status.text); |
|
|
|
|
#endif |
|
|
|
|
gcs3.pending_status = gcs0.pending_status; |
|
|
|
|
mavlink_send_message(MAVLINK_COMM_0, MSG_STATUSTEXT, 0); |
|
|
|
|
if (gcs3.initialised) { |
|
|
|
|
mavlink_send_message(MAVLINK_COMM_1, MSG_STATUSTEXT, 0); |
|
|
|
|
for (uint8_t i=1; i<num_gcs; i++) { |
|
|
|
|
if (gcs[i].initialised) { |
|
|
|
|
gcs[i].pending_status = gcs[0].pending_status; |
|
|
|
|
mavlink_send_message((mavlink_channel_t)i, MSG_STATUSTEXT, 0); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -2342,14 +2350,10 @@ void gcs_send_text_fmt(const prog_char_t *fmt, ...)
@@ -2342,14 +2350,10 @@ void gcs_send_text_fmt(const prog_char_t *fmt, ...)
|
|
|
|
|
*/ |
|
|
|
|
static void gcs_send_airspeed_calibration(const Vector3f &vg) |
|
|
|
|
{ |
|
|
|
|
if (comm_get_txspace(MAVLINK_COMM_0) - MAVLINK_NUM_NON_PAYLOAD_BYTES >= |
|
|
|
|
MAVLINK_MSG_ID_AIRSPEED_AUTOCAL_LEN) { |
|
|
|
|
airspeed.log_mavlink_send(MAVLINK_COMM_0, vg); |
|
|
|
|
} |
|
|
|
|
if (gcs3.initialised) { |
|
|
|
|
if (comm_get_txspace(MAVLINK_COMM_1) - MAVLINK_NUM_NON_PAYLOAD_BYTES >= |
|
|
|
|
for (uint8_t i=0; i<num_gcs; i++) { |
|
|
|
|
if (comm_get_txspace((mavlink_channel_t)i) - MAVLINK_NUM_NON_PAYLOAD_BYTES >= |
|
|
|
|
MAVLINK_MSG_ID_AIRSPEED_AUTOCAL_LEN) { |
|
|
|
|
airspeed.log_mavlink_send(MAVLINK_COMM_1, vg); |
|
|
|
|
airspeed.log_mavlink_send((mavlink_channel_t)i, vg); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|