mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-26 01:13:35 +08:00
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:
@@ -44,6 +44,8 @@
|
||||
#include "Roboclaw.hpp"
|
||||
#include <termios.h>
|
||||
|
||||
ModuleBase::Descriptor Roboclaw::desc{task_spawn, custom_command, print_usage};
|
||||
|
||||
Roboclaw::Roboclaw(const char *device_name, const char *bad_rate_parameter) :
|
||||
OutputModuleInterface(MODULE_NAME, px4::wq_configurations::hp_default)
|
||||
{
|
||||
@@ -170,7 +172,7 @@ void Roboclaw::Run()
|
||||
{
|
||||
if (should_exit()) {
|
||||
ScheduleClear();
|
||||
exit_and_cleanup();
|
||||
exit_and_cleanup(desc);
|
||||
_mixing_output.unregister();
|
||||
return;
|
||||
}
|
||||
@@ -476,8 +478,8 @@ int Roboclaw::task_spawn(int argc, char *argv[])
|
||||
Roboclaw *instance = new Roboclaw(device_name, baud_rate_parameter_value);
|
||||
|
||||
if (instance) {
|
||||
_object.store(instance);
|
||||
_task_id = task_id_is_work_queue;
|
||||
desc.object.store(instance);
|
||||
desc.task_id = task_id_is_work_queue;
|
||||
instance->ScheduleNow();
|
||||
return OK;
|
||||
|
||||
@@ -486,8 +488,8 @@ int Roboclaw::task_spawn(int argc, char *argv[])
|
||||
}
|
||||
|
||||
delete instance;
|
||||
_object.store(nullptr);
|
||||
_task_id = -1;
|
||||
desc.object.store(nullptr);
|
||||
desc.task_id = -1;
|
||||
|
||||
printf("Ending task_spawn");
|
||||
|
||||
@@ -535,5 +537,5 @@ int Roboclaw::print_status()
|
||||
|
||||
extern "C" __EXPORT int roboclaw_main(int argc, char *argv[])
|
||||
{
|
||||
return Roboclaw::main(argc, argv);
|
||||
return ModuleBase::main(Roboclaw::desc, argc, argv);
|
||||
}
|
||||
|
||||
@@ -54,9 +54,11 @@
|
||||
#include <uORB/Publication.hpp>
|
||||
#include <uORB/topics/wheel_encoders.h>
|
||||
|
||||
class Roboclaw : public ModuleBase<Roboclaw>, public OutputModuleInterface
|
||||
class Roboclaw : public ModuleBase, public OutputModuleInterface
|
||||
{
|
||||
public:
|
||||
static Descriptor desc;
|
||||
|
||||
/**
|
||||
* @param device_name Name of the serial port e.g. "/dev/ttyS2"
|
||||
* @param bad_rate_parameter Name of the parameter that holds the baud rate of this serial port
|
||||
|
||||
Reference in New Issue
Block a user