From ed063994a1a12e20a6178a49d69ea1dc9ba9dd93 Mon Sep 17 00:00:00 2001 From: Dmitry Ponomarev <36133264+PonomarevDA@users.noreply.github.com> Date: Thu, 2 Nov 2023 00:22:38 +0300 Subject: [PATCH] update registers and add a few examples (#5) --- CMakeLists.txt | 3 ++- Libs/Cyphal | 2 +- Libs/libparams | 2 +- Makefile | 1 + Src/cyphal_application/application.cpp | 1 - Src/cyphal_application/params.cpp | 18 ------------------ Src/cyphal_application/params.hpp | 16 ---------------- Src/cyphal_application/params.yaml | 17 +++++++++++++++++ Src/cyphal_application/string_params.hpp | 6 ------ Src/dronecan_application/params.cpp | 4 ++-- scripts/prebuild_cyphal.sh | 10 ++++++++++ 11 files changed, 34 insertions(+), 46 deletions(-) delete mode 100644 Src/cyphal_application/params.cpp delete mode 100644 Src/cyphal_application/params.hpp create mode 100644 Src/cyphal_application/params.yaml delete mode 100644 Src/cyphal_application/string_params.hpp create mode 100755 scripts/prebuild_cyphal.sh diff --git a/CMakeLists.txt b/CMakeLists.txt index f5bc1e4..ad823d2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,7 +42,8 @@ else() ) set(applicationSourceCode Src/cyphal_application/application.cpp - Src/cyphal_application/params.cpp + build/src/params.cpp + build/src/string_params.cpp ) set(applicationHeaders Src/cyphal_application diff --git a/Libs/Cyphal b/Libs/Cyphal index 94fd6e4..507767d 160000 --- a/Libs/Cyphal +++ b/Libs/Cyphal @@ -1 +1 @@ -Subproject commit 94fd6e4b0f949bfe68e2541fce06466cf5aa1c8e +Subproject commit 507767d979bba0691c3deab0ad0d67175f433196 diff --git a/Libs/libparams b/Libs/libparams index ecac253..6d1092d 160000 --- a/Libs/libparams +++ b/Libs/libparams @@ -1 +1 @@ -Subproject commit ecac253680c249baecbc1fb0b9ffc08781c822ad +Subproject commit 6d1092dce76b4af610e1648e404f65bfd3a0733f diff --git a/Makefile b/Makefile index 996eb83..cead9ed 100644 --- a/Makefile +++ b/Makefile @@ -7,6 +7,7 @@ BUILD_OBJ_DIR:=build/obj cyphal: clean autogenerate_git_related_headers mkdir -p ${BUILD_OBJ_DIR} + ./scripts/prebuild_cyphal.sh cd ${BUILD_OBJ_DIR} && cmake ../.. && make dronecan: clean autogenerate_git_related_headers diff --git a/Src/cyphal_application/application.cpp b/Src/cyphal_application/application.cpp index 6086bf7..50a4323 100644 --- a/Src/cyphal_application/application.cpp +++ b/Src/cyphal_application/application.cpp @@ -8,7 +8,6 @@ #include "main.h" #include "string_params.hpp" #include "params.hpp" -#include "storage.h" void application_entry_point() { paramsInit(static_cast(IntParamsIndexes::INTEGER_PARAMS_AMOUNT), NUM_OF_STR_PARAMS); diff --git a/Src/cyphal_application/params.cpp b/Src/cyphal_application/params.cpp deleted file mode 100644 index 551dbbd..0000000 --- a/Src/cyphal_application/params.cpp +++ /dev/null @@ -1,18 +0,0 @@ -/// This software is distributed under the terms of the MIT License. -/// Copyright (c) 2022 Dmitry Ponomarev. -/// Author: Dmitry Ponomarev - -#include "params.hpp" -#include "string_params.hpp" -#include "storage.h" - -IntegerDesc_t integer_desc_pool[] = { - {(uint8_t*)"uavcan.node.id", 0, 127, 50}, -}; -IntegerParamValue_t integer_values_pool[sizeof(integer_desc_pool) / sizeof(IntegerDesc_t)]; - -StringDesc_t __attribute__((weak)) string_desc_pool[NUM_OF_STR_PARAMS] = { - {(uint8_t*)"system.name", "", false}, - {(uint8_t*)"uavcan.node.description", "", false}, -}; -StringParamValue_t string_values_pool[sizeof(string_desc_pool) / sizeof(StringDesc_t)]; diff --git a/Src/cyphal_application/params.hpp b/Src/cyphal_application/params.hpp deleted file mode 100644 index 1bb3a12..0000000 --- a/Src/cyphal_application/params.hpp +++ /dev/null @@ -1,16 +0,0 @@ -/// This software is distributed under the terms of the MIT License. -/// Copyright (c) 2022 Dmitry Ponomarev. -/// Author: Dmitry Ponomarev - -#ifndef PARAMS_HPP_ -#define PARAMS_HPP_ - -#include "storage.h" - -enum IntParamsIndexes : ParamIndex_t { - PARAM_NODE_ID, - - INTEGER_PARAMS_AMOUNT -}; - -#endif // PARAMS_HPP_ diff --git a/Src/cyphal_application/params.yaml b/Src/cyphal_application/params.yaml new file mode 100644 index 0000000..bc2fea3 --- /dev/null +++ b/Src/cyphal_application/params.yaml @@ -0,0 +1,17 @@ +example.integer: + type: Integer + enum: PARAM_EXAMPLE_INTEGER + flags: mutable + default: 42 + min: 0 + max: 255 + +example.string: + type: String + enum: PARAM_EXAMPLE_STRING + flags: mutable + default: "default_string_value" + +uavcan.pub.example : + data_type: reg.udral.service.actuator.common.Feedback.0.1 + enum_base: PWM_1_FB diff --git a/Src/cyphal_application/string_params.hpp b/Src/cyphal_application/string_params.hpp deleted file mode 100644 index d995c1e..0000000 --- a/Src/cyphal_application/string_params.hpp +++ /dev/null @@ -1,6 +0,0 @@ -/// This software is distributed under the terms of the MIT License. -/// Copyright (c) 2022 Dmitry Ponomarev. -/// Author: Dmitry Ponomarev - -#pragma once -#define NUM_OF_STR_PARAMS 2 diff --git a/Src/dronecan_application/params.cpp b/Src/dronecan_application/params.cpp index df1c5c7..2686769 100644 --- a/Src/dronecan_application/params.cpp +++ b/Src/dronecan_application/params.cpp @@ -7,11 +7,11 @@ #include "storage.h" IntegerDesc_t integer_desc_pool[] = { - {(uint8_t*)"id", 0, 127, 50}, + {"id", 0, 127, 50}, }; IntegerParamValue_t integer_values_pool[sizeof(integer_desc_pool) / sizeof(IntegerDesc_t)]; StringDesc_t __attribute__((weak)) string_desc_pool[NUM_OF_STR_PARAMS] = { - {(uint8_t*)"name", "", false}, + {"name", "", false}, }; StringParamValue_t string_values_pool[sizeof(string_desc_pool) / sizeof(StringDesc_t)]; diff --git a/scripts/prebuild_cyphal.sh b/scripts/prebuild_cyphal.sh new file mode 100755 index 0000000..a150b57 --- /dev/null +++ b/scripts/prebuild_cyphal.sh @@ -0,0 +1,10 @@ +#!/bin/bash +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) +REPOSITORY_PATH="$(dirname "$SCRIPT_DIR")" +BUILD_DIR=${REPOSITORY_PATH}/build/src/ + +${REPOSITORY_PATH}/Libs/libparams/scripts/params_generate_array_from_yaml.py \ + ${BUILD_DIR} \ + c++ \ + params \ + ${REPOSITORY_PATH}/Libs/Cyphal/Cyphal/params.yaml ${REPOSITORY_PATH}/Src/cyphal_application/params.yaml