From daa302cdbe20ee03fc7cc5390778683aa8c18813 Mon Sep 17 00:00:00 2001 From: Eric Katzfey <53063038+katzfey@users.noreply.github.com> Date: Mon, 6 Mar 2023 06:49:07 -0800 Subject: [PATCH] Changes to allow the commander module to be built and run on Qurt (#21186) * Changed exclusion to rely on the definition of PX4_STORAGEDIR --- boards/modalai/voxl2-slpi/default.px4board | 1 + platforms/common/include/px4_platform_common/defines.h | 3 +++ platforms/qurt/src/px4/tasks.cpp | 7 ++++--- src/drivers/qshell/qurt/qshell.cpp | 2 +- src/modules/commander/Commander.hpp | 6 ++++-- src/modules/commander/HealthAndArmingChecks/Common.hpp | 1 + .../HealthAndArmingChecks/HealthAndArmingChecks.hpp | 1 - .../commander/HealthAndArmingChecks/checks/sdcardCheck.cpp | 5 ++++- .../commander/HealthAndArmingChecks/checks/sdcardCheck.hpp | 6 ++++-- 9 files changed, 22 insertions(+), 10 deletions(-) diff --git a/boards/modalai/voxl2-slpi/default.px4board b/boards/modalai/voxl2-slpi/default.px4board index 21ebfa008f..d0c482a585 100644 --- a/boards/modalai/voxl2-slpi/default.px4board +++ b/boards/modalai/voxl2-slpi/default.px4board @@ -12,6 +12,7 @@ CONFIG_MODULES_MC_POS_CONTROL=y CONFIG_MODULES_MC_RATE_CONTROL=y CONFIG_MODULES_MUORB_SLPI=y CONFIG_MODULES_SENSORS=y +CONFIG_MODULES_COMMANDER=y CONFIG_SYSTEMCMDS_PARAM=y CONFIG_SYSTEMCMDS_UORB=y CONFIG_ORB_COMMUNICATOR=y diff --git a/platforms/common/include/px4_platform_common/defines.h b/platforms/common/include/px4_platform_common/defines.h index c0aad3e869..38d7b4201f 100644 --- a/platforms/common/include/px4_platform_common/defines.h +++ b/platforms/common/include/px4_platform_common/defines.h @@ -99,7 +99,10 @@ __END_DECLS #define PX4_ROOTFSDIR CONFIG_BOARD_ROOTFSDIR +// Qurt doesn't have an SD card for storage +#ifndef __PX4_QURT #define PX4_STORAGEDIR PX4_ROOTFSDIR +#endif /**************************************************************************** * Defines for POSIX and ROS diff --git a/platforms/qurt/src/px4/tasks.cpp b/platforms/qurt/src/px4/tasks.cpp index ef545f8b5c..13bac3f711 100644 --- a/platforms/qurt/src/px4/tasks.cpp +++ b/platforms/qurt/src/px4/tasks.cpp @@ -166,11 +166,12 @@ static px4_task_t px4_task_spawn_internal(const char *name, int priority, px4_ma return -1; } else { - //px4_clock_gettimemap[task_index].argv_storage[i], argv[i]); + strcpy(taskmap[task_index].argv_storage[i], argv[i]); taskmap[task_index].argv[i] = taskmap[task_index].argv_storage[i]; } } else { + // Must add NULL at end of argv taskmap[task_index].argv[i] = nullptr; break; } @@ -420,13 +421,13 @@ int px4_sem_timedwait(px4_sem_t *sem, const struct timespec *ts) return 0; } -int px4_prctl(int option, const char *arg2, pthread_t pid) +int px4_prctl(int option, const char *arg2, px4_task_t pid) { int rv = -1; pthread_mutex_lock(&task_mutex); for (int i = 0; i < PX4_MAX_TASKS; i++) { - if (taskmap[i].isused && taskmap[i].tid == pid) { + if (taskmap[i].isused && taskmap[i].tid == (pthread_t) pid) { rv = pthread_attr_setthreadname(&taskmap[i].attr, arg2); return rv; } diff --git a/src/drivers/qshell/qurt/qshell.cpp b/src/drivers/qshell/qurt/qshell.cpp index fafe04136d..7c5d795ba8 100644 --- a/src/drivers/qshell/qurt/qshell.cpp +++ b/src/drivers/qshell/qurt/qshell.cpp @@ -50,7 +50,7 @@ #include #include -#define MAX_ARGS 8 // max number of whitespace separated args after app name +#define MAX_ARGS 16 // max number of whitespace separated args after app name px4::AppState QShell::appState; diff --git a/src/modules/commander/Commander.hpp b/src/modules/commander/Commander.hpp index 0ea42d1832..3678b9ea9d 100644 --- a/src/modules/commander/Commander.hpp +++ b/src/modules/commander/Commander.hpp @@ -231,8 +231,10 @@ private: hrt_abstime _last_disarmed_timestamp{0}; hrt_abstime _overload_start{0}; ///< time when CPU overload started - hrt_abstime _led_armed_state_toggle{0}; - hrt_abstime _led_overload_toggle{0}; +#if !defined(CONFIG_ARCH_LEDS) && defined(BOARD_HAS_CONTROL_STATUS_LEDS) + hrt_abstime _led_armed_state_toggle {0}; +#endif + hrt_abstime _led_overload_toggle {0}; hrt_abstime _last_health_and_arming_check{0}; diff --git a/src/modules/commander/HealthAndArmingChecks/Common.hpp b/src/modules/commander/HealthAndArmingChecks/Common.hpp index 91197170b9..3767dc15f0 100644 --- a/src/modules/commander/HealthAndArmingChecks/Common.hpp +++ b/src/modules/commander/HealthAndArmingChecks/Common.hpp @@ -40,6 +40,7 @@ #include #include #include +#include #include #include diff --git a/src/modules/commander/HealthAndArmingChecks/HealthAndArmingChecks.hpp b/src/modules/commander/HealthAndArmingChecks/HealthAndArmingChecks.hpp index d12aa585ca..c094c65ebb 100644 --- a/src/modules/commander/HealthAndArmingChecks/HealthAndArmingChecks.hpp +++ b/src/modules/commander/HealthAndArmingChecks/HealthAndArmingChecks.hpp @@ -68,7 +68,6 @@ #include "checks/vtolCheck.hpp" #include "checks/offboardCheck.hpp" - class HealthAndArmingChecks : public ModuleParams { public: diff --git a/src/modules/commander/HealthAndArmingChecks/checks/sdcardCheck.cpp b/src/modules/commander/HealthAndArmingChecks/checks/sdcardCheck.cpp index 8be0c6961b..1136c3f282 100644 --- a/src/modules/commander/HealthAndArmingChecks/checks/sdcardCheck.cpp +++ b/src/modules/commander/HealthAndArmingChecks/checks/sdcardCheck.cpp @@ -38,12 +38,14 @@ #ifdef __PX4_DARWIN #include #include -#else +#elif defined(PX4_STORAGEDIR) #include #endif void SdCardChecks::checkAndReport(const Context &context, Report &reporter) { +#ifdef PX4_STORAGEDIR + if (_param_com_arm_sdcard.get() > 0) { struct statfs statfs_buf; @@ -125,4 +127,5 @@ void SdCardChecks::checkAndReport(const Context &context, Report &reporter) } #endif /* __PX4_NUTTX */ +#endif /* PX4_STORAGEDIR */ } diff --git a/src/modules/commander/HealthAndArmingChecks/checks/sdcardCheck.hpp b/src/modules/commander/HealthAndArmingChecks/checks/sdcardCheck.hpp index 5f46a6ff38..da02ee8292 100644 --- a/src/modules/commander/HealthAndArmingChecks/checks/sdcardCheck.hpp +++ b/src/modules/commander/HealthAndArmingChecks/checks/sdcardCheck.hpp @@ -44,11 +44,13 @@ public: void checkAndReport(const Context &context, Report &reporter) override; private: - bool _sdcard_detected{false}; +#ifdef PX4_STORAGEDIR + bool _sdcard_detected {false}; #ifdef __PX4_NUTTX bool _hardfault_checked_once {false}; - bool _hardfault_file_present{false}; + bool _hardfault_file_present {false}; +#endif #endif DEFINE_PARAMETERS_CUSTOM_PARENT(HealthAndArmingCheckBase,