Skip to content

Commit

Permalink
migrate to a new parameters style
Browse files Browse the repository at this point in the history
  • Loading branch information
PonomarevDA committed Jan 15, 2024
1 parent dc42e8f commit db881ee
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 57 deletions.
32 changes: 17 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ endif()
# Pathes
set(ROOT_DIR ${CMAKE_CURRENT_LIST_DIR})
set(LIBPARAMS_PATH ${ROOT_DIR}/Libs/libparams)
set(BUILD_SRC_DIR ${ROOT_DIR}/build/src)
if(USE_DRONECAN)
set(APPLICATION_DIR ${ROOT_DIR}/Src/dronecan_application)
else()
set(APPLICATION_DIR ${ROOT_DIR}/Src/cyphal_application)
endif()

# platform
if(USE_PLATFORM_UBUNTU)
Expand All @@ -23,14 +29,8 @@ else()
set(APP_PLATFORM stm32f103)
endif()

# libparams
include(${LIBPARAMS_PATH}/CMakeLists.txt)

if(USE_DRONECAN)
include(${ROOT_DIR}/Src/dronecan_application/CMakeLists.txt)
else()
include(${ROOT_DIR}/Src/cyphal_application/CMakeLists.txt)
endif()
include(${APPLICATION_DIR}/CMakeLists.txt)

if(USE_PLATFORM_UBUNTU)
else()
Expand Down Expand Up @@ -62,28 +62,30 @@ add_executable(${EXECUTABLE}
${stm32CubeMxGeneratedFiles}
${libsSourceCode}
${applicationSourceCode}
${BUILD_SRC_DIR}/params.cpp
${ROOT_DIR}/Src/platform/${APP_PLATFORM}/adc.cpp
${ROOT_DIR}/Src/platform/${APP_PLATFORM}/pwm.cpp
${ROOT_DIR}/Src/platform/${APP_PLATFORM}/led.cpp
${ROOT_DIR}/Src/platform/${APP_PLATFORM}/platform_specific.cpp
)

include_directories(${libsHeaders})

target_include_directories(${EXECUTABLE} PRIVATE
${ROOT_DIR}/build/src
${BUILD_SRC_DIR}
${stm32CubeMxHeaders}
${applicationHeaders}
${ROOT_DIR}/Src/platform/${APP_PLATFORM}
)

SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-volatile")

if(NOT USE_DRONECAN)
execute_process(
COMMAND ${CMAKE_CURRENT_LIST_DIR}/scripts/prebuild_cyphal.sh ${cyphalRegisters}
)
endif()
execute_process(
COMMAND ${LIBPARAMS_PATH}/scripts/generate_params.py --out-dir ${BUILD_SRC_DIR} -f ${LIBPARAMS_PARAMS}
)

execute_process(
COMMAND ${LIBPARAMS_PATH}/scripts/generate_docs.py ${LIBPARAMS_PARAMS}
WORKING_DIRECTORY ${APPLICATION_DIR}
)

execute_process(
COMMAND git rev-parse --short=16 HEAD
Expand Down
5 changes: 4 additions & 1 deletion Src/dronecan_application/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,14 @@ set(applicationSourceCode
${ROOT_DIR}/Src/dronecan_application/application.cpp
${ROOT_DIR}/Src/dronecan_application/modules/buzzer.cpp
${ROOT_DIR}/Src/dronecan_application/modules/pmu.cpp
${ROOT_DIR}/Src/dronecan_application/params.cpp
)
set(applicationHeaders
${libparamsHeaders}
${DRONECAN_HEADERS}
${ROOT_DIR}/Src
${ROOT_DIR}/Src/dronecan_application
)

set(LIBPARAMS_PARAMS
${CMAKE_CURRENT_LIST_DIR}/params.yaml
)
9 changes: 9 additions & 0 deletions Src/dronecan_application/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
The node has the following registers:

|| Register name | Description |
| -- | ----------------------- | ----------- |
| 1 | uavcan.node.id | Defines a node-ID. Allowed values [0,127]. |
| 2 | system.name | Defines custom node name. If empty, the node will use the default name. |

> This docs was automatically generated. Do not edit it manually.
3 changes: 1 addition & 2 deletions Src/dronecan_application/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include "dronecan.h"
#include "main.h"
#include "params.hpp"
#include "string_params.hpp"
#include "storage.h"
#include "periphery/led/led.hpp"
#include "periphery/adc/adc.hpp"
Expand All @@ -15,7 +14,7 @@ void application_entry_point() {
paramsInit(static_cast<uint8_t>(IntParamsIndexes::INTEGER_PARAMS_AMOUNT), NUM_OF_STR_PARAMS);
paramsLoadFromFlash();

auto node_id = paramsGetIntegerValue(UAVCAN_NODE_ID);
auto node_id = paramsGetIntegerValue(PARAM_UAVCAN_NODE_ID);
auto node_name = (const char*)paramsGetStringValue(static_cast<uint8_t>(IntParamsIndexes::INTEGER_PARAMS_AMOUNT));

LedPeriphery::reset();
Expand Down
1 change: 0 additions & 1 deletion Src/dronecan_application/modules/buzzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include "dronecan.h"
#include "main.h"
#include "params.hpp"
#include "string_params.hpp"
#include "storage.h"
#include "periphery/pwm/pwm.hpp"

Expand Down
2 changes: 0 additions & 2 deletions Src/dronecan_application/modules/pmu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
#include "dronecan.h"
#include "main.h"
#include "params.hpp"
#include "string_params.hpp"
#include "string_params.hpp"
#include "storage.h"
#include "periphery/adc/adc.hpp"
#include "uavcan/protocol/debug/LogMessage.h"
Expand Down
16 changes: 0 additions & 16 deletions Src/dronecan_application/params.cpp

This file was deleted.

15 changes: 0 additions & 15 deletions Src/dronecan_application/params.hpp

This file was deleted.

15 changes: 15 additions & 0 deletions Src/dronecan_application/params.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
uavcan.node.id:
type: Integer
note: Defines a node-ID. Allowed values [0,127].
enum: PARAM_UAVCAN_NODE_ID
flags: mutable
default: 42
min: 0
max: 255

system.name:
type: String
note: Defines custom node name. If empty, the node will use the default name.
enum: PARAM_SYSTEM_NAME
flags: mutable
default: "arl.pmu"
5 changes: 0 additions & 5 deletions Src/dronecan_application/string_params.hpp

This file was deleted.

0 comments on commit db881ee

Please sign in to comment.