From 11630b7f7e4b33ff1545c2235f8a6c9a2f91cf2f Mon Sep 17 00:00:00 2001 From: James Cotton Date: Sat, 27 Oct 2012 13:43:41 -0500 Subject: [PATCH] SanityCheck: Directly query the task monitor --- flight/Libraries/inc/taskmonitor.h | 1 + flight/Libraries/sanitycheck.c | 14 +++++--------- flight/Libraries/taskmonitor.c | 10 ++++++++++ 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/flight/Libraries/inc/taskmonitor.h b/flight/Libraries/inc/taskmonitor.h index 112598f1b..6492cee06 100644 --- a/flight/Libraries/inc/taskmonitor.h +++ b/flight/Libraries/inc/taskmonitor.h @@ -33,6 +33,7 @@ int32_t TaskMonitorInitialize(void); int32_t TaskMonitorAdd(TaskInfoRunningElem task, xTaskHandle handle); int32_t TaskMonitorRemove(TaskInfoRunningElem task); +bool TaskMonitorQueryRunning(TaskInfoRunningElem task); void TaskMonitorUpdateAll(void); #endif // TASKMONITOR_H diff --git a/flight/Libraries/sanitycheck.c b/flight/Libraries/sanitycheck.c index 50120343e..d94d94cb2 100644 --- a/flight/Libraries/sanitycheck.c +++ b/flight/Libraries/sanitycheck.c @@ -27,9 +27,9 @@ */ #include "openpilot.h" +#include "taskmonitor.h" #include #include "sanitycheck.h" -#include "taskinfo.h" #include "manualcontrolsettings.h" #include "systemalarms.h" #include "systemsettings.h" @@ -75,10 +75,6 @@ int32_t configuration_check() multirotor = false; } - // Get the running modules - uint8_t running[TASKINFO_RUNNING_NUMELEM]; - TaskInfoRunningGet(running); - // For each available flight mode position sanity check the available // modes uint8_t num_modes; @@ -102,7 +98,7 @@ int32_t configuration_check() status = (status == SYSTEMALARMS_ALARM_OK) ? check_stabilization_settings(3, multirotor) : status; break; case MANUALCONTROLSETTINGS_FLIGHTMODEPOSITION_AUTOTUNE: - if (running[TASKINFO_RUNNING_AUTOTUNE] != TASKINFO_RUNNING_TRUE) + if (!TaskMonitorQueryRunning(TASKINFO_RUNNING_AUTOTUNE)) status = SYSTEMALARMS_ALARM_ERROR; break; case MANUALCONTROLSETTINGS_FLIGHTMODEPOSITION_ALTITUDEHOLD: @@ -110,7 +106,7 @@ int32_t configuration_check() status = SYSTEMALARMS_ALARM_ERROR; else { // Revo supports altitude hold - if(running[TASKINFO_RUNNING_ALTITUDEHOLD] != TASKINFO_RUNNING_TRUE) + if (!TaskMonitorQueryRunning(TASKINFO_RUNNING_ALTITUDEHOLD)) status = SYSTEMALARMS_ALARM_ERROR; } break; @@ -119,7 +115,7 @@ int32_t configuration_check() status = SYSTEMALARMS_ALARM_ERROR; else { // Revo supports altitude hold - if(running[TASKINFO_RUNNING_GUIDANCE] != TASKINFO_RUNNING_TRUE) + if (!TaskMonitorQueryRunning(TASKINFO_RUNNING_GUIDANCE)) status = SYSTEMALARMS_ALARM_ERROR; } break; @@ -128,7 +124,7 @@ int32_t configuration_check() status = SYSTEMALARMS_ALARM_ERROR; else { // Revo supports altitude hold - if(running[TASKINFO_RUNNING_GUIDANCE] != TASKINFO_RUNNING_TRUE) + if (!TaskMonitorQueryRunning(TASKINFO_RUNNING_GUIDANCE)) status = SYSTEMALARMS_ALARM_ERROR; } break; diff --git a/flight/Libraries/taskmonitor.c b/flight/Libraries/taskmonitor.c index 0ea4cbf52..6fc1c4dc3 100644 --- a/flight/Libraries/taskmonitor.c +++ b/flight/Libraries/taskmonitor.c @@ -89,6 +89,16 @@ int32_t TaskMonitorRemove(TaskInfoRunningElem task) } } +/** + * Query if a task is running + */ +bool TaskMonitorQueryRunning(TaskInfoRunningElem task) +{ + if (task < TASKINFO_RUNNING_NUMELEM && handles[task] != 0) + return true; + return false; +} + /** * Update the status of all tasks */