Beispiel #1
0
void TO_ProcessCmdMsg(void)
{
    CFE_SB_Msg_t    *MsgPtr;
    CFE_SB_MsgId_t  MsgId;

    while(1)    /* While loop to execute until all commands received */
    {
       /* Check for message on cmd pipe and process */
       switch (CFE_SB_RcvMsg(&MsgPtr, TO_AppData.CmdPipe, CFE_SB_POLL))
       {
          case CFE_SUCCESS:

               MsgId = CFE_SB_GetMsgId(MsgPtr);

               switch (MsgId)
               {
                  case TO_CMD_MID:
                	   /* Call Command Exec Function */
                       TO_CmdExec(MsgPtr);
                       break;

                  default:
                       CFE_EVS_SendEvent(TO_MSGID_ERR_EID,CFE_EVS_ERROR,
                    		         "TO: Cmd Pipe Invalid Msg ID Rcvd 0x%x",
                    		         MsgId);
                       break;
               }
               break;
            default:
               /* Exit command processing loop if no message received. */
               return;
       }
    }
}
Beispiel #2
0
/******************************************************************************
** Function: ProcessCommands
**
*/
static void ProcessCommands(void)
{

   int32           Status;
   CFE_SB_Msg_t*   CmdMsgPtr;
   CFE_SB_MsgId_t  MsgId;

   Status = CFE_SB_RcvMsg(&CmdMsgPtr, LabTlm.CmdPipe, CFE_SB_POLL);

   if (Status == CFE_SUCCESS)
   {

      MsgId = CFE_SB_GetMsgId(CmdMsgPtr);

      switch (MsgId)
      {
         case LABTLM_CMD_MID:
            CMDMGR_DispatchFunc(CmdMsgPtr);
            break;

         case LABTLM_SEND_HK_MID:
            LABTLM_SendHousekeepingPkt();
            break;

         default:
            CFE_EVS_SendEvent(LABTLM_INVALID_MID_ERR_EID, CFE_EVS_ERROR,
                              "Received invalid command packet,MID = 0x%4X",MsgId);

            break;

      } /* End Msgid switch */

   } /* End if SB received a packet */

} /* End ProcessCommands() */
void THRSIM_TaskMain(void) {
    uint32 RunStatus = CFE_ES_APP_RUN;
    int32  Status = CFE_SUCCESS;

    CFE_ES_PerfLogEntry(THRSIM_MAIN_TASK_PERF_ID);

    Status = THRSIM_Init();
    if (Status != CFE_SUCCESS) {
        RunStatus = CFE_ES_APP_ERROR;
    }

    while (CFE_ES_RunLoop(&RunStatus) == TRUE) {
        CFE_ES_PerfLogExit(THRSIM_MAIN_TASK_PERF_ID);

        Status = CFE_SB_RcvMsg(&THRSIM_AppData.MsgPtr, THRSIM_AppData.CmdPipe, CFE_SB_PEND_FOREVER);

        CFE_ES_PerfLogEntry(THRSIM_MAIN_TASK_PERF_ID);

        if (Status == CFE_SUCCESS) {
            THRSIM_AppPipe();
        } else {
            CFE_EVS_SendEvent(THRSIM_PIPE_ERR_EID, CFE_EVS_ERROR, "SB pipe read error, THRSIM will exit.");
            RunStatus = CFE_ES_APP_ERROR;
        }
    }
}
Beispiel #4
0
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *  * *  * * * * **/
void $APPLICATION_NAME$_AppMain( void )
{
    int32  status;
    uint32 RunStatus = CFE_ES_APP_RUN;

    CFE_ES_PerfLogEntry($APPLICATION_NAME$_APP_PERF_ID);

    $APPLICATION_NAME$_AppInit();

    /*
    ** $APPLICATION_NAME$ Runloop
    */
    while (CFE_ES_RunLoop(&RunStatus) == TRUE)
    {
        CFE_ES_PerfLogExit($APPLICATION_NAME$_APP_PERF_ID);

        /* Pend on receipt of command packet -- timeout set to 500 millisecs */
        status = CFE_SB_RcvMsg(&$APPLICATION_NAME$_MsgPtr, $APPLICATION_NAME$_CommandPipe, 500);
        
        CFE_ES_PerfLogEntry($APPLICATION_NAME$_APP_PERF_ID);

        if (status == CFE_SUCCESS)
        {
            $APPLICATION_NAME$_ProcessCommandPacket();
        }

    }

    CFE_ES_ExitApp(RunStatus);

} /* End of $APPLICATION_NAME$_AppMain() */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void TO_process_commands(void)
{
    CFE_SB_Msg_t    *MsgPtr;
    CFE_SB_MsgId_t  MsgId;

    while(1)
    {
       switch (CFE_SB_RcvMsg(&MsgPtr, TO_Cmd_pipe, CFE_SB_POLL))
       {
          case CFE_SUCCESS:

               MsgId = CFE_SB_GetMsgId(MsgPtr);
               /* For SB return statuses that imply a message: process it. */
               switch (MsgId)
               {
                  case TO_LAB_CMD_MID:
                       TO_exec_local_command(MsgPtr);
                       break;

                  case TO_LAB_SEND_HK_MID:
                       TO_output_status();
                       break;

                  default:
                       CFE_EVS_SendEvent(TO_MSGID_ERR_EID,CFE_EVS_ERROR, "L%d TO: Invalid Msg ID Rcvd 0x%x",__LINE__,MsgId);
                       break;
               }
               break;
            default:
               /* Exit command processing loop if no message received. */
               return;
       }
    }
} /* End of TO_process_commands() */
Beispiel #6
0
void UU_AppMain(void)
{
	int32 Status;
	int32 Status2;
	CFE_SB_PipeId_t pipeId;
	char pipeName[10];
	void *TblPointer;
	CFE_TBL_Handle_t TblHandle;
	

    /*
    ** Register application...
    */
    /* CFE_ES_RegisterApp(); */

    /*
    ** Perform application specific initialize 
    ** including access initial table values.
    */
    UU_AppInit();
    TblHandle = 0; /* original was 5 */
                         
     /*
    ** Main process loop (forever)...
    */
    while (TRUE)
    {
     	    
        /*
        ** Wait for the next Software Bus message...
        */
        Status = CFE_SB_RcvMsg(&UU_AppData.MsgPtr,
                                  UU_AppData.CmdPipe,
                                  4);
                                  
     /*   if (Status == CFE_SB_TIME_OUT) */
        if (1)
        {
        	UTF_put_text("CFE_ES_ResetCFE returned %lx\n",CFE_ES_ResetCFE(5));
        	
        	UTF_put_text("CFE_ES_RegisterApp returned %lx\n",CFE_ES_RegisterApp());
        	  /* This one caused a seg fault */
        	  /*UTF_put_text("CFE_ES_GetAppID returned %d\n",CFE_ES_GetAppID((uint32 *)0x3344beef)); */
       	   UTF_put_text("CFE_ES_GetAppID returned %lx\n",CFE_ES_GetAppID(0));
       	   
       	   Status2 = CFE_EVS_SendEvent(UU_INIT_INF_EID,
                      CFE_EVS_INFORMATION,
                     "UU: SendEvent called from UU task's forever loop");
           UTF_put_text("CFE_EVS_SendEvent returned %lx\n", Status2);
           UTF_put_text("CFE_FS_ReadHeader returned %lx\n", CFE_FS_ReadHeader(0,0));
       	   UTF_put_text("CFE_SB_CreatePipe returned %lx\n", CFE_SB_CreatePipe(&pipeId,1,pipeName));
       	   UTF_put_text("CFE_SB_RcvMsg returned %lx\n", Status);
       	   UTF_put_text(" CFE_TBL_GetAddress returned %lx\n", 
       	                  CFE_TBL_GetAddress( &TblPointer,TblHandle ));

        }
                
    }

} /* End of UU_AppMain() */
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 */
Beispiel #8
0
void TT_AppMain(void)
{
	int32 Status;

    /*
    ** Register application...
    */
    CFE_ES_RegisterApp();

    /*
    ** Perform application specific initialize 
    ** including access initial table values.
    */
    TT_AppInit();

    	/* This step simulates the working buffer being */
	/* loaded in the background.                    */
/*	UTF_put_text("\n>>Loading new data.\n"); */
/*	Status = CFE_TBL_LoadWorkingBuffer(TT_AppData.TblHandle,
                 CFE_TBL_SRC_FILE,
                 "/tt_table_values1.dat"); */
    /* UTF_put_text("CFE_TBL_LoadWorkingBuffer returned %lx\n", Status);*/
                         
     /*
    ** Main process loop (forever)...
    */
    while (TRUE)
    {
     	    
        /*
        ** Wait for the next Software Bus message...
        */
        Status = CFE_SB_RcvMsg(&TT4_AppData.MsgPtr,
                                  TT4_AppData.CmdPipe,
                                  4);

        if (Status == CFE_SUCCESS)
        {
            /*
            ** Process Software Bus message...
            */
            TT_AppPipe(TT4_AppData.MsgPtr);
        }
        
        /* Access the latest Table Values */
        TT_AccessCurrentData();
        
    }

} /* End of TT_AppMain() */
Beispiel #9
0
void TO_ForwardTelemetry(uint32 PrioMask)
{
    int32   cfeStatus;
    uint32	msgSize;
    uint32	Surplus = 0;
    uint32 	i=0;

    for(i=0; i < TO_MAX_TLM_CLASS_QUEUES; i++)
    {
    	TO_TlmClassQueue_t *clsQueue = &TO_AppData.Config->ClassQueue[i];

    	uint32 budget = clsQueue->Quantum + clsQueue->Deficit + Surplus;
    	while(1)
    	{
    		if(TO_AppData.Config->ClassQueue[i].PktPtr == 0)
    		{
				cfeStatus = CFE_SB_RcvMsg(&TO_AppData.Config->ClassQueue[i].PktPtr, clsQueue->PipeId, CFE_SB_POLL);
				if((cfeStatus != CFE_SUCCESS))
				{
					clsQueue->Deficit = 0;
					Surplus = budget;
					break;
				}
    		}

    		if(i == 3)
    		{
    			OS_printf("Video telemetry out.");
    		}

    		msgSize = CFE_SB_GetTotalMsgLength(TO_AppData.Config->ClassQueue[i].PktPtr);
			if(msgSize <= budget)
			{
				TO_SendToChannel(TO_AppData.Config->ClassQueue[i].ChannelIdx,
						TO_AppData.Config->ClassQueue[i].PktPtr,
						msgSize);

				TO_AppData.Config->ClassQueue[i].PktPtr = 0;
				budget -= msgSize;
			}
			else
			{
				clsQueue->DeferredCount++;
				clsQueue->Deficit = budget - Surplus;
				Surplus = budget;
				break;
			}
		}
   	}
}
Beispiel #10
0
void CFE_TBL_TaskMain(void)
{
    int32  Status;

    CFE_ES_PerfLogEntry(CFE_TBL_MAIN_PERF_ID);

    Status = CFE_TBL_TaskInit();
    
    if(Status != CFE_SUCCESS)
    {
      CFE_ES_WriteToSysLog("TBL:Application Init Failed,RC=0x%08X\n", Status);      
      CFE_ES_PerfLogExit(CFE_TBL_MAIN_PERF_ID);      
      /* Note: CFE_ES_ExitApp will not return */
      CFE_ES_ExitApp(CFE_ES_CORE_APP_INIT_ERROR);
    }/* end if */

    /* Main loop */
    while (Status == CFE_SUCCESS)
    {
        /* Increment the Main task Execution Counter */
        CFE_ES_IncrementTaskCounter();

        CFE_ES_PerfLogExit(CFE_TBL_MAIN_PERF_ID);

        /* Pend on receipt of packet */
        Status = CFE_SB_RcvMsg( &CFE_TBL_TaskData.MsgPtr,
                                CFE_TBL_TaskData.CmdPipe,
                                CFE_SB_PEND_FOREVER);

        CFE_ES_PerfLogEntry(CFE_TBL_MAIN_PERF_ID);

        if (Status == CFE_SUCCESS)
        {
            /* Process cmd pipe msg */
            CFE_TBL_TaskPipe(CFE_TBL_TaskData.MsgPtr);
        }else{
            CFE_ES_WriteToSysLog("TBL: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_TBL_TaskMain() */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void TO_forward_telemetry(void)
{
    static struct sockaddr_in s_addr;
    int                       status;
    int32                     CFE_SB_status;
    uint16                    size;
    CFE_SB_Msg_t              *PktPtr;

    bzero((char *) &s_addr, sizeof(s_addr));
    s_addr.sin_family      = AF_INET;
    s_addr.sin_addr.s_addr = inet_addr(tlm_dest_IP);
    s_addr.sin_port        = htons(cfgTLM_PORT);
    status = 0;

    do
    {
       CFE_SB_status = CFE_SB_RcvMsg(&PktPtr, TO_Tlm_pipe, CFE_SB_POLL);

       if ( (CFE_SB_status == CFE_SUCCESS) && (suppress_sendto == FALSE) )
       {
          size = CFE_SB_GetTotalMsgLength(PktPtr);
          
          if(downlink_on == TRUE)
          {
             CFE_ES_PerfLogEntry(TO_SOCKET_SEND_PERF_ID);

             status = sendto(TLMsockid, (char *)PktPtr, size, 0,
                                        (struct sockaddr *) &s_addr,
                                         sizeof(s_addr) );
                                         
             CFE_ES_PerfLogExit(TO_SOCKET_SEND_PERF_ID);                             
          }
          if (status < 0)
          {
             CFE_EVS_SendEvent(TO_TLMOUTSTOP_ERR_EID,CFE_EVS_ERROR,
                               "L%d TO sendto errno %d. Tlm output supressed\n", __LINE__, errno);
             suppress_sendto = TRUE;
          }
       }
    /* If CFE_SB_status != CFE_SUCCESS, then no packet was received from CFE_SB_RcvMsg() */
    }while(CFE_SB_status == CFE_SUCCESS);
} /* End of TO_forward_telemetry() */
Beispiel #12
0
void CI_TaskMain( void )
{
    int32   status;
    uint32  RunStatus = CFE_ES_APP_RUN;

    CFE_ES_PerfLogEntry(CI_MAIN_TASK_PERF_ID);

    CI_TaskInit();

#ifdef _CI_DELAY_TEST
    OS_printf("CI going to delay for 40 seconds before calling runloop\n");
    OS_TaskDelay(40000);
#endif

    /*
    ** CI Runloop
    */
    while (CFE_ES_RunLoop(&RunStatus) == TRUE)
    {
        CFE_ES_PerfLogExit(CI_MAIN_TASK_PERF_ID);

        /* Pend on receipt of command packet -- timeout set to 500 millisecs */
        status = CFE_SB_RcvMsg(&CIMsgPtr, CI_CommandPipe, 500);
        CFE_ES_PerfLogEntry(CI_MAIN_TASK_PERF_ID);

        if (status == CFE_SUCCESS)
        {
            CI_ProcessCommandPacket();
        }

        /* Regardless of packet vs timeout, always process uplink queue      */
        if (CI_SocketConnected)
        {
            CI_ReadUpLink();
        }
    }
    CFE_ES_ExitApp(RunStatus);

} /* End of CI_TaskMain() */
Beispiel #13
0
int32 TO_RecvMsg( int32 timeout )
{
	int32 iStatus ;

    /*  Performance Log Exit Stamp */
    CFE_ES_PerfLogExit(TO_MAIN_TASK_PERF_ID);

    /* Wait for SCH software bus Wakeup or HK message */
    iStatus = CFE_SB_RcvMsg(&TO_AppData.MsgPtr,
    		                 TO_AppData.SchPipe,
    		                 timeout);
    /* Message received now process message */
    if (iStatus == CFE_SUCCESS)
    {
        TO_ProcessSchMsg();
    }
    else if ( iStatus == CFE_SB_TIME_OUT )
	{
    	/* SCH was probably unloaded or the entry was disabled, causing the
    	 * wakeup to timeout.  Rather than completely blackout all telemetry
    	 * we'll go ahead and send telemetry after the timeout anyway.
    	 */
        TO_OutputStatus();
        TO_ForwardTelemetry(TO_AppData.Config->Timeout);
    }
    else if ( iStatus == CFE_SB_NO_MESSAGE )
    {
        /* nothing to be done if no message is present */
    }

    /* Performance Log Exit Stamp */
    CFE_ES_PerfLogEntry(TO_MAIN_TASK_PERF_ID);

    return iStatus ;

}
Beispiel #14
0
void SC_AppMain(void)
{   
    uint32 RunStatus = CFE_ES_APP_RUN;
    int32 Result;

    /* Register application with cFE */
    Result = CFE_ES_RegisterApp();

    /* Performance Log (start time counter) */
    CFE_ES_PerfLogEntry(SC_APPMAIN_PERF_ID);

    /* Startup initialization */
    if (Result == CFE_SUCCESS)
    {
        Result = SC_AppInit();                  
    }

    /* Check for start-up error */
    if (Result != CFE_SUCCESS)
    {
        /* Set request to terminate main loop */
        RunStatus = CFE_ES_APP_ERROR;
    }

    /* Main process loop */
    while (CFE_ES_RunLoop(&RunStatus))
    {
        /* Performance Log (stop time counter) */
        CFE_ES_PerfLogExit(SC_APPMAIN_PERF_ID);

        /* Pend on Software Bus for message */
        Result = CFE_SB_RcvMsg(&SC_OperData.MsgPtr, SC_OperData.CmdPipe, CFE_SB_PEND_FOREVER);

        /* Performance Log (start time counter) */
        CFE_ES_PerfLogEntry(SC_APPMAIN_PERF_ID);

        /* Check for Software Bus error */
        if (Result == CFE_SUCCESS)
        {
            /* Invoke command handlers */
            SC_ProcessRequest(SC_OperData.MsgPtr);   
        }
        else
        {
            /* Exit main process loop */
            RunStatus = CFE_ES_APP_ERROR;
        }
    }
    
    /* Check for "fatal" process error */
    if (Result !=  CFE_SUCCESS)
    {
        /* Send event describing reason for termination */
        CFE_EVS_SendEvent(SC_APP_EXIT_ERR_EID, CFE_EVS_ERROR,
           "App terminating, Result = 0x%08X", Result);

        /* In case cFE Event Services is not working */
        CFE_ES_WriteToSysLog("SC App terminating, Result = 0x%08X\n", Result);
    }

    /* Performance Log (stop time counter) */
    CFE_ES_PerfLogExit(SC_APPMAIN_PERF_ID);
    
    /* Let cFE kill the app */
    CFE_ES_ExitApp(RunStatus);
    
} /* end SC_AppMain() */
Beispiel #15
0
void SIMCI_TaskMain( void ) {
    int32  Status = CFE_SUCCESS;
    uint32 RunStatus = CFE_ES_APP_RUN;
    struct timeval tv_timeout;
    fd_set readfds;
    int32  max_fd;

    CFE_ES_PerfLogEntry(SIMCI_MAIN_TASK_PERF_ID);

    Status = SIMCI_TaskInit();
    if (Status != CFE_SUCCESS) {
        RunStatus = CFE_ES_APP_ERROR;
    }

    /* Set up information for select */
    max_fd = max(SIMCI_AppData.UplinkSocketID, SIMCI_AppData.IngestSocketID);
    max_fd++;

    tv_timeout.tv_sec = 0;
    tv_timeout.tv_usec = SIMCI_PERIOD_USEC;

    /* Runloop */
    while (CFE_ES_RunLoop(&RunStatus) == TRUE)
    {
        FD_ZERO(&readfds);

        FD_SET(SIMCI_AppData.UplinkSocketID, &readfds);
        FD_SET(SIMCI_AppData.IngestSocketID, &readfds);

        CFE_ES_PerfLogExit(SIMCI_MAIN_TASK_PERF_ID);

        /* Select on the two sockets + SB pipe */
        Status = select(max_fd, &readfds, NULL, NULL, &tv_timeout);

        CFE_ES_PerfLogEntry(SIMCI_MAIN_TASK_PERF_ID);

        if (Status == 0) {
            /* Timed out, process some commands if available */
            uint32 i;

            for (i = 0; i < SIMCI_PIPE_DEPTH; i++) {
                Status = CFE_SB_RcvMsg(&SIMCI_AppData.MsgPtr, SIMCI_AppData.CommandPipe, CFE_SB_POLL);
                if (Status == CFE_SUCCESS) {
                    /* We have a message to process */
                    SIMCI_AppPipe();
                } else if (Status == CFE_SB_NO_MESSAGE) {
                    /* Nothing to do, go back to sleep */
                    break;
                } else {
                    SIMCI_AppData.HkPacket.error_count++;
                    CFE_EVS_SendEvent(SIMCI_PIPE_ERR_EID, CFE_EVS_ERROR, "SIMCI: Error reading command pipe, RC=%08X", Status);
                }
            }
        } else {
            if (FD_ISSET(SIMCI_AppData.UplinkSocketID, &readfds)) {
                SIMCI_ForwardUplinkPacket();
            }
            if (FD_ISSET(SIMCI_AppData.IngestSocketID, &readfds)) {
                SIMCI_IngestPacket();
            }
        }
    }
    CFE_ES_ExitApp(RunStatus);

}
Beispiel #16
0
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
int32 HS_ProcessCommands(void)
{
    int32 Status = CFE_SUCCESS;

    /*
    ** Event Message Pipe (done first so EventMon does not get enabled without table checking)
    */
    if (HS_AppData.CurrentEventMonState == HS_STATE_ENABLED)
    {
        while (Status == CFE_SUCCESS)
        {
            Status = CFE_SB_RcvMsg(&HS_AppData.MsgPtr, HS_AppData.EventPipe, CFE_SB_POLL);

            if (Status == CFE_SUCCESS)
            {
                /*
                ** Pass Events to Event Monitor
                */
                HS_AppData.EventsMonitoredCount++;
                HS_MonitorEvent(HS_AppData.MsgPtr);
            }
        }
    }

    if (Status == CFE_SB_NO_MESSAGE)
    {
        /*
        ** It's Good to not get a message -- we are polling
        */
        Status = CFE_SUCCESS;
    }

    /*
    ** Command and HK Requests Pipe
    */
    while (Status == CFE_SUCCESS)
    {
        /*
        ** Process pending Commands or HK Reqs
        */
        Status = CFE_SB_RcvMsg(&HS_AppData.MsgPtr, HS_AppData.CmdPipe, CFE_SB_POLL);

        if (Status == CFE_SUCCESS)
        {
            /*
            ** Pass Commands/HK Req to AppPipe Processing
            */
            HS_AppPipe(HS_AppData.MsgPtr);
        }
    }

    if (Status == CFE_SB_NO_MESSAGE)
    {
        /*
        ** It's Good to not get a message -- we are polling
        */
        Status = CFE_SUCCESS;
    }

    return(Status);

} /* End of HS_ProcessCommands() */
Beispiel #17
0
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
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 */