From 25862aa1950f92837199320b01b73825d2c8c838 Mon Sep 17 00:00:00 2001 From: mileticveljko Date: Fri, 9 Jan 2026 12:43:25 +0100 Subject: [PATCH] Fix mavlink bug caused by implicit declarations of channel status and channel buffer getters --- app/src/telemetry_packer.c | 4 +++ libs/telemetry/mavlink/CMakeLists.txt | 1 + .../mavlink/include/mavlink_custom.h | 27 +++++++++++++++++++ libs/telemetry/mavlink/mavlink.c | 2 +- 4 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 libs/telemetry/mavlink/include/mavlink_custom.h diff --git a/app/src/telemetry_packer.c b/app/src/telemetry_packer.c index fc3da1e..8f76bfc 100644 --- a/app/src/telemetry_packer.c +++ b/app/src/telemetry_packer.c @@ -19,7 +19,11 @@ #include #include +// MAVLink headers +// clang-format off +#include "mavlink_custom.h" // Needs to be included before any MAVLink header inclusion #include "common/mavlink.h" +// clang-format on #include "types.h" diff --git a/libs/telemetry/mavlink/CMakeLists.txt b/libs/telemetry/mavlink/CMakeLists.txt index a10bf1e..e09dfb2 100644 --- a/libs/telemetry/mavlink/CMakeLists.txt +++ b/libs/telemetry/mavlink/CMakeLists.txt @@ -49,6 +49,7 @@ STATIC target_include_directories(mavlink SYSTEM PUBLIC + include ${GENERATED_DIR} ) diff --git a/libs/telemetry/mavlink/include/mavlink_custom.h b/libs/telemetry/mavlink/include/mavlink_custom.h new file mode 100644 index 0000000..1de0713 --- /dev/null +++ b/libs/telemetry/mavlink/include/mavlink_custom.h @@ -0,0 +1,27 @@ +/* + * This file is part of the efc project . + * Copyright (c) (2024 - Present), The efc developers. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef __MAVLINK_CUSTOM_H__ +#define __MAVLINK_CUSTOM_H__ + +#include "mavlink_types.h" + +/* Prototypes must be visible to anyone including MAVLink */ +mavlink_status_t *mavlink_get_channel_status(uint8_t chan); +mavlink_message_t *mavlink_get_channel_buffer(uint8_t chan); + +#endif diff --git a/libs/telemetry/mavlink/mavlink.c b/libs/telemetry/mavlink/mavlink.c index cb10214..3762417 100644 --- a/libs/telemetry/mavlink/mavlink.c +++ b/libs/telemetry/mavlink/mavlink.c @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -#include "mavlink_types.h" +#include "mavlink_custom.h" /* Global status and buffer instances for each channel */ static mavlink_status_t chan_statuses[MAVLINK_COMM_NUM_BUFFERS];