From a235bfd73d82009d4e40ffba778ef91d10f25c52 Mon Sep 17 00:00:00 2001 From: Eric Katzfey Date: Mon, 4 Mar 2024 13:58:24 -0800 Subject: [PATCH] Fixed non-voxl2 builds --- src/lib/parameters/CMakeLists.txt | 10 +++ src/lib/parameters/parameters.cpp | 81 +++++++++++++----------- src/lib/parameters/parameters_remote.cpp | 4 +- 3 files changed, 57 insertions(+), 38 deletions(-) diff --git a/src/lib/parameters/CMakeLists.txt b/src/lib/parameters/CMakeLists.txt index ed032fca3bde..b87e652cad4f 100644 --- a/src/lib/parameters/CMakeLists.txt +++ b/src/lib/parameters/CMakeLists.txt @@ -160,9 +160,19 @@ list(APPEND SRCS parameters.cpp atomic_transaction.cpp autosave.cpp +) + +if(CONFIG_PARAM_PRIMARY) +list(APPEND SRCS parameters_primary.cpp +) +endif() + +if(CONFIG_PARAM_REMOTE) +list(APPEND SRCS parameters_remote.cpp ) +endif() if(BUILD_TESTING) list(APPEND SRCS param_translation_unit_tests.cpp) diff --git a/src/lib/parameters/parameters.cpp b/src/lib/parameters/parameters.cpp index 1baf6adbafae..12515ca31a18 100644 --- a/src/lib/parameters/parameters.cpp +++ b/src/lib/parameters/parameters.cpp @@ -447,19 +447,23 @@ param_set_internal(param_t param, const void *val, bool mark_saved, bool notify_ } // If this is the parameter server, make sure that the remote is updated - if ((remote_active) && (is_primary)) { - if (param_changed && update_remote) { - param_primary_set_value(param, val); - } +#if defined(CONFIG_PARAM_PRIMARY) + + if (param_changed && update_remote) { + param_primary_set_value(param, val); } +#endif + // If this is the parameter remote, make sure that the primary is updated - if ((remote_active) && (is_remote)) { - if (param_changed && update_remote) { - param_remote_set_value(param, val); - } +#if defined(CONFIG_PARAM_REMOTE) + + if (param_changed && update_remote) { + param_remote_set_value(param, val); } +#endif + perf_end(param_set_perf); /* @@ -512,10 +516,14 @@ bool param_used(param_t param) void param_set_used(param_t param) { if (handle_in_range(param)) { - if ((remote_active) && (is_remote) && (! param_used(param))) { +#if defined(CONFIG_PARAM_REMOTE) + + if (! param_used(param)) { param_remote_set_used(param); } +#endif + params_active.set(param, true); } } @@ -611,9 +619,9 @@ static int param_reset_internal(param_t param, bool notify = true, bool autosave param_notify_changes(); } - if ((remote_active) && (is_primary)) { - param_primary_reset(param); - } +#if defined(CONFIG_PARAM_PRIMARY) + param_primary_reset(param); +#endif return param_found; } @@ -637,9 +645,9 @@ param_reset_all_internal(bool auto_save) param_autosave(); } - if ((remote_active) && (is_primary)) { - param_primary_reset_all(); - } +#if defined(CONFIG_PARAM_PRIMARY) + param_primary_reset_all(); +#endif param_notify_changes(); } @@ -1347,27 +1355,26 @@ void param_print_status() perf_print_counter(param_get_perf); perf_print_counter(param_set_perf); - if (remote_active) { - if (is_primary) { - struct param_primary_counters counts; - param_primary_get_counters(&counts); - PX4_INFO("set value requests received: %u, set value responses sent: %u", - counts.set_value_request_received, counts.set_value_response_sent); - PX4_INFO("set value requests sent: %u, set value responses received: %u", - counts.set_value_request_sent, counts.set_value_response_received); - PX4_INFO("resets sent: %u, set used requests received: %u", - counts.reset_sent, counts.set_used_received); - } +#if defined(CONFIG_PARAM_PRIMARY) + struct param_primary_counters counts; + param_primary_get_counters(&counts); + PX4_INFO("set value requests received: %" PRIu32 ", set value responses sent: %" PRIu32, + counts.set_value_request_received, counts.set_value_response_sent); + PX4_INFO("set value requests sent: %" PRIu32 ", set value responses received: %" PRIu32, + counts.set_value_request_sent, counts.set_value_response_received); + PX4_INFO("resets sent: %" PRIu32 ", set used requests received: %" PRIu32, + counts.reset_sent, counts.set_used_received); +#endif + +#if defined(CONFIG_PARAM_REMOTE) + struct param_remote_counters counts; + param_remote_get_counters(&counts); + PX4_INFO("set value requests received: %" PRIu32 ", set value responses sent: %" PRIu32, + counts.set_value_request_received, counts.set_value_response_sent); + PX4_INFO("set value requests sent: %" PRIu32 ", set value responses received: %" PRIu32, + counts.set_value_request_sent, counts.set_value_response_received); + PX4_INFO("resets received: %" PRIu32 ", set used requests sent: %" PRIu32, + counts.reset_received, counts.set_used_sent); +#endif - if (is_remote) { - struct param_remote_counters counts; - param_remote_get_counters(&counts); - PX4_INFO("set value requests received: %u, set value responses sent: %u", - counts.set_value_request_received, counts.set_value_response_sent); - PX4_INFO("set value requests sent: %u, set value responses received: %u", - counts.set_value_request_sent, counts.set_value_response_received); - PX4_INFO("resets received: %u, set used requests sent: %u", - counts.reset_received, counts.set_used_sent); - } - } } diff --git a/src/lib/parameters/parameters_remote.cpp b/src/lib/parameters/parameters_remote.cpp index 7ca0937174c8..78b7ee153cf1 100644 --- a/src/lib/parameters/parameters_remote.cpp +++ b/src/lib/parameters/parameters_remote.cpp @@ -35,6 +35,8 @@ #include "uORB/uORBManager.hpp" +#include + #include #include @@ -214,7 +216,7 @@ void param_remote_set_value(param_t param, const void *val) req.int_value = *(int32_t *)val; if (debug) { - PX4_INFO("*** Setting %s to %d ***", param_name(req.parameter_index), req.int_value); + PX4_INFO("*** Setting %s to %" PRIi32 " ***", param_name(req.parameter_index), req.int_value); } break;