void task_1(void) { uint32 status; OS_printf("Starting task 1\n"); OS_TaskRegister(); while(1) { status = OS_MutSemTake(mutex_id); if ( status != OS_SUCCESS ) { OS_printf("TASK 1:Error calling OS_MutSemTake with mutex_id = %d\n",mutex_id); } shared_resource_x = task_1_id; status = OS_QueuePut(msgq_id, (void*)&shared_resource_x, sizeof(uint32), 0); if ( status != OS_SUCCESS ) { OS_printf("TASK 1:Error calling OS_QueuePut ( 1 )\n"); } shared_resource_x = task_1_id; status = OS_QueuePut(msgq_id, (void*)&shared_resource_x, sizeof(uint32), 0); if ( status != OS_SUCCESS ) { OS_printf("TASK 1:Error calling OS_QueuePut ( 2 )\n"); } status = OS_MutSemGive(mutex_id); if ( status != OS_SUCCESS ) { OS_printf("TASK 1:Error calling OS_MutSemGive\n"); } OS_TaskDelay(100); } }
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() */
void task_3(void) { uint32 status; OS_printf("Starting task 3\n"); OS_TaskRegister(); while(1) { OS_TaskDelay(1000); OS_printf("TASK 3: Waiting on the semaphore\n"); status = OS_CountSemTake(count_sem_id); if ( status != OS_SUCCESS ) { OS_printf("TASK 3: Error calling OS_CountSemTake\n"); } else { OS_printf("TASK 3: grabbed Counting Sem\n"); } } }
static void test_003_005_execute(void) { uint32 local_tmid; /* [3.5.1] Retrieving the timer by name.*/ test_set_step(1); { int32 err; err = OS_TimerGetIdByName(&local_tmid, "test timer"); test_assert(err == OS_SUCCESS, "timer not found"); } /* [3.5.2] Setting up the timer for a 70mS periodic tick.*/ test_set_step(2); { uint32 err; err = OS_TimerSet(local_tmid, 70000, 70000); test_assert(err == OS_SUCCESS, "timer setup failed"); } /* [3.5.3] Waiting one second then counting the occurred ticks.*/ test_set_step(3); { (void) OS_TaskDelay(1000); test_assert(cnt == 14, "wrong ticks"); } /* [3.5.4] Stopping the timer.*/ test_set_step(4); { uint32 err; err = OS_TimerSet(local_tmid, 0, 0); test_assert(err == OS_SUCCESS, "timer stop failed"); } }
void QSYS_Init(void) { u8 *ptr1; u8 *ptr2; // FIL *ptr3; OS_CPU_SysTickInit();//Initialize the SysTick. #if OS_USE_UCOS CPU_IntSrcPrioSet(CPU_INT_PENDSV,15); CPU_IntSrcPrioSet(CPU_INT_SYSTICK,15); #endif SetupHardware(); Debug("sizeof(INPUT_EVENT)=%d\n\r",sizeof(INPUT_EVENT));//for debug by karlno Debug("sizeof(PAGE_ATTRIBUTE)=%d\n\r",sizeof(PAGE_ATTRIBUTE));//for debug by karlno Debug("sizeof(IMG_BUTTON_OBJ)=%d\n\r",sizeof(IMG_BUTTON_OBJ));//for debug by karlno Debug("sizeof(CHAR_BUTTON_OBJ)=%d\n\r",sizeof(CHAR_BUTTON_OBJ));//for debug by karlno Debug("sizeof(MUSIC_EVENT)=%d\n\r",sizeof(MUSIC_EVENT));//for debug by karlno //Debug("sizeof(QSYS_MSG_BOX)=%d\n\r",sizeof(QSYS_MSG_BOX));//for debug by karlno if(SysEvt_MaxNum>32) { Debug("Error:SysEvt_MaxNum(%d) is too big!!!\n\r",SysEvt_MaxNum); Q_ErrorStopScreen("Error:SysEvt_MaxNum is too big!!!\n\r"); } gLCD_Mutex=OS_MutexCreate(); //创建触摸输入中断发生信号量 gTouchHandler_Sem=OS_SemaphoreCreate(0); gAllowTchHandler_Sem=OS_SemaphoreCreate(0); gVsDreq_Sem=OS_SemaphoreCreate(0); gRfRecvHandler_Sem=OS_SemaphoreCreate(0); //创建事件传递数据 gInputHandler_Queue=OS_MsgBoxCreate("Input Event",sizeof(INPUT_EVENT),16); gMusicHandler_Queue=OS_MsgBoxCreate("MusicKV Event",sizeof(MUSIC_EVENT),8); #if 0//debug OS_TaskCreate((void (*) (void *)) T1_Task,(void *) 0, (OS_STK *) &T1_TaskStack[OS_MINIMAL_STACK_SIZE - 1],T1_TASK_pRIORITY); //OS_TaskCreate(T2_Task , ( signed OS_CHAR * ) "T2 Handler", OS_MINI_STACK_SIZE, NULL, MUSIC_HANDLER_TASK_PRIORITY, NULL ); OS_TaskDelete(SYSTEM_TASK_PRIORITY); #endif #if 1 //首次下载完成后可关闭此处代码,防止误下载 Debug("\n\r-------------------SPI FLASH DOWNLOAD FROM SD------------------\n\r"); ptr1=(u8 *)Q_Mallco(CfgFileSize); ptr2=(u8 *)Q_Mallco(SPI_FLASH_PAGE_SIZE); SpiFlashDownFromSD(FALSE,"System/Down.cfg",ptr1,ptr2); Q_Free(ptr2); Q_Free(ptr1); Debug("-------------------SPI FLASH DOWNLOAD FROM SD------------------\n\r\n\r"); #endif Debug("----------------DATABASE SETTING INITIALIZATION----------------\n\r"); DB_Init(); Debug("----------------DATABASE SETTING INITIALIZATION----------------\n\r\n\r"); RTC_SetUp(); Gui_Init(); //图像库初始化 Gui_SetBgLight(Q_DB_GetValue(Setting_BgLightScale,NULL));//设置背光亮度 OS_TaskCreate(MusicHandler_Task,"Music",OS_MINIMAL_STACK_SIZE*8,NULL,MUSIC_TASK_PRIORITY,&MusicHandler_Task_Handle); OS_TaskCreate(TouchHandler_Task,"Touch",OS_MINIMAL_STACK_SIZE*3,NULL,TOUCH_TASK_PRIORITY,&TouchHandler_Task_Handle); OS_TaskCreate(KeysHandler_Task,"Keys",OS_MINIMAL_STACK_SIZE*2,NULL,KEYS_TASK_PRIORITY,&KeysHandler_Task_Handle); OS_TaskCreate(QWebHandler_Task,"QWeb",OS_MINIMAL_STACK_SIZE*8,NULL,RF_DATA_TASK_PRIORITY,&QWebHandler_Task_Handle); OS_TaskDelay(100); OS_TaskStkCheck(FALSE); if(GPIO_ReadInputDataBit(GPIOE,GPIO_Pin_2)==0) //如果没按下Key-PE2,就正常启动串口中断 { #if !QXW_RELEASE_VER//for debug USART_ITConfig(USART1, USART_IT_RXNE, ENABLE);//release版本请关掉此句,免得不懂的用户说板卡老死机。 USART_ITConfig(USART3, USART_IT_RXNE, ENABLE); #endif } }
static void test_001_002_execute(void) { /* [1.2.1] Four tasks are created in priority order from low to high.*/ test_set_step(1); { int32 err; uint32 tid1, tid2, tid3, tid4; err = OS_TaskCreate(&tid4, "running task 4", test_task4, (uint32 *)wa_test4, sizeof wa_test4, TASKS_BASE_PRIORITY - 0, 0); test_assert(err == OS_SUCCESS, "task 4 creation failed"); err = OS_TaskCreate(&tid3, "running task 3", test_task3, (uint32 *)wa_test3, sizeof wa_test3, TASKS_BASE_PRIORITY - 1, 0); test_assert(err == OS_SUCCESS, "task 3 creation failed"); err = OS_TaskCreate(&tid2, "running task 2", test_task2, (uint32 *)wa_test2, sizeof wa_test2, TASKS_BASE_PRIORITY - 2, 0); test_assert(err == OS_SUCCESS, "task 2 creation failed"); err = OS_TaskCreate(&tid1, "running task 1", test_task1, (uint32 *)wa_test1, sizeof wa_test1, TASKS_BASE_PRIORITY - 3, 0); test_assert(err == OS_SUCCESS, "task 1 creation failed"); } /* [1.2.2] Tasks are made runnable atomically and their execution order tested.*/ test_set_step(2); { OS_TaskDelay(5); test_assert_sequence("ABCD", "task order violation"); } /* [1.2.3] Four tasks are created in priority order from high to low.*/ test_set_step(3); { int32 err; uint32 tid1, tid2, tid3, tid4; err = OS_TaskCreate(&tid1, "running task 1", test_task1, (uint32 *)wa_test1, sizeof wa_test1, TASKS_BASE_PRIORITY - 3, 0); test_assert(err == OS_SUCCESS, "task 1 creation failed"); err = OS_TaskCreate(&tid2, "running task 2", test_task2, (uint32 *)wa_test2, sizeof wa_test2, TASKS_BASE_PRIORITY - 2, 0); test_assert(err == OS_SUCCESS, "task 2 creation failed"); err = OS_TaskCreate(&tid3, "running task 3", test_task3, (uint32 *)wa_test3, sizeof wa_test3, TASKS_BASE_PRIORITY - 1, 0); test_assert(err == OS_SUCCESS, "task 3 creation failed"); err = OS_TaskCreate(&tid4, "running task 4", test_task4, (uint32 *)wa_test4, sizeof wa_test4, TASKS_BASE_PRIORITY - 0, 0); test_assert(err == OS_SUCCESS, "task 4 creation failed"); } /* [1.2.4] Tasks are made runnable atomically and their execution order tested.*/ test_set_step(4); { OS_TaskDelay(5); test_assert_sequence("ABCD", "task order violation"); } /* [1.2.5] Four tasks are created in an not ordered way.*/ test_set_step(5); { int32 err; uint32 tid1, tid2, tid3, tid4; err = OS_TaskCreate(&tid2, "running task 2", test_task2, (uint32 *)wa_test2, sizeof wa_test2, TASKS_BASE_PRIORITY - 2, 0); test_assert(err == OS_SUCCESS, "task 2 creation failed"); err = OS_TaskCreate(&tid1, "running task 1", test_task1, (uint32 *)wa_test1, sizeof wa_test1, TASKS_BASE_PRIORITY - 3, 0); test_assert(err == OS_SUCCESS, "task 1 creation failed"); err = OS_TaskCreate(&tid4, "running task 4", test_task4, (uint32 *)wa_test4, sizeof wa_test4, TASKS_BASE_PRIORITY - 0, 0); test_assert(err == OS_SUCCESS, "task 4 creation failed"); err = OS_TaskCreate(&tid3, "running task 3", test_task3, (uint32 *)wa_test3, sizeof wa_test3, TASKS_BASE_PRIORITY - 1, 0); test_assert(err == OS_SUCCESS, "task 3 creation failed"); } /* [1.2.6] Tasks are made runnable atomically and their execution order tested.*/ test_set_step(6); { OS_TaskDelay(5); test_assert_sequence("ABCD", "task order violation"); } }
/* ** Main function */ void OS_Application_Startup(void) { uint32 status; OS_bin_sem_prop_t bin_sem_prop; OS_API_Init(); OS_printf("OS Application Startup\n"); /* ** Create the binary semaphore */ status = OS_BinSemCreate( &bin_sem_id, "BinSem1", 1, 0); if ( status != OS_SUCCESS ) { OS_printf("Error creating Binary Sem\n"); } else { status = OS_BinSemGetInfo (bin_sem_id, &bin_sem_prop); OS_printf("Binary Sem ID = %d, value = %d\n", (int)bin_sem_id, (int)bin_sem_prop.value); } /* ** Take the semaphore so the value is 0 and the next SemTake call should block */ status = OS_BinSemTake(bin_sem_id); if ( status != OS_SUCCESS ) { OS_printf("Error calling OS_BinSemTake with bin_sem_id = %d\n",(int)bin_sem_id); } else { status = OS_BinSemGetInfo (bin_sem_id, &bin_sem_prop); OS_printf("Initial Binary Sem Take: value = %d\n", (int)bin_sem_prop.value); } /* ** Create the tasks */ status = OS_TaskCreate( &task_1_id, "Task 1", task_1, task_1_stack, TASK_STACK_SIZE, TASK_1_PRIORITY, 0); if ( status != OS_SUCCESS ) { OS_printf("Error creating Task 1\n"); } else { OS_printf("Created Task 1\n"); } status = OS_TaskCreate( &task_2_id, "Task 2", task_2, task_2_stack, TASK_STACK_SIZE, TASK_2_PRIORITY, 0); if ( status != OS_SUCCESS ) { OS_printf("Error creating Task 2\n"); } else { OS_printf("Created Task 2\n"); } status = OS_TaskCreate( &task_3_id, "Task 3", task_3, task_3_stack, TASK_STACK_SIZE, TASK_3_PRIORITY, 0); if ( status != OS_SUCCESS ) { OS_printf("Error creating Task 3\n"); } else { OS_printf("Created Task 3\n"); } /* ** Delay, then release the semaphore */ OS_TaskDelay(2000); status = OS_BinSemFlush(bin_sem_id); OS_printf("Main done!\n"); }
/*------------------------------------------------------------------------- ** ** Functional Prolog ** ** Name: CFE_ES_CreateObjects ** ** Purpose: This function reads the es_object_table and performs all of the ** application layer initialization. **---------------------------------------------------------------------------- */ void CFE_ES_CreateObjects(void) { int32 ReturnCode; boolean AppSlotFound; int16 i; int16 j; CFE_ES_WriteToSysLog("ES Startup: Starting Object Creation calls.\n"); for ( i = 0; i < CFE_ES_OBJECT_TABLE_SIZE; i++ ) { switch ( CFE_ES_ObjectTable[i].ObjectType ) { case CFE_ES_DRIVER_TASK: case CFE_ES_CORE_TASK: /* ** Allocate an ES AppTable entry */ AppSlotFound = FALSE; for ( j = 0; j < CFE_ES_MAX_APPLICATIONS; j++ ) { if ( CFE_ES_Global.AppTable[j].RecordUsed == FALSE ) { AppSlotFound = TRUE; break; } } /* ** If a slot was found, create the application */ if ( AppSlotFound == TRUE ) { CFE_ES_LockSharedData(__func__,__LINE__); /* ** Allocate and populate the ES_AppTable entry */ CFE_PSP_MemSet ( (void *)&(CFE_ES_Global.AppTable[j]), 0, sizeof(CFE_ES_AppRecord_t)); CFE_ES_Global.AppTable[j].RecordUsed = TRUE; CFE_ES_Global.AppTable[j].Type = CFE_ES_APP_TYPE_CORE; /* ** Fill out the parameters in the AppStartParams sub-structure */ strncpy((char *)CFE_ES_Global.AppTable[j].StartParams.Name, (char *)CFE_ES_ObjectTable[i].ObjectName, OS_MAX_API_NAME); CFE_ES_Global.AppTable[j].StartParams.Name[OS_MAX_API_NAME - 1] = '\0'; /* EntryPoint field is not valid here for base apps */ /* FileName is not valid for base apps, either */ CFE_ES_Global.AppTable[j].StartParams.StackSize = CFE_ES_ObjectTable[i].ObjectSize; CFE_ES_Global.AppTable[j].StartParams.StartAddress = (uint32)CFE_ES_ObjectTable[i].FuncPtrUnion.FunctionPtr; CFE_ES_Global.AppTable[j].StartParams.ExceptionAction = CFE_ES_APP_EXCEPTION_PROC_RESTART; CFE_ES_Global.AppTable[j].StartParams.Priority = CFE_ES_ObjectTable[i].ObjectPriority; /* ** Fill out the Task Info */ strncpy((char *)CFE_ES_Global.AppTable[j].TaskInfo.MainTaskName, (char *)CFE_ES_ObjectTable[i].ObjectName, OS_MAX_API_NAME); CFE_ES_Global.AppTable[j].TaskInfo.MainTaskName[OS_MAX_API_NAME - 1] = '\0'; CFE_ES_Global.AppTable[j].TaskInfo.NumOfChildTasks = 0; /* ** Since this is a Core app, the AppStateRecord does not need to be filled out. */ /* ** Create the task */ ReturnCode = OS_TaskCreate(&CFE_ES_Global.AppTable[j].TaskInfo.MainTaskId, /* task id */ CFE_ES_ObjectTable[i].ObjectName, /* task name */ CFE_ES_ObjectTable[i].FuncPtrUnion.VoidPtr, /* task function pointer */ NULL, /* stack pointer */ CFE_ES_ObjectTable[i].ObjectSize, /* stack size */ CFE_ES_ObjectTable[i].ObjectPriority, /* task priority */ OS_FP_ENABLED); /* task options */ if(ReturnCode != OS_SUCCESS) { CFE_ES_Global.AppTable[j].RecordUsed = FALSE; CFE_ES_WriteToSysLog("ES Startup: OS_TaskCreate error creating core App: %s: EC = 0x%08X\n", CFE_ES_ObjectTable[i].ObjectName, ReturnCode); CFE_ES_UnlockSharedData(__func__,__LINE__); /* ** Delay to allow the message to be read */ OS_TaskDelay(CFE_ES_PANIC_DELAY); /* ** cFE Cannot continue to start up. */ CFE_PSP_Panic(CFE_PSP_PANIC_CORE_APP); } else { CFE_ES_ObjectTable[i].ObjectKey = CFE_ES_Global.AppTable[j].TaskInfo.MainTaskId; /* ** Allocate and populate the CFE_ES_Global.TaskTable entry */ if ( CFE_ES_Global.TaskTable[CFE_ES_Global.AppTable[j].TaskInfo.MainTaskId].RecordUsed == TRUE ) { CFE_ES_WriteToSysLog("ES Startup: CFE_ES_Global.TaskTable record used error for App: %s, continuing.\n", CFE_ES_ObjectTable[i].ObjectName); } else { CFE_ES_Global.TaskTable[CFE_ES_Global.AppTable[j].TaskInfo.MainTaskId].RecordUsed = TRUE; } CFE_ES_Global.TaskTable[CFE_ES_Global.AppTable[j].TaskInfo.MainTaskId].AppId = j; CFE_ES_Global.TaskTable[CFE_ES_Global.AppTable[j].TaskInfo.MainTaskId].TaskId = CFE_ES_Global.AppTable[j].TaskInfo.MainTaskId; strncpy((char *)CFE_ES_Global.TaskTable[CFE_ES_Global.AppTable[j].TaskInfo.MainTaskId].TaskName, (char *)CFE_ES_Global.AppTable[j].TaskInfo.MainTaskName, OS_MAX_API_NAME); CFE_ES_Global.TaskTable[CFE_ES_Global.AppTable[j].TaskInfo.MainTaskId].TaskName[OS_MAX_API_NAME - 1] = '\0'; CFE_ES_WriteToSysLog("ES Startup: Core App: %s created. App ID: %d\n", CFE_ES_ObjectTable[i].ObjectName,j); /* ** Increment the registered App and Registered External Task variables. */ CFE_ES_Global.RegisteredTasks++; CFE_ES_Global.RegisteredCoreApps++; CFE_ES_UnlockSharedData(__func__,__LINE__); } } else /* appSlot not found -- This should never happen!*/ { CFE_ES_WriteToSysLog("ES Startup: Error, No free application slots available for CORE App!\n"); /* ** Delay to allow the message to be read */ OS_TaskDelay(CFE_ES_PANIC_DELAY); /* ** cFE Cannot continue to start up. */ CFE_PSP_Panic(CFE_PSP_PANIC_CORE_APP); } break; case CFE_ES_FUNCTION_CALL: /*----------------------------------------------------------*/ if ( CFE_ES_ObjectTable[i].FuncPtrUnion.FunctionPtr != NULL ) { CFE_ES_WriteToSysLog("ES Startup: Calling %s\n",CFE_ES_ObjectTable[i].ObjectName); /* ** Call the function */ ReturnCode = (*CFE_ES_ObjectTable[i].FuncPtrUnion.FunctionPtr)(); if(ReturnCode != CFE_SUCCESS) { CFE_ES_WriteToSysLog("ES Startup: Error returned when calling function: %s: EC = 0x%08X\n", CFE_ES_ObjectTable[i].ObjectName, ReturnCode); /* ** Delay to allow the message to be read */ OS_TaskDelay(CFE_ES_PANIC_DELAY); /* ** cFE Cannot continue to start up. */ CFE_PSP_Panic(CFE_PSP_PANIC_CORE_APP); } /* end if */ } else { CFE_ES_WriteToSysLog("ES Startup: bad function pointer ( table entry = %d).\n",i); } break; case CFE_ES_NULL_ENTRY: /*-------------------------------------------------------*/ break; default: break; } /* end switch */ } /* end for */ CFE_ES_WriteToSysLog("ES Startup: Finished ES CreateObject table entries.\n"); }
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ int32 CFE_ES_ShellOutputCommand(char * CmdString, char *Filename) { int32 Result; int32 ReturnCode = CFE_SUCCESS; int32 fd; int32 FileSize; int32 CurrFilePtr; uint32 i; /* the extra 1 added for the \0 char */ char CheckCmd [CFE_ES_CHECKSIZE + 1]; char Cmd [CFE_ES_MAX_SHELL_CMD]; char OutputFilename [OS_MAX_PATH_LEN]; /* Use default filename if not provided */ if (Filename[0] == '\0') { strncpy(OutputFilename, CFE_ES_DEFAULT_SHELL_FILENAME, OS_MAX_PATH_LEN); } else { strncpy(OutputFilename, Filename, OS_MAX_PATH_LEN); } /* Make sure string is null terminated */ OutputFilename[OS_MAX_PATH_LEN - 1] = '\0'; /* Remove previous version of output file */ OS_remove(OutputFilename); fd = OS_creat(OutputFilename, OS_READ_WRITE); if (fd < OS_FS_SUCCESS) { Result = OS_FS_ERROR; } else { strncpy(CheckCmd,CmdString,CFE_ES_CHECKSIZE); CheckCmd[CFE_ES_CHECKSIZE] = '\0'; strncpy(Cmd,CmdString, CFE_ES_MAX_SHELL_CMD); /* We need to check if this command is directed at ES, or at the operating system */ if (strncmp(CheckCmd,"ES_",CFE_ES_CHECKSIZE) == 0) { /* This list can be expanded to include other ES functionality */ if ( strncmp(Cmd,CFE_ES_LIST_APPS_CMD,strlen(CFE_ES_LIST_APPS_CMD) )== 0) { Result = CFE_ES_ListApplications(fd); } else if ( strncmp(Cmd,CFE_ES_LIST_TASKS_CMD,strlen(CFE_ES_LIST_TASKS_CMD) )== 0) { Result = CFE_ES_ListTasks(fd); } else if ( strncmp(Cmd,CFE_ES_LIST_RESOURCES_CMD,strlen(CFE_ES_LIST_RESOURCES_CMD) )== 0) { Result = CFE_ES_ListResources(fd); } /* default if there is not an ES command that matches */ else { Result = CFE_ES_ERR_SHELL_CMD; CFE_ES_WriteToSysLog("There is no ES Shell command that matches %s \n",Cmd); } } /* if the command is not directed at ES, pass it through to the * underlying OS */ else { Result = OS_ShellOutputToFile(Cmd,fd); } /* seek to the end of the file to get it's size */ FileSize = OS_lseek(fd,0,OS_SEEK_END); if (FileSize == OS_FS_ERROR) { OS_close(fd); CFE_ES_WriteToSysLog("OS_lseek call failed from CFE_ES_ShellOutputCmd 1\n"); Result = OS_FS_ERROR; } /* We want to add 3 characters at the end of the telemetry,'\n','$','\0'. * To do this we need to make sure there are at least 3 empty characters at * the end of the last CFE_ES_MAX_SHELL_PKT so we don't over write any data. If * the current file has only 0,1, or 2 free spaces at the end, we want to * make the file longer to start a new tlm packet of size CFE_ES_MAX_SHELL_PKT. * This way we will get a 'blank' packet with the correct 3 characters at the end. */ else { /* if we are within 2 bytes of the end of the packet*/ if ( FileSize % CFE_ES_MAX_SHELL_PKT > (CFE_ES_MAX_SHELL_PKT - 3)) { /* add enough bytes to start a new packet */ for (i = 0; i < CFE_ES_MAX_SHELL_PKT - (FileSize % CFE_ES_MAX_SHELL_PKT) + 1 ; i++) { OS_write(fd," ",1); } } else { /* we are exactly at the end */ if( FileSize % CFE_ES_MAX_SHELL_PKT == 0) { OS_write(fd," ",1); } } /* seek to the end of the file again to get it's new size */ FileSize = OS_lseek(fd,0,OS_SEEK_END); if (FileSize == OS_FS_ERROR) { OS_close(fd); CFE_ES_WriteToSysLog("OS_lseek call failed from CFE_ES_ShellOutputCmd 2\n"); Result = OS_FS_ERROR; } else { /* set the file back to the beginning */ OS_lseek(fd,0,OS_SEEK_SET); /* start processing the chunks. We want to have one packet left so we are sure this for loop * won't run over */ for (CurrFilePtr=0; CurrFilePtr < (FileSize - CFE_ES_MAX_SHELL_PKT); CurrFilePtr += CFE_ES_MAX_SHELL_PKT) { OS_read(fd, CFE_ES_TaskData.ShellPacket.ShellOutput, CFE_ES_MAX_SHELL_PKT); /* Send the packet */ CFE_SB_TimeStampMsg((CFE_SB_Msg_t *) &CFE_ES_TaskData.ShellPacket); CFE_SB_SendMsg((CFE_SB_Msg_t *) &CFE_ES_TaskData.ShellPacket); /* delay to not flood the pipe on large messages */ OS_TaskDelay(200); } /* finish off the last portion of the file */ /* over write the last packet with spaces, then it will get filled * in with the correct info below. This assures that the last non full * part of the packet will be spaces */ for (i =0; i < CFE_ES_MAX_SHELL_PKT; i++) { CFE_ES_TaskData.ShellPacket.ShellOutput[i] = ' '; } OS_read(fd, CFE_ES_TaskData.ShellPacket.ShellOutput, ( FileSize - CurrFilePtr)); /* From our check above, we are assured that there are at least 3 free * characters to write our data into at the end of this last packet * * The \n assures we are on a new line, the $ gives us our prompt, and the * \0 assures we are null terminalted. */ CFE_ES_TaskData.ShellPacket.ShellOutput[ CFE_ES_MAX_SHELL_PKT - 3] = '\n'; CFE_ES_TaskData.ShellPacket.ShellOutput[ CFE_ES_MAX_SHELL_PKT - 2] = '$'; CFE_ES_TaskData.ShellPacket.ShellOutput[ CFE_ES_MAX_SHELL_PKT - 1] = '\0'; /* Send the last packet */ CFE_SB_TimeStampMsg((CFE_SB_Msg_t *) &CFE_ES_TaskData.ShellPacket); CFE_SB_SendMsg((CFE_SB_Msg_t *) &CFE_ES_TaskData.ShellPacket); /* Close the file descriptor */ OS_close(fd); } /* if FilseSize == OS_FS_ERROR */ } /* if FileSeize == OS_FS_ERROR */ }/* if fd < OS_FS_SUCCESS */ if (Result != OS_SUCCESS && Result != CFE_SUCCESS ) { ReturnCode = CFE_ES_ERR_SHELL_CMD; CFE_ES_WriteToSysLog("OS_ShellOutputToFile call failed from CFE_ES_ShellOutputCommand\n"); } else { ReturnCode = CFE_SUCCESS; } return ReturnCode; }
void EIM_NavDataTlmMain(void) { int32 Status = CFE_SUCCESS; struct sockaddr_in addrNav; uint32 RunStatus = CFE_ES_APP_RUN; Status = CFE_ES_RegisterChildTask(); if(Status != CFE_SUCCESS) { CFE_EVS_SendEvent(EIM_TELEM_TASK_ERR_EID, CFE_EVS_ERROR, "EIM: Failed to register telemetry listener task."); CFE_ES_ExitChildTask(); } /* ** Install the delete handler */ OS_TaskInstallDeleteHandler((void *)(&EIM_NavDataTlm_delete_callback)); /* Create sockets */ EIM_AppData.NavSocketID = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); if(EIM_AppData.NavSocketID < 0) { CFE_EVS_SendEvent(EIM_TELEM_TASK_ERR_EID, CFE_EVS_ERROR,"EIM: Create Nav telemetry socket failed = %d", errno); CFE_ES_ExitChildTask(); } //EIM_AppData.ATCmdSocketID = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); //if(EIM_AppData.ATCmdSocketID < 0) //{ // CFE_EVS_SendEvent(EIM_TELEM_TASK_ERR_EID, CFE_EVS_ERROR,"EIM: Create Nav command socket failed = %d", errno); // CFE_ES_ExitChildTask(); //} memset((char *) &addrNav, 0, sizeof(addrNav)); addrNav.sin_family = AF_INET; addrNav.sin_port = htons(EIM_NAV_DATA_PORT+100); addrNav.sin_addr.s_addr = htonl(INADDR_ANY); OS_printf("EIM: Binding NAV socket.\n"); if ( bind(EIM_AppData.NavSocketID, (struct sockaddr *) &addrNav, sizeof(addrNav)) < 0) { CFE_EVS_SendEvent(EIM_TELEM_TASK_ERR_EID, CFE_EVS_ERROR, "EIM: Failed to bind NAV command socket. errno: %d", errno); CFE_ES_ExitChildTask(); } /* Set addresses */ //bzero((char *) &EIM_AppData.CmdSocketAddress, sizeof(EIM_AppData.CmdSocketAddress)); //EIM_AppData.CmdSocketAddress.sin_family = AF_INET; //EIM_AppData.CmdSocketAddress.sin_addr.s_addr = inet_addr("0.0.0.0"); //EIM_AppData.CmdSocketAddress.sin_port = htons(0); //bzero((char *) &EIM_AppData.CmdARDroneAddress, sizeof(EIM_AppData.CmdARDroneAddress)); //EIM_AppData.CmdARDroneAddress.sin_family = AF_INET; //EIM_AppData.CmdARDroneAddress.sin_addr.s_addr = inet_addr(EIM_WIFI_IP); //EIM_AppData.CmdARDroneAddress.sin_port = htons(EIM_AT_PORT); //if ( bind(EIM_AppData.ATCmdSocketID, // (struct sockaddr *) &EIM_AppData.CmdSocketAddress, // sizeof(EIM_AppData.CmdSocketAddress)) < 0) //{ // CFE_EVS_SendEvent(EIM_TELEM_TASK_ERR_EID, CFE_EVS_ERROR, // "EIM: Failed to bind command socket. errno: %d", errno); // CFE_ES_ExitChildTask(); //} // //EIM_InitATCmdSockets(); OS_TaskDelay(100); EIM_ResetTlmConnection(); if(CFE_ES_RunLoop(&RunStatus) == FALSE) { EIM_AppData.Hk.NavDataState = EIM_NAVDATA_FAILED; } else { EIM_AppData.Hk.NavDataState = EIM_NAVDATA_ENABLED; } while (CFE_ES_RunLoop(&RunStatus) == TRUE) { EIM_ReadTelem(); if(EIM_AppData.Hk.ARDroneState.CommWatchdog == TRUE) { if(EIM_AppData.Hk.ARDrone2TimedOut == FALSE) { CFE_EVS_SendEvent(EIM_TELEM_TASK_ERR_EID, CFE_EVS_ERROR, "EIM: ARDrone timedout. Resetting watchdog."); EIM_AppData.Hk.ARDrone2TimedOut = TRUE; } EIM_cmdComWdg(); } else { if(EIM_AppData.Hk.ARDrone2TimedOut == TRUE) { CFE_EVS_SendEvent(EIM_TELEM_TASK_ERR_EID, CFE_EVS_ERROR, "EIM: ARDrone watchdog reset."); EIM_AppData.Hk.ARDrone2TimedOut = FALSE; } } } close(EIM_AppData.ATCmdSocketID); close(EIM_AppData.NavSocketID); EIM_AppData.ATCmdSocketID = 0; EIM_AppData.NavSocketID = 0; EIM_AppData.Hk.NavDataState = EIM_NAVDATA_DISABLED; CFE_ES_ExitApp(RunStatus); }
/**************************************************************** * 函数名称 : void SMARTCARD_Detect_notify(void *pvParam) * 函数功能 : * 输入参数 : 无 * 返回参数 : * 全局变量 : * 调用函数 : * 创建人 : XuHong * 创建日期 : 2002.10.18 * 修改人 : * 修改日期 : * 版本 : 0.1 ****************************************************************/ static void SMARTCARD_Detect_notify(void) { S32 ErrCode;/*times*/ Card_Event_t eventStatus=CARD_OUT_EVENT; AM_SMC_CardStatus_t tSCIStatus; S32 s32ResetTime; U8 atr_tmp[255]; int atr_recv_count; static int cardouttimes =0; while(TRUE) { OS_SemWait( Detect_signal ); ErrCode = AM_SMC_GetCardStatus(g_u8SCIPort,&tSCIStatus); if ( ErrCode == AM_SUCCESS ) { if(tSCIStatus == AM_SMC_CARD_IN) { eventStatus = CARD_IN_EVENT; } else { eventStatus=CARD_OUT_EVENT; } } // printf("SMARTCARD_Detect_notify----line %d---%d\n",__LINE__,eventStatus); if (eventStatus == Global_SC_STATS) { if(eventStatus == CARD_OUT_EVENT) { CTICAS_SendStatusToCAcore(1); Global_SC_STATS = CARD_OUT_EVENT; if(Cas_Get_Last_Err()!=0) { cardouttimes++; if(cardouttimes>=10) { // STB_CAS_Notify(2,4,0); cardouttimes=0; } } } OS_TaskDelay(500); OS_SemSignal( Detect_signal ); continue; } // pbiinfo("SMARTCARD_Detect_notify----line %d evnet%d\n",__LINE__,eventStatus); if(eventStatus == CARD_IN_EVENT) { Global_SC_STATS = CARD_IN_EVENT; atr_recv_count = 40; memset(atr_tmp,0,sizeof(atr_tmp)); printf("SMARTCARD_Detect_notify----line %d\n",__LINE__); //OS_TaskDelay(200); SC_SetParam(); ErrCode = AM_SMC_Reset(g_u8SCIPort, atr_tmp, &atr_recv_count); if(ErrCode !=AM_SUCCESS) { int i =0; OS_TaskDelay(200); OS_SemSignal( Detect_signal ); CTICAS_SendStatusToCAcore(2); printf("errrorocode %x -------line %d\n",ErrCode,__LINE__); continue; } else { CTICAS_SendStatusToCAcore( 0 ); } printf("CARD_IN_EVENT!!!! Status=%d ******\n",tSCIStatus); } else if(eventStatus == CARD_OUT_EVENT) { AM_SMC_Deactive(g_u8SCIPort); CTICAS_SendStatusToCAcore(1); Clear_All_Current_Keys(); } Global_SC_STATS=eventStatus; OS_TaskDelay(500); OS_SemSignal( Detect_signal ); } }
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ void CS_OneShotChildTask(void) { uint32 NewChecksumValue = 0; int32 Status = -1; /* Init to OS error */ uint32 NumBytesRemainingCycles = 0; uint32 NumBytesThisCycle = 0; uint32 FirstAddrThisCycle = 0; Status = CFE_ES_RegisterChildTask(); if (Status == CFE_SUCCESS) { NewChecksumValue = 0; NumBytesRemainingCycles = CS_AppData.LastOneShotSize; FirstAddrThisCycle = CS_AppData.LastOneShotAddress; while (NumBytesRemainingCycles > 0) { NumBytesThisCycle = ( (CS_AppData.MaxBytesPerCycle < NumBytesRemainingCycles) ? CS_AppData.MaxBytesPerCycle : NumBytesRemainingCycles); NewChecksumValue = CFE_ES_CalculateCRC((void *) ((uint8*)FirstAddrThisCycle), NumBytesThisCycle, NewChecksumValue, CS_DEFAULT_ALGORITHM); /* Update the remainders for the next cycle */ FirstAddrThisCycle += NumBytesThisCycle; NumBytesRemainingCycles -= NumBytesThisCycle; OS_TaskDelay(CS_CHILD_TASK_DELAY); } /*Checksum Calculation is done! */ /* put the new checksum value in the baseline */ CS_AppData.LastOneShotChecksum = NewChecksumValue; /* send event message */ CFE_EVS_SendEvent (CS_ONESHOT_FINISHED_INF_EID, CFE_EVS_INFORMATION, "OneShot checksum on Address: 0x%08X, size %d completed. Checksum = 0x%08X", CS_AppData.LastOneShotAddress, CS_AppData.LastOneShotSize, CS_AppData.LastOneShotChecksum); }/*end if register child task*/ else { /* Can't send event or write to syslog because this task isn't registered with the cFE. */ OS_printf("OneShot Child Task Registration failed!\n"); } CS_AppData.ChildTaskInUse = FALSE; CS_AppData.OneShotTaskInUse = FALSE; CS_AppData.ChildTaskID = 0; CFE_ES_ExitChildTask(); return; }/* end CS_OneShotChildTask */
/* ** Name: CFE_ES_Main ** Purpose: This is the entry point to the cFE application code. ** */ void CFE_ES_Main(uint32 StartType, uint32 StartSubtype, uint32 ModeId, uint8 *StartFilePath ) { int i; int32 ReturnCode; /* ** Initialize the Reset variables. This call is required ** Before most of the ES functions can be used including the ** ES System log. */ CFE_ES_SetupResetVariables(StartType, StartSubtype, ModeId); /* ** Initialize the Logic Perf variables ** Because this is in the ES Reset area, it must be called after ** CFE_ES_SetupResetVariables. */ CFE_ES_SetupPerfVariables(StartType); /* ** Announce the startup */ CFE_ES_WriteToSysLog("ES Startup: CFE_ES_Main started\n"); /* ** Create and Mount the filesystems needed */ CFE_ES_InitializeFileSystems(StartType); /* ** Install exception Handlers ( Placeholder ) */ CFE_PSP_AttachExceptions(); /* ** Initialize the ES Application Table ** to mark all entries as unused. */ for ( i = 0; i < CFE_ES_MAX_APPLICATIONS; i++ ) { CFE_ES_Global.AppTable[i].RecordUsed = FALSE; } /* ** Initialize the ES Task Table ** to mark all entries as unused. */ for ( i = 0; i < OS_MAX_TASKS; i++ ) { CFE_ES_Global.TaskTable[i].RecordUsed = FALSE; } /* ** Initialize the ES Generic Counter Table ** to mark all entries as unused. */ for ( i = 0; i < CFE_ES_MAX_GEN_COUNTERS; i++ ) { CFE_ES_Global.CounterTable[i].RecordUsed = FALSE; } /* ** Create the ES Shared Data Mutex */ ReturnCode = OS_MutSemCreate(&(CFE_ES_Global.SharedDataMutex), "ES_DATA_MUTEX", 0 ); if(ReturnCode != OS_SUCCESS) { CFE_ES_WriteToSysLog("ES Startup: Error: ES Shared Data Mutex could not be created. RC=0x%08X\n", ReturnCode); /* ** Delay to allow the message to be read */ OS_TaskDelay(CFE_ES_PANIC_DELAY); /* ** cFE Cannot continue to start up. */ CFE_PSP_Panic(CFE_PSP_PANIC_STARTUP_SEM); } /* end if */ /* ** Create the ES Startup Sync Semaphore */ ReturnCode = OS_BinSemCreate(&(CFE_ES_Global.StartupSyncSemaphore),"ES_SYNC_SEM", 0, 0 ); if(ReturnCode != OS_SUCCESS) { CFE_ES_WriteToSysLog("ES Startup: Error: ES Startup Sync Semaphore could not be created. RC=0x%08X\n", ReturnCode); /* ** Delay to allow the message to be read */ OS_TaskDelay(CFE_ES_PANIC_DELAY); /* ** cFE Cannot continue to start up. */ CFE_PSP_Panic(CFE_PSP_PANIC_STARTUP_SEM); } /* end if */ /* ** Create the tasks, OS objects, and initialize hardware */ CFE_ES_CreateObjects(); /* ** Before the Applications are loaded, set up the state ** variables that allow the startup syncronization to work. ** This depends on a couple of things: ** 1. The fact that the cFE applications all use the CFE_ES_RunLoop Call ** 2. The StartupSyncSemaphore has been created ( see above ) ** 3. The App(s) that wish to wait calls CFE_ES_WaitForStartupSync */ CFE_ES_Global.AppStartupCounter = 0; CFE_ES_Global.StartupFileComplete = FALSE; CFE_ES_Global.StartupSemaphoreReleased = FALSE; /* ** Start the cFE Applications from the disk using the file ** specified in the CFE_ES_NONVOL_STARTUP_FILE or CFE_ES_VOLATILE_STARTUP_FILE ** ( defined in the cfe_platform_cfg.h file ) */ CFE_ES_StartApplications(StartType, StartFilePath ); /* ** Indicate that the startup file is complete. This avoids ** certain race conditions. */ CFE_ES_Global.StartupFileComplete = TRUE; /* ** Startup is complete */ CFE_ES_WriteToSysLog("ES Startup: CFE Core Startup Complete\n"); }
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ void CS_RecomputeTablesChildTask(void) { uint32 NewChecksumValue = 0; CS_Res_Tables_Table_Entry_t * ResultsEntry = NULL; uint16 PreviousState = CS_STATE_EMPTY; boolean DoneWithEntry = FALSE; int32 Status = -1; /* Init to OS error */ uint16 PreviousDefState = CS_STATE_EMPTY; boolean DefEntryFound = FALSE; uint16 DefEntryID = 0; CS_Def_Tables_Table_Entry_t * DefTblPtr = NULL; uint16 MaxDefEntries = 0; CFE_TBL_Handle_t DefTblHandle = CFE_TBL_BAD_TABLE_HANDLE; Status = CFE_ES_RegisterChildTask(); if (Status == CFE_SUCCESS) { /* Get the variables to use from the global data */ ResultsEntry = CS_AppData.RecomputeTablesEntryPtr; /* we want to make sure that the entry isn't being checksummed in the background at the same time we are recomputing */ PreviousState = ResultsEntry -> State; ResultsEntry -> State = CS_STATE_DISABLED; /* Set entry as if this is the first time we are computing the checksum, since we want the entry to take on the new value */ ResultsEntry -> ByteOffset = 0; ResultsEntry -> TempChecksumValue = 0; ResultsEntry -> ComputedYet = FALSE; /* Update the definition table entry as well. We need to determine which memory type is being updated as well as which entry in the table is being updated. */ DefTblPtr = CS_AppData.DefTablesTblPtr; MaxDefEntries = CS_MAX_NUM_TABLES_TABLE_ENTRIES; DefTblHandle = CS_AppData.DefTablesTableHandle; DefEntryID = 0; while ((!DefEntryFound) && (DefEntryID < MaxDefEntries)) { if ((strncmp(ResultsEntry->Name, DefTblPtr[DefEntryID].Name, CFE_TBL_MAX_FULL_NAME_LEN) == 0) && (DefTblPtr[DefEntryID].State != CS_STATE_EMPTY)) { DefEntryFound = TRUE; PreviousDefState = DefTblPtr[DefEntryID].State; DefTblPtr[DefEntryID].State = CS_STATE_DISABLED; CS_ResetTablesTblResultEntry(CS_AppData.TblResTablesTblPtr); CFE_TBL_Modified(DefTblHandle); } else { DefEntryID++; } } while(!DoneWithEntry) { Status = CS_ComputeTables(ResultsEntry, &NewChecksumValue, &DoneWithEntry); if (Status == CS_ERR_NOT_FOUND) { break; } OS_TaskDelay(CS_CHILD_TASK_DELAY); } /* The new checksum value is stored in the table by the above functions */ if (Status == CS_ERR_NOT_FOUND) { CFE_EVS_SendEvent (CS_RECOMPUTE_ERROR_TABLES_ERR_EID, CFE_EVS_ERROR, "Table %s recompute failed. Could not get address", ResultsEntry -> Name); } else { /* reset the entry's variables for a newly computed value */ ResultsEntry -> TempChecksumValue = 0; ResultsEntry -> ByteOffset = 0; ResultsEntry -> ComputedYet = TRUE; /* send event message */ CFE_EVS_SendEvent (CS_RECOMPUTE_FINISH_TABLES_INF_EID, CFE_EVS_INFORMATION, "Table %s recompute finished. New baseline is 0x%08X", ResultsEntry -> Name, NewChecksumValue); } /* restore the entry's state */ ResultsEntry -> State = PreviousState; /* Restore the definition table if we found one earlier */ if (DefEntryFound) { DefTblPtr[DefEntryID].State = PreviousDefState; CS_ResetTablesTblResultEntry(CS_AppData.TblResTablesTblPtr); CFE_TBL_Modified(DefTblHandle); } }/*end if register child task*/ else { /* Can't send event or write to syslog because this task isn't registered with the cFE. */ OS_printf("Recompute Tables Child Task Registration failed!\n"); } CS_AppData.ChildTaskInUse = FALSE; CFE_ES_ExitChildTask(); return; }/* end CS_RecomputeTablesChildTask */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ void CS_RecomputeEepromMemoryChildTask(void) { uint32 NewChecksumValue = 0; char TableType[CS_TABLETYPE_NAME_SIZE]; CS_Res_EepromMemory_Table_Entry_t * ResultsEntry = NULL; uint16 Table = 0; uint16 EntryID = 0; uint16 PreviousState = CS_STATE_EMPTY; uint32 Status = -1; /* Init to OS error */ boolean DoneWithEntry = FALSE; uint16 PreviousDefState = CS_STATE_EMPTY; boolean DefEntryFound = FALSE; uint16 DefEntryID = 0; CS_Def_EepromMemory_Table_Entry_t * DefTblPtr = NULL; uint16 MaxDefEntries = 0; CFE_TBL_Handle_t DefTblHandle = CFE_TBL_BAD_TABLE_HANDLE; CS_Res_Tables_Table_Entry_t * TablesTblResultEntry = NULL; Status = CFE_ES_RegisterChildTask(); strncpy(TableType, "Undef Tbl", CS_TABLETYPE_NAME_SIZE); /* Initialize table type string */ if (Status == CFE_SUCCESS) { Table = CS_AppData.ChildTaskTable; EntryID = CS_AppData.ChildTaskEntryID; ResultsEntry = CS_AppData.RecomputeEepromMemoryEntryPtr; /* we want to make sure that the entry isn't being checksummed in the background at the same time we are recomputing */ PreviousState = ResultsEntry -> State; ResultsEntry -> State = CS_STATE_DISABLED; /* Set entry as if this is the first time we are computing the checksum, since we want the entry to take on the new value */ ResultsEntry -> ByteOffset = 0; ResultsEntry -> TempChecksumValue = 0; ResultsEntry -> ComputedYet = FALSE; /* Update the definition table entry as well. We need to determine which memory type is being updated as well as which entry in the table is being updated. */ if ((Table != CS_OSCORE) && (Table != CS_CFECORE)) { if (Table == CS_EEPROM_TABLE) { DefTblPtr = CS_AppData.DefEepromTblPtr; MaxDefEntries = CS_MAX_NUM_EEPROM_TABLE_ENTRIES; DefTblHandle = CS_AppData.DefEepromTableHandle; TablesTblResultEntry = CS_AppData.EepResTablesTblPtr; } else { DefTblPtr = CS_AppData.DefMemoryTblPtr; MaxDefEntries = CS_MAX_NUM_MEMORY_TABLE_ENTRIES; DefTblHandle = CS_AppData.DefMemoryTableHandle; TablesTblResultEntry = CS_AppData.MemResTablesTblPtr; } if (EntryID < MaxDefEntries) { /* This assumes that the definition table entries are in the same order as the results table entries, which should be a safe assumption. */ if ((ResultsEntry->StartAddress == DefTblPtr[EntryID].StartAddress) && (DefTblPtr[EntryID].State != CS_STATE_EMPTY)) { DefEntryFound = TRUE; PreviousDefState = DefTblPtr[EntryID].State; DefTblPtr[EntryID].State = CS_STATE_DISABLED; DefEntryID = EntryID; CS_ResetTablesTblResultEntry(TablesTblResultEntry); CFE_TBL_Modified(DefTblHandle); } } } while(!DoneWithEntry) { CS_ComputeEepromMemory(ResultsEntry, &NewChecksumValue, &DoneWithEntry); OS_TaskDelay(CS_CHILD_TASK_DELAY); } /* The new checksum value is stored in the table by the above functions */ /* reset the entry's variables for a newly computed value */ ResultsEntry -> TempChecksumValue = 0; ResultsEntry -> ByteOffset = 0; ResultsEntry -> ComputedYet = TRUE; /* restore the entry's previous state */ ResultsEntry -> State = PreviousState; /* Restore the definition table if we found one earlier */ if (DefEntryFound) { DefTblPtr[DefEntryID].State = PreviousDefState; CS_ResetTablesTblResultEntry(TablesTblResultEntry); CFE_TBL_Modified(DefTblHandle); } /* send event message */ if( Table == CS_EEPROM_TABLE) { strncpy(TableType, "Eeprom", CS_TABLETYPE_NAME_SIZE); } if( Table == CS_MEMORY_TABLE) { strncpy(TableType, "Memory", CS_TABLETYPE_NAME_SIZE); } if( Table == CS_CFECORE) { strncpy(TableType, "cFE Core", CS_TABLETYPE_NAME_SIZE); CS_AppData.CfeCoreBaseline = NewChecksumValue; } if( Table == CS_OSCORE) { strncpy(TableType, "OS", CS_TABLETYPE_NAME_SIZE); CS_AppData.OSBaseline = NewChecksumValue; } CFE_EVS_SendEvent (CS_RECOMPUTE_FINISH_EEPROM_MEMORY_INF_EID, CFE_EVS_INFORMATION, "%s entry %d recompute finished. New baseline is 0X%08X", TableType, EntryID, NewChecksumValue); }/* end if child task register */ else { /* Can't send event or write to syslog because this task isn't registered with the cFE. */ OS_printf("Recompute for Eeprom or Memory Child Task Registration failed!\n"); } CS_AppData.ChildTaskInUse = FALSE; CFE_ES_ExitChildTask(); return; }/* end CS_RecomputeEepromMemoryChildTask */
BYTE CTISC_Command(BYTE bLength, PBYTE pabMessage, PBYTE pabReplay) { int i =0; int replay_length = 0; unsigned char command[256]; unsigned char chLRC = 0; int ActwriteLen = 0; int len = 0; int read_len = 0; int size = 0; memcpy(command+3,pabMessage,bLength); command[ 0 ] = 0; command[ 1 ] = 0; command[ 2 ] = (unsigned char)(bLength); for(i = 0; i < 3+(bLength); i++) { chLRC^= command[ i ]; } command[ bLength+3 ] = chLRC; len = bLength+4; #if 0 printf("CTISC_Command: "); for(i=0; i<len; i++) { printf("%02x ", command[i]); } printf("\n"); #endif ActwriteLen = AM_SMC_WriteEx( g_u8SCIPort, command, len, 4000); if(ActwriteLen>=AM_SUCCESS) { OS_TaskDelay(100); read_len = AM_SMC_ReadEx(g_u8SCIPort,pabReplay,3,300); if(read_len>=AM_SUCCESS) { size = pabReplay[2]; //printf("data = %x,%x,%x,read_len = %d\n",pabReplay[0],pabReplay[1],pabReplay[2],read_len); size+=1; read_len = AM_SMC_ReadEx(g_u8SCIPort,pabReplay+3,size,1000); if(read_len >= AM_SUCCESS) { #ifdef CTI_DEBUG printf("READ: = %d\n ",read_len); for(i=0; i<pabReplay[2]+4; i++) { printf("%02x ", pabReplay[i]); } printf("\n"); #endif return 0; } } else { printf("read fail = %x\n",read_len); } } else { printf("write fail = %x\n",read_len); } //TRDRV_SCARD_AdpuFunction(0,pabMessage,bLength,pabReplay,&replay_length); return 3; }
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ void CFE_ES_PerfLogDump(void){ int32 WriteStat; uint32 i; uint32 FileSize; CFE_FS_Header_t FileHdr; CFE_ES_RegisterChildTask(); /* Zero cFE header, then fill in fields */ CFE_PSP_MemSet(&FileHdr, 0, sizeof(CFE_FS_Header_t)); strcpy(&FileHdr.Description[0], CFE_ES_PERF_LOG_DESC); FileHdr.SubType = CFE_FS_ES_PERFDATA_SUBTYPE; /* write the cFE header to the file */ WriteStat = CFE_FS_WriteHeader( CFE_ES_PerfLogDumpStatus.DataFileDescriptor, &FileHdr); if(WriteStat != sizeof(CFE_FS_Header_t)) { CFE_ES_FileWriteByteCntErr(&CFE_ES_PerfLogDumpStatus.DataFileName[0], sizeof(CFE_FS_Header_t),WriteStat); OS_close(CFE_ES_PerfLogDumpStatus.DataFileDescriptor); CFE_ES_ExitChildTask(); }/* end if */ FileSize = WriteStat; /* write the performance metadata to the file */ WriteStat = OS_write(CFE_ES_PerfLogDumpStatus.DataFileDescriptor,(uint8 *)&Perf->MetaData,sizeof(CFE_ES_PerfMetaData_t)); if(WriteStat != sizeof(CFE_ES_PerfMetaData_t)) { CFE_ES_FileWriteByteCntErr(&CFE_ES_PerfLogDumpStatus.DataFileName[0], sizeof(CFE_ES_PerfMetaData_t),WriteStat); OS_close(CFE_ES_PerfLogDumpStatus.DataFileDescriptor); CFE_ES_ExitChildTask(); }/* end if */ FileSize += WriteStat; CFE_ES_PerfLogDumpStatus.DataToWrite = Perf->MetaData.DataCount; /* write the collected data to the file */ for(i=0; i < Perf->MetaData.DataCount; i++){ WriteStat = OS_write (CFE_ES_PerfLogDumpStatus.DataFileDescriptor, &Perf->DataBuffer[i], sizeof(CFE_ES_PerfDataEntry_t)); if(WriteStat != sizeof(CFE_ES_PerfDataEntry_t)) { CFE_ES_FileWriteByteCntErr(&CFE_ES_PerfLogDumpStatus.DataFileName[0], sizeof(CFE_ES_PerfDataEntry_t),WriteStat); OS_close(CFE_ES_PerfLogDumpStatus.DataFileDescriptor); /* Reset the DataToWrite variable, so a new file can be written */ CFE_ES_PerfLogDumpStatus.DataToWrite = 0; CFE_ES_ExitChildTask(); }/* end if */ FileSize += WriteStat; CFE_ES_PerfLogDumpStatus.DataToWrite--; if((i % CFE_ES_PERF_ENTRIES_BTWN_DLYS) == 0){ OS_TaskDelay(CFE_ES_PERF_CHILD_MS_DELAY); }/* end if */ }/* end for */ OS_close(CFE_ES_PerfLogDumpStatus.DataFileDescriptor); CFE_EVS_SendEvent(CFE_ES_PERF_DATAWRITTEN_EID,CFE_EVS_DEBUG, "%s written:Size=%d,EntryCount=%d", &CFE_ES_PerfLogDumpStatus.DataFileName[0],FileSize, Perf->MetaData.DataCount); CFE_ES_ExitChildTask(); }/* end CFE_ES_PerfLogDump */
/* ** Name: CFE_ES_InitializeFileSystems ** ** Purpose: This function initializes the file systems used in the cFE core. ** */ void CFE_ES_InitializeFileSystems(uint32 start_type) { int32 RetStatus; uint32 *RamDiskMemoryAddress; uint32 RamDiskMemorySize; int32 BlocksFree; int32 PercentFree; /* ** Get the memory area for the RAM disk */ RetStatus = CFE_PSP_GetVolatileDiskMem(&(RamDiskMemoryAddress), &(RamDiskMemorySize)); if ( RetStatus != OS_FS_SUCCESS ) { CFE_ES_WriteToSysLog("ES Startup: Cannot Get Memory for Volatile Disk. EC = 0x%08X\n",RetStatus); /* ** Delay to allow the message to be read */ OS_TaskDelay(CFE_ES_PANIC_DELAY); /* ** cFE Cannot continue to start up. */ CFE_PSP_Panic(CFE_PSP_PANIC_VOLATILE_DISK); } /* ** Next, either format, or just initialize the RAM disk depending on ** the reset type */ if ( start_type == CFE_ES_POWERON_RESET ) { RetStatus = OS_mkfs((void *)RamDiskMemoryAddress, "/ramdev0", "RAM", CFE_ES_RAM_DISK_SECTOR_SIZE, CFE_ES_RAM_DISK_NUM_SECTORS ); if ( RetStatus != OS_FS_SUCCESS ) { CFE_ES_WriteToSysLog("ES Startup: Error Creating Volatile(RAM) Volume. EC = 0x%08X\n",RetStatus); /* ** Delay to allow the message to be read */ OS_TaskDelay(CFE_ES_PANIC_DELAY); /* ** cFE Cannot continue to start up. */ CFE_PSP_Panic(CFE_PSP_PANIC_VOLATILE_DISK); } } else { RetStatus = OS_initfs((void *)RamDiskMemoryAddress, "/ramdev0", "RAM", CFE_ES_RAM_DISK_SECTOR_SIZE, CFE_ES_RAM_DISK_NUM_SECTORS ); if ( RetStatus != OS_FS_SUCCESS ) { CFE_ES_WriteToSysLog("ES Startup: Error Initializing Volatile(RAM) Volume. EC = 0x%08X\n",RetStatus); CFE_ES_WriteToSysLog("ES Startup: Formatting Volatile(RAM) Volume.\n"); RetStatus = OS_mkfs((void *)RamDiskMemoryAddress, "/ramdev0", "RAM", CFE_ES_RAM_DISK_SECTOR_SIZE, CFE_ES_RAM_DISK_NUM_SECTORS ); if ( RetStatus != OS_SUCCESS ) { CFE_ES_WriteToSysLog("ES Startup: Error Creating Volatile(RAM) Volume. EC = 0x%08X\n",RetStatus); /* ** Delay to allow the message to be read */ OS_TaskDelay(CFE_ES_PANIC_DELAY); /* ** cFE Cannot continue to start up. */ CFE_PSP_Panic(CFE_PSP_PANIC_VOLATILE_DISK); } } } /* ** Now, mount the RAM disk */ RetStatus = OS_mount("/ramdev0", CFE_ES_RAM_DISK_MOUNT_STRING); if ( RetStatus != OS_FS_SUCCESS ) { CFE_ES_WriteToSysLog("ES Startup: Error Mounting Volatile(RAM) Volume. EC = 0x%08X\n",RetStatus); /* ** Delay to allow the message to be read */ OS_TaskDelay(CFE_ES_PANIC_DELAY); /* ** cFE Cannot continue to start up. */ CFE_PSP_Panic(CFE_PSP_PANIC_VOLATILE_DISK); } /* ** During a Processor reset, if the RAM disk has less than a defined ** amount of free space, reformat and re-mount it. ** The parameter being checked is CFE_ES_RAM_DISK_PERCENT_RESERVED ** Note: When CFE_ES_RAM_DISK_PERCENT_RESERVED is set to 0, this feature is ** disabled. */ if ((start_type == CFE_ES_PROCESSOR_RESET) && (CFE_ES_RAM_DISK_PERCENT_RESERVED > 0)) { /* ** See how many blocks are free in the RAM disk */ BlocksFree = OS_fsBlocksFree(CFE_ES_RAM_DISK_MOUNT_STRING); if ( BlocksFree >= 0 ) { /* ** Need a sanity check for the desktop systems. ** Because the desktop ports map the volatile disk to the host ** hard disk, it will report more free blocks than the defined number ** of sectors ( blocks ). Therefore it must be truncated. */ if ( BlocksFree > CFE_ES_RAM_DISK_NUM_SECTORS ) { BlocksFree = CFE_ES_RAM_DISK_NUM_SECTORS - 1; } /* ** Determine if the disk is too full */ BlocksFree = BlocksFree * 100; PercentFree = BlocksFree / CFE_ES_RAM_DISK_NUM_SECTORS; CFE_ES_WriteToSysLog("Volatile Disk has %d Percent free space.\n",PercentFree); if ( PercentFree < CFE_ES_RAM_DISK_PERCENT_RESERVED ) { CFE_ES_WriteToSysLog("ES Startup: Insufficent Free Space on Volatile Disk, Reformatting.\n"); /* ** First, unmount the disk */ RetStatus = OS_unmount(CFE_ES_RAM_DISK_MOUNT_STRING); if ( RetStatus == OS_FS_SUCCESS ) { /* ** Remove the file system from the OSAL */ RetStatus = OS_rmfs("/ramdev0"); if ( RetStatus == OS_FS_SUCCESS ) { /* ** Next, make a new file system on the disk */ RetStatus = OS_mkfs((void *)RamDiskMemoryAddress, "/ramdev0", "RAM", CFE_ES_RAM_DISK_SECTOR_SIZE, CFE_ES_RAM_DISK_NUM_SECTORS ); if ( RetStatus == OS_FS_SUCCESS ) { /* ** Last, remount the disk */ RetStatus = OS_mount("/ramdev0", CFE_ES_RAM_DISK_MOUNT_STRING); if ( RetStatus != OS_FS_SUCCESS ) { CFE_ES_WriteToSysLog("ES Startup: Error Re-Mounting Volatile(RAM) Volume. EC = 0x%08X\n",RetStatus); /* ** Delay to allow the message to be read */ OS_TaskDelay(CFE_ES_PANIC_DELAY); /* ** cFE Cannot continue to start up. */ CFE_PSP_Panic(CFE_PSP_PANIC_VOLATILE_DISK); } /* end if mount */ } else { CFE_ES_WriteToSysLog("ES Startup: Error Re-Formating Volatile(RAM) Volume. EC = 0x%08X\n",RetStatus); /* ** Delay to allow the message to be read */ OS_TaskDelay(CFE_ES_PANIC_DELAY); /* ** cFE Cannot continue to start up. */ CFE_PSP_Panic(CFE_PSP_PANIC_VOLATILE_DISK); } /* end if mkfs */ } else /* could not Remove File system */ { CFE_ES_WriteToSysLog("ES Startup: Error Removing Volatile(RAM) Volume. EC = 0x%08X\n",RetStatus); /* ** Delay to allow the message to be read */ OS_TaskDelay(CFE_ES_PANIC_DELAY); /* ** cFE Cannot continue to start up. */ CFE_PSP_Panic(CFE_PSP_PANIC_VOLATILE_DISK); } /* end if OS_rmfs */ } else /* could not un-mount disk */ { CFE_ES_WriteToSysLog("ES Startup: Error Un-Mounting Volatile(RAM) Volume. EC = 0x%08X\n",RetStatus); /* ** Delay to allow the message to be read */ OS_TaskDelay(CFE_ES_PANIC_DELAY); /* ** cFE Cannot continue to start up. */ CFE_PSP_Panic(CFE_PSP_PANIC_VOLATILE_DISK); } } /* end if enough free space */ } else /* could not determine free blocks */ { /* Log error message -- note that BlocksFree returns the error code in this case */ CFE_ES_WriteToSysLog("ES Startup: Error Determining Blocks Free on Volume. EC = 0x%08X\n",BlocksFree); /* ** Delay to allow the message to be read */ OS_TaskDelay(CFE_ES_PANIC_DELAY); /* ** cFE Cannot continue to start up. */ CFE_PSP_Panic(CFE_PSP_PANIC_VOLATILE_DISK); } /* end if BlocksFree */ } /* end if processor reset */ } /* end function */
/* ** Name: CFE_ES_SetupResetVariables ** ** Purpose: This function initializes the ES reset variables depending on the reset type. ** It will also initiate a power on reset when too many processor resets ** have happened. ** */ void CFE_ES_SetupResetVariables(uint32 StartType, uint32 StartSubtype, uint32 BootSource ) { int32 status; uint32 resetAreaSize; /* ** Get the pointer to the Reset area from the BSP */ status = CFE_PSP_GetResetArea (&(CFE_ES_ResetDataPtr), &(resetAreaSize)); /* ** Make sure the status is OK or size is big enough */ if ( status == OS_ERROR ) { /* ** Cannot use the ES System log without the Reset Area */ OS_printf("ES Startup: CFE_PSP_GetResetArea call Failed!\n"); /* ** Delay to allow the message to be read */ OS_TaskDelay(CFE_ES_PANIC_DELAY); /* ** cFE Cannot continue to start up. */ CFE_PSP_Panic(CFE_PSP_PANIC_MEMORY_ALLOC); } else if ( resetAreaSize < sizeof(CFE_ES_ResetData_t)) { /* ** Cannot use the ES system log without the Reset Area */ OS_printf("ES Startup: Error: ES Reset area not big enough. Needed: %d, Given: %d.\n", sizeof(CFE_ES_ResetData_t), resetAreaSize); /* ** Delay to allow the message to be read */ OS_TaskDelay(CFE_ES_PANIC_DELAY); /* ** cFE Cannot continue to start up. */ CFE_PSP_Panic(CFE_PSP_PANIC_MEMORY_ALLOC); } /* ** Determine how the system was started. The choices are: ** CFE_ES_POWER_ON_RESET, or CFE_ES_PROCESSOR_RESET ** The subtypes include: ** CFE_ES_POWER_CYCLE, CFE_ES_PUSH_BUTTON, CFE_ES_HW_SPECIAL_COMMAND, ** CFE_ES_HW_WATCHDOG, CFE_ES_RESET_COMMAND, or CFE_ES_EXCEPTION. */ if ( StartType == CFE_ES_POWERON_RESET ) { /* ** Record the reset type and subtype */ CFE_ES_ResetDataPtr->ResetVars.ResetSubtype = StartSubtype; CFE_ES_ResetDataPtr->ResetVars.ResetType = CFE_ES_POWERON_RESET; /* ** Always log the power-on reset. */ status = CFE_ES_WriteToERLog(CFE_ES_CORE_LOG_ENTRY, CFE_ES_POWERON_RESET, StartSubtype, "ES Startup: POWER ON Reset", NULL,0 ); /* ** Initialize all reset counters. */ CFE_ES_ResetDataPtr->ResetVars.ProcessorResetCount = 0; CFE_ES_ResetDataPtr->ResetVars.MaxProcessorResetCount = CFE_ES_MAX_PROCESSOR_RESETS; CFE_ES_Global.DebugVars.DebugFlag = 0; } else if ( StartType == CFE_ES_PROCESSOR_RESET ) { /* ** If a Processor reset was not commanded, it must be a watchdog reset. ** Log the reset before updating any reset variables. */ if ( CFE_ES_ResetDataPtr->ResetVars.ES_CausedReset != TRUE ) { CFE_ES_ResetDataPtr->ResetVars.ResetType = CFE_ES_PROCESSOR_RESET; CFE_ES_ResetDataPtr->ResetVars.ResetSubtype = CFE_ES_HW_WATCHDOG; /* ** Log the watchdog reset */ status = CFE_ES_WriteToERLog(CFE_ES_CORE_LOG_ENTRY, CFE_ES_PROCESSOR_RESET, StartSubtype, "ES Startup: PROCESSOR RESET due to Watchdog.", NULL,0 ); /* ** When coming up from a Processor reset that was not caused by ES, check to see ** if the maximum number has been exceeded */ if ( CFE_ES_ResetDataPtr->ResetVars.ProcessorResetCount >= CFE_ES_ResetDataPtr->ResetVars.MaxProcessorResetCount ) { CFE_ES_WriteToSysLog("ES Startup: CFE ES Power On Reset Due to Max Processor Resets.\n"); /* ** Log the reset in the ER Log. The log will be wiped out, but it's good to have ** the entry just in case something fails. */ status = CFE_ES_WriteToERLog(CFE_ES_CORE_LOG_ENTRY, CFE_ES_POWERON_RESET, StartSubtype, "ES Startup: POWER ON RESET due to Maximum Processor Resets in ES Startup.", NULL,0 ); /* ** Call the BSP reset routine */ CFE_PSP_Restart(CFE_ES_POWERON_RESET); /* ** Should not return here. */ CFE_ES_WriteToSysLog("ES Startup: Error: CFE_PSP_Restart returned.\n"); } else { /* ** Increment the Processor Reset Count after the check to see ** if there are too many processor resets. This keeps the logic consistent with ** the resets that are caused by the cFE ( command or exception ) */ CFE_ES_ResetDataPtr->ResetVars.ProcessorResetCount++; } /* end if */ } /* ** If a processor reset was commanded, the reset has already been logged. ** Update the reset variables only. ** The logic for detecting maximum resets is done on the command side ** on the "way down", or when the command is executed. */ else { CFE_ES_ResetDataPtr->ResetVars.ResetType = CFE_ES_PROCESSOR_RESET; CFE_ES_ResetDataPtr->ResetVars.ResetSubtype = StartSubtype; } /* ** Initialize processor reset counters. */ CFE_ES_Global.DebugVars.DebugFlag = 0; } /* ** Clear the commanded reset flag, in case a watchdog happens. */ CFE_ES_ResetDataPtr->ResetVars.ES_CausedReset = FALSE; CFE_ES_ResetDataPtr->ResetVars.BootSource = BootSource; }
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 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 */