From f3e8819d1ecebe50fe82552ed73c74fb4cb8a683 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 8 Sep 2015 13:53:58 +1000 Subject: [PATCH] GCS_MAVLink: make send_statustext_all() take a format string this allows for formatted messages to all groundstations in libraries --- libraries/GCS_MAVLink/GCS.h | 2 +- libraries/GCS_MAVLink/GCS_Common.cpp | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/libraries/GCS_MAVLink/GCS.h b/libraries/GCS_MAVLink/GCS.h index 211bda9342..69502d8751 100644 --- a/libraries/GCS_MAVLink/GCS.h +++ b/libraries/GCS_MAVLink/GCS.h @@ -163,7 +163,7 @@ public: connections. This function is static so it can be called from any library */ - static void send_statustext_all(const prog_char_t *msg); + static void send_statustext_all(const prog_char_t *fmt, ...); /* send a MAVLink message to all components with this vehicle's system id diff --git a/libraries/GCS_MAVLink/GCS_Common.cpp b/libraries/GCS_MAVLink/GCS_Common.cpp index 6f2b005f1f..877452c429 100644 --- a/libraries/GCS_MAVLink/GCS_Common.cpp +++ b/libraries/GCS_MAVLink/GCS_Common.cpp @@ -1169,14 +1169,17 @@ void GCS_MAVLINK::send_ahrs(AP_AHRS &ahrs) /* send a statustext message to all active MAVLink connections */ -void GCS_MAVLINK::send_statustext_all(const prog_char_t *msg) +void GCS_MAVLINK::send_statustext_all(const prog_char_t *fmt, ...) { for (uint8_t i=0; i= MAVLINK_NUM_NON_PAYLOAD_BYTES + MAVLINK_MSG_ID_STATUSTEXT_LEN) { char msg2[50]; - strncpy_P(msg2, msg, sizeof(msg2)); + va_list arg_list; + va_start(arg_list, fmt); + hal.util->vsnprintf_P((char *)msg2, sizeof(msg2), fmt, arg_list); + va_end(arg_list); mavlink_msg_statustext_send(chan, MAV_SEVERITY_CRITICAL, msg2);