From 42b070d8ab60ea7f0d885f7a49e31d15420433e1 Mon Sep 17 00:00:00 2001 From: Jacob Hageman Date: Wed, 25 May 2022 09:57:46 -0600 Subject: [PATCH] Fix #21, Add idle task while loop back in --- fsw/src/hs_custom.c | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/fsw/src/hs_custom.c b/fsw/src/hs_custom.c index 57e83d0..0cc6614 100644 --- a/fsw/src/hs_custom.c +++ b/fsw/src/hs_custom.c @@ -52,28 +52,30 @@ void HS_IdleTask(void) { OS_time_t PSPTime = {0}; - HS_CustomData.IdleTaskRunStatus = CFE_SUCCESS; - - /* Check to see if we are to mark the time. */ - if (((HS_CustomData.ThisIdleTaskExec & HS_CustomData.UtilMask) == HS_CustomData.UtilMask) && - (HS_CustomData.ThisIdleTaskExec > HS_CustomData.UtilMask)) + while (HS_CustomData.IdleTaskRunStatus == CFE_SUCCESS) { - /* Entry and Exit markers are for easy time marking only; not performance */ - CFE_ES_PerfLogEntry(HS_IDLETASK_PERF_ID); - /* Increment the child task Execution Counter */ - CFE_ES_IncrementTaskCounter(); + /* Check to see if we are to mark the time. */ + if (((HS_CustomData.ThisIdleTaskExec & HS_CustomData.UtilMask) == HS_CustomData.UtilMask) && + (HS_CustomData.ThisIdleTaskExec > HS_CustomData.UtilMask)) + { + /* Entry and Exit markers are for easy time marking only; not performance */ + CFE_ES_PerfLogEntry(HS_IDLETASK_PERF_ID); - /* update stamp and array */ - CFE_PSP_GetTime(&PSPTime); - HS_CustomData.UtilArray[HS_CustomData.UtilArrayIndex & HS_CustomData.UtilArrayMask] = (uint32)PSPTime.ticks; - HS_CustomData.UtilArrayIndex++; + /* Increment the child task Execution Counter */ + CFE_ES_IncrementTaskCounter(); - CFE_ES_PerfLogExit(HS_IDLETASK_PERF_ID); - } + /* update stamp and array */ + CFE_PSP_GetTime(&PSPTime); + HS_CustomData.UtilArray[HS_CustomData.UtilArrayIndex & HS_CustomData.UtilArrayMask] = (uint32)PSPTime.ticks; + HS_CustomData.UtilArrayIndex++; - /* Call the Utilization Tracking function */ - HS_UtilizationIncrement(); + CFE_ES_PerfLogExit(HS_IDLETASK_PERF_ID); + } + + /* Call the Utilization Tracking function */ + HS_UtilizationIncrement(); + } return; @@ -92,11 +94,14 @@ int32 HS_CustomInit(void) /* ** Spawn the Idle Task */ + HS_CustomData.IdleTaskRunStatus = CFE_SUCCESS; + Status = CFE_ES_CreateChildTask(&HS_CustomData.IdleTaskID, HS_IDLE_TASK_NAME, HS_IdleTask, HS_IDLE_TASK_STACK_PTR, HS_IDLE_TASK_STACK_SIZE, HS_IDLE_TASK_PRIORITY, HS_IDLE_TASK_FLAGS); if (Status != CFE_SUCCESS) { + HS_CustomData.IdleTaskRunStatus = !CFE_SUCCESS; CFE_EVS_SendEvent(HS_CR_CHILD_TASK_ERR_EID, CFE_EVS_EventType_ERROR, "Error Creating Child Task for CPU Utilization Monitoring,RC=0x%08X", (unsigned int)Status); return (Status);