diff --git a/boards/nxp/mr-tropic/nuttx-config/scripts/itcm_functions_includes.ld b/boards/nxp/mr-tropic/nuttx-config/scripts/itcm_functions_includes.ld index d819a3f544f..dfca0c6988b 100644 --- a/boards/nxp/mr-tropic/nuttx-config/scripts/itcm_functions_includes.ld +++ b/boards/nxp/mr-tropic/nuttx-config/scripts/itcm_functions_includes.ld @@ -625,7 +625,6 @@ *(.text._ZN36do_not_explicitly_use_this_namespace5ParamIfLN3px46paramsE919EEC1Ev) /* itcm-check-ignore */ *(.text._ZN22MavlinkStreamHeartbeat8get_sizeEv) *(.text._ZN6matrix6MatrixIfLj3ELj1EEdVEf) -*(.text._ZN17FlightTaskDescendC1Ev) *(.text._ZN26MavlinkStreamCameraTrigger8get_sizeEv) *(.text.iob_navail) *(.text._ZN12FailsafeBase25removeNonActivatedActionsEv) diff --git a/boards/nxp/tropic-community/nuttx-config/scripts/itcm_functions_includes.ld b/boards/nxp/tropic-community/nuttx-config/scripts/itcm_functions_includes.ld index d819a3f544f..dfca0c6988b 100644 --- a/boards/nxp/tropic-community/nuttx-config/scripts/itcm_functions_includes.ld +++ b/boards/nxp/tropic-community/nuttx-config/scripts/itcm_functions_includes.ld @@ -625,7 +625,6 @@ *(.text._ZN36do_not_explicitly_use_this_namespace5ParamIfLN3px46paramsE919EEC1Ev) /* itcm-check-ignore */ *(.text._ZN22MavlinkStreamHeartbeat8get_sizeEv) *(.text._ZN6matrix6MatrixIfLj3ELj1EEdVEf) -*(.text._ZN17FlightTaskDescendC1Ev) *(.text._ZN26MavlinkStreamCameraTrigger8get_sizeEv) *(.text.iob_navail) *(.text._ZN12FailsafeBase25removeNonActivatedActionsEv) diff --git a/boards/px4/fmu-v6xrt/nuttx-config/scripts/itcm_functions_includes.ld b/boards/px4/fmu-v6xrt/nuttx-config/scripts/itcm_functions_includes.ld index 03a78a4b72c..c9f5fe63516 100644 --- a/boards/px4/fmu-v6xrt/nuttx-config/scripts/itcm_functions_includes.ld +++ b/boards/px4/fmu-v6xrt/nuttx-config/scripts/itcm_functions_includes.ld @@ -639,7 +639,6 @@ *(.text._ZN36do_not_explicitly_use_this_namespace5ParamIfLN3px46paramsE919EEC1Ev) /* itcm-check-ignore */ *(.text._ZN22MavlinkStreamHeartbeat8get_sizeEv) *(.text._ZN6matrix6MatrixIfLj3ELj1EEdVEf) -*(.text._ZN17FlightTaskDescendC1Ev) *(.text._ZN26MavlinkStreamCameraTrigger8get_sizeEv) *(.text.iob_navail) *(.text._ZN12FailsafeBase25removeNonActivatedActionsEv) diff --git a/platforms/common/CMakeLists.txt b/platforms/common/CMakeLists.txt index cb0721fe691..97b6754bfe8 100644 --- a/platforms/common/CMakeLists.txt +++ b/platforms/common/CMakeLists.txt @@ -47,6 +47,7 @@ add_library(px4_platform STATIC i2c.cpp i2c_spi_buses.cpp module.cpp + module_params.cpp px4_getopt.c px4_cli.cpp shutdown.cpp diff --git a/platforms/common/include/px4_platform_common/module_params.h b/platforms/common/include/px4_platform_common/module_params.h index 2949053c995..7d954e09087 100644 --- a/platforms/common/include/px4_platform_common/module_params.h +++ b/platforms/common/include/px4_platform_common/module_params.h @@ -56,19 +56,9 @@ public: * @brief Sets the parent module. This is typically not required, * only in cases where the parent cannot be set via constructor. */ - void setParent(ModuleParams *parent) - { - if (parent) { - parent->_children.add(this); - } + void setParent(ModuleParams *parent); - _parent = parent; - } - - virtual ~ModuleParams() - { - if (_parent) { _parent->_children.remove(this); } - } + virtual ~ModuleParams(); // Disallow copy construction and move assignment. ModuleParams(const ModuleParams &) = delete; diff --git a/platforms/common/module_params.cpp b/platforms/common/module_params.cpp new file mode 100644 index 00000000000..1ae4e4cafc2 --- /dev/null +++ b/platforms/common/module_params.cpp @@ -0,0 +1,48 @@ +/**************************************************************************** + * + * Copyright (c) 2026 PX4 Development Team. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name PX4 nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +#include + +void ModuleParams::setParent(ModuleParams *parent) +{ + if (parent) { + parent->_children.add(this); + } + + _parent = parent; +} + +ModuleParams::~ModuleParams() +{ + if (_parent) { _parent->_children.remove(this); } +} diff --git a/src/modules/commander/HealthAndArmingChecks/CMakeLists.txt b/src/modules/commander/HealthAndArmingChecks/CMakeLists.txt index a7f3b6afcd8..893a58b812f 100644 --- a/src/modules/commander/HealthAndArmingChecks/CMakeLists.txt +++ b/src/modules/commander/HealthAndArmingChecks/CMakeLists.txt @@ -83,7 +83,7 @@ px4_add_library(health_and_arming_checks ${health_and_arming_checks_srcs}) set_property(GLOBAL APPEND PROPERTY PX4_MODULE_CONFIG_FILES ${CMAKE_CURRENT_SOURCE_DIR}/esc_check_params.yaml) add_dependencies(health_and_arming_checks mode_util) -target_link_libraries(health_and_arming_checks PRIVATE geo hysteresis) +target_link_libraries(health_and_arming_checks PRIVATE geo hysteresis px4_platform) px4_add_functional_gtest(SRC HealthAndArmingChecksTest.cpp LINKLIBS health_and_arming_checks mode_util diff --git a/src/modules/commander/failsafe/CMakeLists.txt b/src/modules/commander/failsafe/CMakeLists.txt index 0d7b3bd366c..f792cdb29a7 100644 --- a/src/modules/commander/failsafe/CMakeLists.txt +++ b/src/modules/commander/failsafe/CMakeLists.txt @@ -53,6 +53,7 @@ add_executable(failsafe_test EXCLUDE_FROM_ALL emscripten.cpp failsafe.cpp framework.cpp + ${PX4_SOURCE_DIR}/platforms/common/module_params.cpp ) set_property(TARGET failsafe_test PROPERTY UNITY_BUILD ON) # avoids some method calls to e.g. param_name or param_type set_property(TARGET failsafe_test PROPERTY LINK_DEPENDS ${html_output_file})