void MD_CopyUpdatedTbl(MD_DwellTableLoad_t *MD_LoadTablePtr, uint8 TblIndex) { uint8 EntryIndex; uint32 ResolvedAddr; MD_TableLoadEntry_t *ThisLoadEntry; MD_DwellPacketControl_t *LocalControlStruct; /* Assign pointer to internal control structure. */ LocalControlStruct = &MD_AppData.MD_DwellTables[TblIndex]; /* Copy 'Enabled' field from load structure to internal control structure. */ LocalControlStruct->Enabled = MD_LoadTablePtr->Enabled; #if MD_SIGNATURE_OPTION == 1 /* Copy 'Signature' field from load structure to internal control structure. */ strncpy (LocalControlStruct->Signature, MD_LoadTablePtr->Signature, MD_SIGNATURE_FIELD_LENGTH); /* Ensure that resulting string is null-terminated */ LocalControlStruct->Signature[MD_SIGNATURE_FIELD_LENGTH - 1] = '\0'; #endif /* For each row in the table load, */ /* copy length, delay, and address fields from load structure to */ /* internal control structure. */ for(EntryIndex=0; EntryIndex < MD_DWELL_TABLE_SIZE; EntryIndex++) { /* Get ResolvedAddr & insert in local control structure */ ThisLoadEntry = &MD_LoadTablePtr->Entry[EntryIndex]; CFS_ResolveSymAddr(&ThisLoadEntry->DwellAddress, &ResolvedAddr); CFE_PSP_MemCpy( &MD_AppData.MD_DwellTables[TblIndex].Entry[EntryIndex].ResolvedAddress, (void *) &ResolvedAddr, sizeof(uint32) ); /* Copy length */ CFE_PSP_MemCpy( &MD_AppData.MD_DwellTables[TblIndex].Entry[EntryIndex].Length, (void *) &ThisLoadEntry->Length, sizeof(uint16) ); /* Copy delay */ CFE_PSP_MemCpy( &MD_AppData.MD_DwellTables[TblIndex].Entry[EntryIndex].Delay, (void *) &ThisLoadEntry->Delay, sizeof(uint16) ); } /* end for loop */ /* Update Dwell Table Control Info, used to process dwell packets */ MD_UpdateDwellControlInfo((uint16)TblIndex); return; } /* End of MD_CopyUpdatedTbl */
int32 ADSIM_WriteDeviceData(adio_veh_msg_t *adio_veh_msg) { /* Wait for the previous A/D job to complete, if there was one (should never happen) */ if (pru_icss_wait_event_clear(THERMPOW_AD_WRITE_EVENT, sysClkRateGet()/400) == ERROR) { return ERROR; } /* Copy the data over into the ST buffer in the PRU DRAM */ CFE_PSP_MemCpy((void*)(PRU0_DRAM_BASE + THERMPOW_AD_BUFFER_ADDR), CFE_SB_GetUserData((CFE_SB_MsgPtr_t)adio_veh_msg), CFE_SB_GetUserDataLength((CFE_SB_MsgPtr_t)adio_veh_msg)); /* Tell the PRU to write out the buffers */ pru_icss_set_event(THERMPOW_AD_WRITE_EVENT); return CFE_SUCCESS; }
/****************************************************************************** ** Function: TBLMGR_Test01 ** ** - Constructor ** */ void TBLMGR_Test01(void) { TBLMGR_DumpTblCmd DumpTblCmd; printf("TBLMGR_Test01()\n"); PKTMGR_Constructor(&UtPktMgr, TEST_PIPE_NAME, TEST_PIPE_DEPTH); printf("TBLMGR_Test01() - A\n"); TBLMGR_Constructor(&UtTblMgr, TEST_PKT_TBL); printf("TBLMGR_Test01()- B\n"); CFE_PSP_MemCpy((void*)&(DumpTblCmd.FileName),"pkttbl.txt", OS_MAX_PATH_LEN); TBLMGR_DumpPktTable((CFE_SB_Msg_t*)&DumpTblCmd); } /* End TBLMGR_Test01() */
/****************************************************************************** ** Function: TBLMGR_Test01 ** ** - Constructor ** */ void TBLMGR_Test01(void) { TBLMGR_DumpTblCmd DumpTblCmd; printf("TBLMGR_Test01()\n"); EXOBJ_Constructor(&UtExObj); printf("TBLMGR_Test01() - A\n"); TBLMGR_Constructor(&UtTblMgr, TEST_OBJ_TBL_LOAD); printf("TBLMGR_Test01()- B\n"); CFE_PSP_MemCpy((void*)&(DumpTblCmd.FileName),TEST_OBJ_TBL_DUMP, OS_MAX_PATH_LEN); TBLMGR_DumpExObjTableCmd((CFE_SB_Msg_t*)&DumpTblCmd); } /* End TBLMGR_Test01() */
/****************************************************************************** ** Function: TBLMGR_DumpExObjTableCmd ** */ boolean TBLMGR_DumpExObjTableCmd(const CFE_SB_MsgPtr_t MsgPtr) { const TBLMGR_DumpTblCmd *DumpTblCmd = (const TBLMGR_DumpTblCmd *) MsgPtr; char FileName[OS_MAX_PATH_LEN]; /* Copy the commanded filename into local buffer to ensure size limitation and to allow for modification */ CFE_PSP_MemCpy(FileName, (void *)DumpTblCmd->FileName, OS_MAX_PATH_LEN); /* Check to see if a default filename should be used */ if (FileName[0] == '\0') { strncpy(FileName, _TEMPLATE__EXOBJ_TBL_DEF_DUMP_FILE, OS_MAX_PATH_LEN); } /* Make sure all strings are null terminated before attempting to process them */ FileName[OS_MAX_PATH_LEN-1] = '\0'; return DumpTableToFile(FileName,"OB App's Packet Table",DumpExObjTable); } /* End of TBLMGR_DumpExObjTableCmd() */
/****************************************************************************** ** Function: CFE_SB_GetMsgTime() ** ** Purpose: ** Get the time field from a message. ** ** Arguments: ** MsgPtr - Pointer to a CFE_SB_Msg_t ** ** Return: ** Time field from message or ** Time value of zero for msgs that do not have a Time field in header */ CFE_TIME_SysTime_t CFE_SB_GetMsgTime(CFE_SB_MsgPtr_t MsgPtr) { CFE_TIME_SysTime_t TimeFromMsg; uint32 LocalSecs32 = 0; uint32 LocalSubs32 = 0; #ifdef MESSAGE_FORMAT_IS_CCSDS #if (CFE_SB_PACKET_TIME_FORMAT == CFE_SB_TIME_32_16_SUBS) uint16 LocalSubs16; #endif CFE_SB_TlmHdr_t *TlmHdrPtr; /* if msg type is a command or msg has no secondary hdr, time = 0 */ if ((CCSDS_RD_TYPE(MsgPtr->Hdr) != CCSDS_CMD) && (CCSDS_RD_SHDR(MsgPtr->Hdr) != 0)) { /* copy time data to/from packets to eliminate alignment issues */ TlmHdrPtr = (CFE_SB_TlmHdr_t *)MsgPtr; #if (CFE_SB_PACKET_TIME_FORMAT == CFE_SB_TIME_32_16_SUBS) CFE_PSP_MemCpy(&LocalSecs32, &TlmHdrPtr->Sec.Time[0], 4); CFE_PSP_MemCpy(&LocalSubs16, &TlmHdrPtr->Sec.Time[4], 2); /* convert packet data into CFE_TIME_SysTime_t format */ LocalSubs32 = ((uint32) LocalSubs16) << 16; #elif (CFE_SB_PACKET_TIME_FORMAT == CFE_SB_TIME_32_32_SUBS) CFE_PSP_MemCpy(&LocalSecs32, &TlmHdrPtr->Sec.Time[0], 4); CFE_PSP_MemCpy(&LocalSubs32, &TlmHdrPtr->Sec.Time[4], 4); /* no conversion necessary -- packet format = CFE_TIME_SysTime_t format */ #elif (CFE_SB_PACKET_TIME_FORMAT == CFE_SB_TIME_32_32_M_20) CFE_PSP_MemCpy(&LocalSecs32, &TlmHdrPtr->Sec.Time[0], 4); CFE_PSP_MemCpy(&LocalSubs32, &TlmHdrPtr->Sec.Time[4], 4); /* convert packet data into CFE_TIME_SysTime_t format */ LocalSubs32 = CFE_TIME_Micro2SubSecs((LocalSubs32 >> 12)); #endif }
void Create_Input_File0(void) { /* FILE *to; */ int8 values[4] = {5,10,15,20}; char tableName[30]; CFE_FS_Header_t StdFileHeader; CFE_TBL_File_Hdr_t TblFileHeader; int32 FileDescriptor; int32 Status; int32 EndianCheck = 0x01020304; /* to = fopen("/tt_table_values0.dat", "wb"); if (to == 0) { UTF_error("Error opening file /tt_table_initial_values.dat to write\n"); UTF_exit(); } fwrite(values, sizeof(int8), 4, to); fclose(to); */ strcpy (tableName, "TT.FourNumbers"); /* Clear Header of any garbage before copying content */ CFE_PSP_MemSet(&StdFileHeader, 0, sizeof(CFE_FS_Header_t)); CFE_PSP_MemSet(&TblFileHeader, 0, sizeof(CFE_TBL_File_Hdr_t)); /* Create a new dump file, overwriting anything that may have existed previously */ FileDescriptor = OS_creat("/ram/tt_table_values0.dat", OS_WRITE_ONLY); if (FileDescriptor >= OS_FS_SUCCESS) { /* Initialize the standard cFE File Header for the Dump File */ StdFileHeader.SubType = CFE_FS_TBL_IMG_SUBTYPE; strcpy(&StdFileHeader.Description[0], "Table Load File"); /* Output the Standard cFE File Header to the Dump File */ Status = CFE_FS_WriteHeader(FileDescriptor, &StdFileHeader); if (Status == sizeof(CFE_FS_Header_t)) { /* Initialize the Table Image Header for the Dump File */ CFE_PSP_MemCpy(TblFileHeader.TableName, tableName, CFE_TBL_MAX_FULL_NAME_LEN); TblFileHeader.Offset = 0; TblFileHeader.NumBytes = 4; TblFileHeader.Reserved = 0; /* Determine if this is a little endian processor */ if ((*(char *)&EndianCheck) == 0x04) { CFE_TBL_ByteSwapTblHeader(&TblFileHeader); } /* Output the Table Image Header to the Dump File */ Status = OS_write(FileDescriptor, &TblFileHeader, sizeof(CFE_TBL_File_Hdr_t)); /* Make sure the header was output completely */ if (Status == sizeof(CFE_TBL_File_Hdr_t)) { /* Output the requested data to the dump file */ /* Output the active table image data to the dump file */ Status = OS_write(FileDescriptor, values, 4); } } /* We are done writing the load file. Close it. */ OS_close(FileDescriptor); } }