From 55e6008e388e81c4d3745a7a8ac37eb5fbc762e9 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 bf4fbc6e62..eeac51fdc4 100644 --- a/libraries/GCS_MAVLink/GCS.h +++ b/libraries/GCS_MAVLink/GCS.h @@ -161,7 +161,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 7af5e0db1f..f15016157e 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, SEVERITY_HIGH, msg2);