void CFE_TIME_TaskMain(void) { int32 Status; CFE_ES_PerfLogEntry(CFE_TIME_MAIN_PERF_ID); Status = CFE_TIME_TaskInit(); if(Status != CFE_SUCCESS) { CFE_ES_WriteToSysLog("TIME:Application Init Failed,RC=0x%08X\n", Status); CFE_ES_PerfLogExit(CFE_TIME_MAIN_PERF_ID); /* Note: CFE_ES_ExitApp will not return */ CFE_ES_ExitApp(CFE_ES_CORE_APP_INIT_ERROR); }/* end if */ /* * Wait for other apps to start. * It is important that the core apps are present before this starts receiving * messages from the command pipe, as some of those handlers might depend on * the other core apps. */ CFE_ES_WaitForStartupSync(CFE_CORE_MAX_STARTUP_MSEC); /* Main loop */ while (Status == CFE_SUCCESS) { /* Increment the Main task Execution Counter */ CFE_ES_IncrementTaskCounter(); CFE_ES_PerfLogExit(CFE_TIME_MAIN_PERF_ID); /* Pend on receipt of packet */ Status = CFE_SB_RcvMsg(&CFE_TIME_TaskData.MsgPtr, CFE_TIME_TaskData.CmdPipe, CFE_SB_PEND_FOREVER); CFE_ES_PerfLogEntry(CFE_TIME_MAIN_PERF_ID); if (Status == CFE_SUCCESS) { /* Process cmd pipe msg */ CFE_TIME_TaskPipe(CFE_TIME_TaskData.MsgPtr); }else{ CFE_ES_WriteToSysLog("TIME:Error reading cmd pipe,RC=0x%08X\n",Status); }/* end if */ }/* end while */ /* while loop exits only if CFE_SB_RcvMsg returns error */ CFE_ES_ExitApp(CFE_ES_CORE_APP_RUNTIME_ERROR); } /* end CFE_TIME_TaskMain */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ void HS_AppMain(void) { int32 Status = CFE_SUCCESS; uint32 RunStatus = CFE_ES_APP_RUN; /* ** Performance Log, Start */ CFE_ES_PerfLogEntry(HS_APPMAIN_PERF_ID); /* ** Register this application with Executive Services */ Status = CFE_ES_RegisterApp(); /* ** Perform application specific initialization */ if (Status == CFE_SUCCESS) { Status = HS_AppInit(); } /* ** If no errors were detected during initialization, then wait for everyone to start */ if (Status == CFE_SUCCESS) { CFE_ES_WaitForStartupSync(HS_STARTUP_SYNC_TIMEOUT); /* ** Enable and set the watchdog timer */ CFE_PSP_WatchdogSet(HS_WATCHDOG_TIMEOUT_VALUE); CFE_PSP_WatchdogService(); CFE_PSP_WatchdogEnable(); CFE_PSP_WatchdogService(); /* ** Subscribe to Event Messages */ if (HS_AppData.CurrentEventMonState == HS_STATE_ENABLED) { Status = CFE_SB_SubscribeEx(CFE_EVS_EVENT_MSG_MID, HS_AppData.EventPipe, CFE_SB_Default_Qos, HS_EVENT_PIPE_DEPTH); if (Status != CFE_SUCCESS) { CFE_EVS_SendEvent(HS_SUB_EVS_ERR_EID, CFE_EVS_ERROR, "Error Subscribing to Events,RC=0x%08X",Status); } } } if (Status != CFE_SUCCESS) { /* ** Set run status to terminate main loop */ RunStatus = CFE_ES_APP_ERROR; } /* ** Application main loop */ while(CFE_ES_RunLoop(&RunStatus) == TRUE) { /* ** Performance Log, Stop */ CFE_ES_PerfLogExit(HS_APPMAIN_PERF_ID); /* ** Task Delay for a configured timeout */ #if HS_POST_PROCESSING_DELAY != 0 OS_TaskDelay(HS_POST_PROCESSING_DELAY); #endif /* ** Task Delay for a configured timeout */ Status = CFE_SB_RcvMsg(&HS_AppData.MsgPtr, HS_AppData.WakeupPipe, HS_WAKEUP_TIMEOUT); /* ** Performance Log, Start */ CFE_ES_PerfLogEntry(HS_APPMAIN_PERF_ID); /* ** Process the software bus message */ if ((Status == CFE_SUCCESS) || (Status == CFE_SB_NO_MESSAGE) || (Status == CFE_SB_TIME_OUT)) { Status = HS_ProcessMain(); } /* ** Note: If there were some reason to exit the task ** normally (without error) then we would set ** RunStatus = CFE_ES_APP_EXIT */ if (Status != CFE_SUCCESS) { /* ** Set request to terminate main loop */ RunStatus = CFE_ES_APP_ERROR; } } /* end CFS_ES_RunLoop while */ /* ** Check for "fatal" process error... */ if (Status != CFE_SUCCESS) { /* ** Send an event describing the reason for the termination */ CFE_EVS_SendEvent(HS_APP_EXIT_EID, CFE_EVS_CRITICAL, "Application Terminating, err = 0x%08X", Status); /* ** In case cFE Event Services is not working */ CFE_ES_WriteToSysLog("HS App: Application Terminating, ERR = 0x%08X\n", Status); } HS_CustomCleanup(); /* ** Performance Log, Stop */ CFE_ES_PerfLogExit(HS_APPMAIN_PERF_ID); /* ** Exit the application */ CFE_ES_ExitApp(RunStatus); } /* end HS_AppMain */