From 632bb71c87e84627cef1e681b270f0a90267cea7 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 10 Feb 2024 15:25:48 +1100 Subject: [PATCH] GCS_MAVLink: use can_printf_severity() for AP_Periph --- libraries/GCS_MAVLink/GCS.h | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/libraries/GCS_MAVLink/GCS.h b/libraries/GCS_MAVLink/GCS.h index 1990426423b60..95cc4237fe2ee 100644 --- a/libraries/GCS_MAVLink/GCS.h +++ b/libraries/GCS_MAVLink/GCS.h @@ -1346,9 +1346,9 @@ GCS &gcs(); #define AP_HAVE_GCS_SEND_TEXT 1 #else extern "C" { -void can_printf(const char *fmt, ...); + void can_printf_severity(uint8_t severity, const char *fmt, ...); } -#define GCS_SEND_TEXT(severity, format, args...) (void)severity; can_printf(format, ##args) +#define GCS_SEND_TEXT(severity, format, args...) can_printf_severity(severity, format, ##args) #define AP_HAVE_GCS_SEND_TEXT 1 #endif @@ -1358,12 +1358,31 @@ void can_printf(const char *fmt, ...); // map send text to can_printf() on larger AP_Periph boards extern "C" { -void can_printf(const char *fmt, ...); + void can_printf_severity(uint8_t severity, const char *fmt, ...); } -#define GCS_SEND_TEXT(severity, format, args...) can_printf(format, ##args) +#define GCS_SEND_TEXT(severity, format, args...) can_printf_severity(severity, format, ##args) #define GCS_SEND_MESSAGE(msg) #define AP_HAVE_GCS_SEND_TEXT 1 +/* + we need a severity enum for the can_printf_severity function with no GCS present + */ +#ifndef HAVE_ENUM_MAV_SEVERITY +enum MAV_SEVERITY +{ + MAV_SEVERITY_EMERGENCY=0, + MAV_SEVERITY_ALERT=1, + MAV_SEVERITY_CRITICAL=2, + MAV_SEVERITY_ERROR=3, + MAV_SEVERITY_WARNING=4, + MAV_SEVERITY_NOTICE=5, + MAV_SEVERITY_INFO=6, + MAV_SEVERITY_DEBUG=7, + MAV_SEVERITY_ENUM_END=8, +}; +#define HAVE_ENUM_MAV_SEVERITY +#endif + #else // HAL_GCS_ENABLED // empty send text when we have no GCS #define GCS_SEND_TEXT(severity, format, args...)