1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-03-01 18:29:16 +01:00

SanityCheck: Directly query the task monitor

This commit is contained in:
James Cotton 2012-10-27 13:43:41 -05:00
parent 07a08c327c
commit 11630b7f7e
3 changed files with 16 additions and 9 deletions

View File

@ -33,6 +33,7 @@
int32_t TaskMonitorInitialize(void); int32_t TaskMonitorInitialize(void);
int32_t TaskMonitorAdd(TaskInfoRunningElem task, xTaskHandle handle); int32_t TaskMonitorAdd(TaskInfoRunningElem task, xTaskHandle handle);
int32_t TaskMonitorRemove(TaskInfoRunningElem task); int32_t TaskMonitorRemove(TaskInfoRunningElem task);
bool TaskMonitorQueryRunning(TaskInfoRunningElem task);
void TaskMonitorUpdateAll(void); void TaskMonitorUpdateAll(void);
#endif // TASKMONITOR_H #endif // TASKMONITOR_H

View File

@ -27,9 +27,9 @@
*/ */
#include "openpilot.h" #include "openpilot.h"
#include "taskmonitor.h"
#include <pios_board_info.h> #include <pios_board_info.h>
#include "sanitycheck.h" #include "sanitycheck.h"
#include "taskinfo.h"
#include "manualcontrolsettings.h" #include "manualcontrolsettings.h"
#include "systemalarms.h" #include "systemalarms.h"
#include "systemsettings.h" #include "systemsettings.h"
@ -75,10 +75,6 @@ int32_t configuration_check()
multirotor = false; multirotor = false;
} }
// Get the running modules
uint8_t running[TASKINFO_RUNNING_NUMELEM];
TaskInfoRunningGet(running);
// For each available flight mode position sanity check the available // For each available flight mode position sanity check the available
// modes // modes
uint8_t num_modes; uint8_t num_modes;
@ -102,7 +98,7 @@ int32_t configuration_check()
status = (status == SYSTEMALARMS_ALARM_OK) ? check_stabilization_settings(3, multirotor) : status; status = (status == SYSTEMALARMS_ALARM_OK) ? check_stabilization_settings(3, multirotor) : status;
break; break;
case MANUALCONTROLSETTINGS_FLIGHTMODEPOSITION_AUTOTUNE: case MANUALCONTROLSETTINGS_FLIGHTMODEPOSITION_AUTOTUNE:
if (running[TASKINFO_RUNNING_AUTOTUNE] != TASKINFO_RUNNING_TRUE) if (!TaskMonitorQueryRunning(TASKINFO_RUNNING_AUTOTUNE))
status = SYSTEMALARMS_ALARM_ERROR; status = SYSTEMALARMS_ALARM_ERROR;
break; break;
case MANUALCONTROLSETTINGS_FLIGHTMODEPOSITION_ALTITUDEHOLD: case MANUALCONTROLSETTINGS_FLIGHTMODEPOSITION_ALTITUDEHOLD:
@ -110,7 +106,7 @@ int32_t configuration_check()
status = SYSTEMALARMS_ALARM_ERROR; status = SYSTEMALARMS_ALARM_ERROR;
else { else {
// Revo supports altitude hold // Revo supports altitude hold
if(running[TASKINFO_RUNNING_ALTITUDEHOLD] != TASKINFO_RUNNING_TRUE) if (!TaskMonitorQueryRunning(TASKINFO_RUNNING_ALTITUDEHOLD))
status = SYSTEMALARMS_ALARM_ERROR; status = SYSTEMALARMS_ALARM_ERROR;
} }
break; break;
@ -119,7 +115,7 @@ int32_t configuration_check()
status = SYSTEMALARMS_ALARM_ERROR; status = SYSTEMALARMS_ALARM_ERROR;
else { else {
// Revo supports altitude hold // Revo supports altitude hold
if(running[TASKINFO_RUNNING_GUIDANCE] != TASKINFO_RUNNING_TRUE) if (!TaskMonitorQueryRunning(TASKINFO_RUNNING_GUIDANCE))
status = SYSTEMALARMS_ALARM_ERROR; status = SYSTEMALARMS_ALARM_ERROR;
} }
break; break;
@ -128,7 +124,7 @@ int32_t configuration_check()
status = SYSTEMALARMS_ALARM_ERROR; status = SYSTEMALARMS_ALARM_ERROR;
else { else {
// Revo supports altitude hold // Revo supports altitude hold
if(running[TASKINFO_RUNNING_GUIDANCE] != TASKINFO_RUNNING_TRUE) if (!TaskMonitorQueryRunning(TASKINFO_RUNNING_GUIDANCE))
status = SYSTEMALARMS_ALARM_ERROR; status = SYSTEMALARMS_ALARM_ERROR;
} }
break; break;

View File

@ -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 * Update the status of all tasks
*/ */