Skip to content

Commit

Permalink
define protocol on build time if only one is being used
Browse files Browse the repository at this point in the history
  • Loading branch information
PonomarevDA committed Aug 25, 2024
1 parent e25d01a commit 27a49f4
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Src/applications/cyphal/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion Src/applications/cyphal/default_params.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
uavcan.node.id: 40
example.integer: 42
uavcan.sub.setpoint.id: 2000
uavcan.pub.feedback.id: 2001
2 changes: 2 additions & 0 deletions Src/applications/dronecan/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions Src/common/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -75,6 +80,7 @@ Module::Protocol get_protocol() {
}

return protocol;
#endif
}

__attribute__((noreturn)) void application_entry_point() {
Expand Down

0 comments on commit 27a49f4

Please sign in to comment.