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:
parent
0575b45378
commit
b05697c2cf
@ -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
|
* Update the status of all tasks
|
||||||
*/
|
*/
|
||||||
@ -79,10 +97,10 @@ void TaskMonitorUpdateAll(void)
|
|||||||
#if defined(DIAG_TASKS)
|
#if defined(DIAG_TASKS)
|
||||||
TaskInfoData data;
|
TaskInfoData data;
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
// Lock
|
// Lock
|
||||||
xSemaphoreTakeRecursive(lock, portMAX_DELAY);
|
xSemaphoreTakeRecursive(lock, portMAX_DELAY);
|
||||||
|
|
||||||
#if ( configGENERATE_RUN_TIME_STATS == 1 )
|
#if ( configGENERATE_RUN_TIME_STATS == 1 )
|
||||||
uint32_t currentTime;
|
uint32_t currentTime;
|
||||||
uint32_t deltaTime;
|
uint32_t deltaTime;
|
||||||
@ -121,10 +139,10 @@ void TaskMonitorUpdateAll(void)
|
|||||||
data.RunningTime[n] = 0;
|
data.RunningTime[n] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update object
|
// Update object
|
||||||
TaskInfoSet(&data);
|
TaskInfoSet(&data);
|
||||||
|
|
||||||
// Done
|
// Done
|
||||||
xSemaphoreGiveRecursive(lock);
|
xSemaphoreGiveRecursive(lock);
|
||||||
#endif
|
#endif
|
||||||
|
@ -170,8 +170,11 @@ static void systemTask(void *parameters)
|
|||||||
updateI2Cstats();
|
updateI2Cstats();
|
||||||
updateWDGstats();
|
updateWDGstats();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(DIAG_TASKS)
|
||||||
// Update the task status object
|
// Update the task status object
|
||||||
TaskMonitorUpdateAll();
|
TaskMonitorUpdateAll();
|
||||||
|
#endif
|
||||||
|
|
||||||
// Flash the heartbeat LED
|
// Flash the heartbeat LED
|
||||||
PIOS_LED_Toggle(LED1);
|
PIOS_LED_Toggle(LED1);
|
||||||
|
@ -47,7 +47,7 @@ int32_t TaskMonitorInitialize(void)
|
|||||||
lock = xSemaphoreCreateRecursiveMutex();
|
lock = xSemaphoreCreateRecursiveMutex();
|
||||||
memset(handles, 0, sizeof(xTaskHandle)*TASKINFO_RUNNING_NUMELEM);
|
memset(handles, 0, sizeof(xTaskHandle)*TASKINFO_RUNNING_NUMELEM);
|
||||||
lastMonitorTime = 0;
|
lastMonitorTime = 0;
|
||||||
#if defined(DIAGNOSTICS)
|
#if defined(DIAG_TASKS)
|
||||||
lastMonitorTime = portGET_RUN_TIME_COUNTER_VALUE();
|
lastMonitorTime = portGET_RUN_TIME_COUNTER_VALUE();
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
@ -94,7 +94,7 @@ int32_t TaskMonitorRemove(TaskInfoRunningElem task)
|
|||||||
*/
|
*/
|
||||||
void TaskMonitorUpdateAll(void)
|
void TaskMonitorUpdateAll(void)
|
||||||
{
|
{
|
||||||
#if defined(DIAGNOSTICS)
|
#if defined(DIAG_TASKS)
|
||||||
TaskInfoData data;
|
TaskInfoData data;
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
@ -128,7 +128,6 @@ void TaskMonitorUpdateAll(void)
|
|||||||
#if ( configGENERATE_RUN_TIME_STATS == 1 )
|
#if ( configGENERATE_RUN_TIME_STATS == 1 )
|
||||||
/* Generate run time stats */
|
/* Generate run time stats */
|
||||||
data.RunningTime[n] = uxTaskGetRunTime(handles[n]) / deltaTime;
|
data.RunningTime[n] = uxTaskGetRunTime(handles[n]) / deltaTime;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user