From 27a49f4d4934a6522f1cf08db4f94a4db6cf42eb Mon Sep 17 00:00:00 2001 From: PonomarevDA Date: Sun, 25 Aug 2024 12:08:05 +0300 Subject: [PATCH] define protocol on build time if only one is being used --- Src/applications/cyphal/CMakeLists.txt | 2 ++ Src/applications/cyphal/default_params.yml | 1 - Src/applications/dronecan/CMakeLists.txt | 2 ++ Src/common/application.cpp | 6 ++++++ 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Src/applications/cyphal/CMakeLists.txt b/Src/applications/cyphal/CMakeLists.txt index 1bd6f34..6bea3d9 100644 --- a/Src/applications/cyphal/CMakeLists.txt +++ b/Src/applications/cyphal/CMakeLists.txt @@ -5,6 +5,8 @@ set(APPLICATION_DIR ${CMAKE_CURRENT_LIST_DIR}) cmake_path(GET CMAKE_CURRENT_LIST_DIR PARENT_PATH APPLICATIONS_DIR) cmake_path(GET APPLICATIONS_DIR PARENT_PATH SRC_DIR) +add_definitions(-DCONFIG_USE_CYPHAL=1) + include(${SRC_DIR}/modules/cyphal/core/CMakeLists.txt) include(${SRC_DIR}/modules/circuit_status/cyphal/CMakeLists.txt) include(${SRC_DIR}/modules/cyphal/feedback/CMakeLists.txt) diff --git a/Src/applications/cyphal/default_params.yml b/Src/applications/cyphal/default_params.yml index fde7781..f81af9b 100644 --- a/Src/applications/cyphal/default_params.yml +++ b/Src/applications/cyphal/default_params.yml @@ -1,4 +1,3 @@ uavcan.node.id: 40 -example.integer: 42 uavcan.sub.setpoint.id: 2000 uavcan.pub.feedback.id: 2001 diff --git a/Src/applications/dronecan/CMakeLists.txt b/Src/applications/dronecan/CMakeLists.txt index 311aad1..2f1e6a2 100644 --- a/Src/applications/dronecan/CMakeLists.txt +++ b/Src/applications/dronecan/CMakeLists.txt @@ -5,6 +5,8 @@ set(APPLICATION_DIR ${CMAKE_CURRENT_LIST_DIR}) cmake_path(GET CMAKE_CURRENT_LIST_DIR PARENT_PATH APPLICATIONS_DIR) cmake_path(GET APPLICATIONS_DIR PARENT_PATH SRC_DIR) +add_definitions(-DCONFIG_USE_DRONECAN=1) + include(${SRC_DIR}/modules/dronecan/core/CMakeLists.txt) include(${SRC_DIR}/modules/circuit_status/dronecan/CMakeLists.txt) include(${SRC_DIR}/modules/dronecan/pwm/CMakeLists.txt) diff --git a/Src/common/application.cpp b/Src/common/application.cpp index 38ef76c..e7b894c 100644 --- a/Src/common/application.cpp +++ b/Src/common/application.cpp @@ -65,6 +65,11 @@ static void blink_board_led() { } Module::Protocol get_protocol() { +#if defined(CONFIG_USE_CYPHAL) && !defined(CONFIG_USE_DRONECAN) + return Module::Protocol::CYPHAL; +#elif !defined(CONFIG_USE_CYPHAL) && defined(CONFIG_USE_DRONECAN) + return Module::Protocol::DRONECAN; +#else auto system_protocol = paramsGetIntegerValue(PARAM_SYSTEM_PROTOCOL); Module::Protocol protocol; @@ -75,6 +80,7 @@ Module::Protocol get_protocol() { } return protocol; +#endif } __attribute__((noreturn)) void application_entry_point() {