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

taskinfo: ensure usage of TaskInfo uavo is covered by DIAG_TASKS

OpenPilot platform (and thus sim too) was missed when the
DIAG_TASKS macro was broken out from the DIAGNOSTICS macro.

This allowed accesses to the TaskInfo UAVO even though it hadn't
been initialized.
This commit is contained in:
Stacey Sheldon 2012-01-15 18:02:38 -05:00
parent 0575b45378
commit b05697c2cf
3 changed files with 27 additions and 7 deletions

View File

@ -71,6 +71,24 @@ int32_t TaskMonitorAdd(TaskInfoRunningElem task, xTaskHandle handle)
}
}
/**
* Remove a task handle from the library
*/
int32_t TaskMonitorRemove(TaskInfoRunningElem task)
{
if (task < TASKINFO_RUNNING_NUMELEM)
{
xSemaphoreTakeRecursive(lock, portMAX_DELAY);
handles[task] = 0;
xSemaphoreGiveRecursive(lock);
return 0;
}
else
{
return -1;
}
}
/**
* Update the status of all tasks
*/
@ -79,10 +97,10 @@ void TaskMonitorUpdateAll(void)
#if defined(DIAG_TASKS)
TaskInfoData data;
int n;
// Lock
xSemaphoreTakeRecursive(lock, portMAX_DELAY);
#if ( configGENERATE_RUN_TIME_STATS == 1 )
uint32_t currentTime;
uint32_t deltaTime;
@ -121,10 +139,10 @@ void TaskMonitorUpdateAll(void)
data.RunningTime[n] = 0;
}
}
// Update object
TaskInfoSet(&data);
// Done
xSemaphoreGiveRecursive(lock);
#endif

View File

@ -170,8 +170,11 @@ static void systemTask(void *parameters)
updateI2Cstats();
updateWDGstats();
#endif
#if defined(DIAG_TASKS)
// Update the task status object
TaskMonitorUpdateAll();
#endif
// Flash the heartbeat LED
PIOS_LED_Toggle(LED1);

View File

@ -47,7 +47,7 @@ int32_t TaskMonitorInitialize(void)
lock = xSemaphoreCreateRecursiveMutex();
memset(handles, 0, sizeof(xTaskHandle)*TASKINFO_RUNNING_NUMELEM);
lastMonitorTime = 0;
#if defined(DIAGNOSTICS)
#if defined(DIAG_TASKS)
lastMonitorTime = portGET_RUN_TIME_COUNTER_VALUE();
#endif
return 0;
@ -94,7 +94,7 @@ int32_t TaskMonitorRemove(TaskInfoRunningElem task)
*/
void TaskMonitorUpdateAll(void)
{
#if defined(DIAGNOSTICS)
#if defined(DIAG_TASKS)
TaskInfoData data;
int n;
@ -128,7 +128,6 @@ void TaskMonitorUpdateAll(void)
#if ( configGENERATE_RUN_TIME_STATS == 1 )
/* Generate run time stats */
data.RunningTime[n] = uxTaskGetRunTime(handles[n]) / deltaTime;
#endif
#endif