module_base: remove CRTP template pattern to reduce flash bloat (#26476)

* module_base: claude rewrite to remove CRTP bloat

* module_base: apply to all drivers/modules

* format

* fix build errors

* fix missing syntax

* remove reference to module.h in files that need module_base.h

* remove old ModuleBase<T>

* add module_base.cpp to px4_protected_layers.cmake

* fix IridiumSBD can_stop()

* fix IridiumSBD.cpp

* clang-tidy: downcast static cast

* get_instance() template accessor, revert clang-tidy global

* rename module_base.h to module.h

* revert changes in zenoh/Kconfig.topics
This commit is contained in:
Jacob Dahl
2026-02-19 15:17:17 +13:00
committed by GitHub
parent 657854ae1b
commit ce3e62841f
227 changed files with 1741 additions and 1496 deletions
+15 -6
View File
@@ -67,6 +67,8 @@ using namespace device;
namespace septentrio
{
ModuleBase::Descriptor SeptentrioDriver::desc{task_spawn, custom_command, print_usage};
/**
* RTC drift time when time synchronization is needed (in seconds).
*/
@@ -347,6 +349,13 @@ void SeptentrioDriver::run()
}
int SeptentrioDriver::run_trampoline(int argc, char *argv[])
{
return ModuleBase::run_trampoline_impl(desc, [](int ac, char *av[]) -> ModuleBase * {
return SeptentrioDriver::instantiate(ac, av);
}, argc, argv);
}
int SeptentrioDriver::task_spawn(int argc, char *argv[])
{
return task_spawn(argc, argv, Instance::Main);
@@ -372,14 +381,14 @@ int SeptentrioDriver::task_spawn(int argc, char *argv[], Instance instance)
(char *const *)argv);
if (task_id < 0) {
// `_task_id` of module that hasn't been started before or has been stopped should already be -1.
// `desc.task_id` of module that hasn't been started before or has been stopped should already be -1.
// This is just to make sure.
_task_id = -1;
desc.task_id = -1;
return -errno;
}
if (instance == Instance::Main) {
_task_id = task_id;
desc.task_id = task_id;
}
return 0;
@@ -489,12 +498,12 @@ int SeptentrioDriver::custom_command(int argc, char *argv[])
const char *failure_reason {"unknown command"};
SeptentrioDriver *driver_instance;
if (!is_running()) {
if (!is_running(desc)) {
PX4_INFO("not running");
return -1;
}
driver_instance = get_instance();
driver_instance = get_instance<SeptentrioDriver>(desc);
if (argc >= 1 && strcmp(argv[0], "reset") == 0) {
if (argc == 2) {
@@ -1861,5 +1870,5 @@ uint32_t SeptentrioDriver::get_parameter(const char *name, float *value)
extern "C" __EXPORT int septentrio_main(int argc, char *argv[])
{
return septentrio::SeptentrioDriver::main(argc, argv);
return ModuleBase::main(septentrio::SeptentrioDriver::desc, argc, argv);
}
+6 -1
View File
@@ -227,9 +227,11 @@ enum class ReceiverOutputTracker {
PositioningMessages = DOP + PVTGeodetic + VelCovGeodetic + AttEuler + AttCovEuler,
};
class SeptentrioDriver : public ModuleBase<SeptentrioDriver>, public device::Device
class SeptentrioDriver : public ModuleBase, public device::Device
{
public:
static Descriptor desc;
SeptentrioDriver(const char *device_path, Instance instance, uint32_t baud_rate);
~SeptentrioDriver() override;
@@ -244,6 +246,9 @@ public:
static int task_spawn(int argc, char *argv[], Instance instance);
/** @see ModuleBase */
static int run_trampoline(int argc, char *argv[]);
/**
* @brief Secondary run trampoline to support two driver instances.
*/