void FM_ReleaseTablePointers(void) { /* Release pointer to file system free space table */ CFE_TBL_ReleaseAddress(FM_GlobalData.FreeSpaceTableHandle); /* Prevent table pointer use while released */ FM_GlobalData.FreeSpaceTablePtr = (FM_FreeSpaceTable_t *) NULL; return; } /* End FM_ReleaseTablePointers */
void TT_AccessCurrentData(void) { void *TblPointer; int32 Status; CFE_TBL_Manage(TT4_AppData.TblHandle); Status = CFE_TBL_GetAddress(&TblPointer,TT4_AppData.TblHandle); if (Status == CFE_TBL_INFO_UPDATED) { TT4_AppData.HkPacket.UpdateCount++; } UTF_put_text("The current table values are:%d %d %d %d\n", *(int8*)TblPointer,*(int8*)(TblPointer+1), *(int8*)(TblPointer+2),*(int8*)(TblPointer+3)); Status = CFE_TBL_ReleaseAddress(TT4_AppData.TblHandle); } /*TT_AccessCurrentData*/
void MD_UpdateTableSignature (uint16 TableIndex, char NewSignature[MD_SIGNATURE_FIELD_LENGTH]) { int32 GetAddressResult; MD_DwellTableLoad_t *MD_LoadTablePtr; /* Get pointer to Table */ GetAddressResult = CFE_TBL_GetAddress((void*)&MD_LoadTablePtr, MD_AppData.MD_TableHandle[TableIndex]); /* Copy Signature to dwell structure */ strncpy ( MD_LoadTablePtr->Signature, NewSignature, MD_SIGNATURE_FIELD_LENGTH); /* Notify Table Services that buffer was modified */ CFE_TBL_Modified (MD_AppData.MD_TableHandle[TableIndex]); /* Release access to Table Services buffer */ CFE_TBL_ReleaseAddress (MD_AppData.MD_TableHandle[TableIndex]); return; }
void MD_UpdateTableEnabledField (uint16 TableIndex, uint16 FieldValue) { int32 GetAddressResult; MD_DwellTableLoad_t *MD_LoadTablePtr; GetAddressResult = CFE_TBL_GetAddress((void*)&MD_LoadTablePtr, MD_AppData.MD_TableHandle[TableIndex]); if (FieldValue == MD_DWELL_STREAM_ENABLED) { MD_LoadTablePtr->Enabled = MD_DWELL_STREAM_ENABLED; } else if (FieldValue == MD_DWELL_STREAM_DISABLED) { MD_LoadTablePtr->Enabled = MD_DWELL_STREAM_DISABLED; } CFE_TBL_Modified (MD_AppData.MD_TableHandle[TableIndex]); CFE_TBL_ReleaseAddress (MD_AppData.MD_TableHandle[TableIndex]); return; } /* End of MD_UpdateTableEnabledField */
void MD_UpdateTableDwellEntry (uint16 TableIndex, uint16 EntryIndex, uint16 NewLength, uint16 NewDelay, CFS_SymAddr_t NewDwellAddress) { int32 GetAddressResult; MD_DwellTableLoad_t *MD_LoadTablePtr; MD_TableLoadEntry_t *EntryPtr; /* Get pointer to Table */ GetAddressResult = CFE_TBL_GetAddress((void*)&MD_LoadTablePtr, MD_AppData.MD_TableHandle[TableIndex]); /* Get pointer to specific entry */ EntryPtr = &MD_LoadTablePtr->Entry[EntryIndex]; /* Copy new numerical values to Table Services buffer */ EntryPtr->Length = NewLength; EntryPtr->Delay = NewDelay; EntryPtr->DwellAddress.Offset = NewDwellAddress.Offset; /* Copy symbol name to Table Services buffer */ strncpy(EntryPtr->DwellAddress.SymName, NewDwellAddress.SymName, OS_MAX_SYM_LEN); /* Ensure string is null terminated. */ EntryPtr->DwellAddress.SymName[OS_MAX_SYM_LEN - 1] = '\0'; /* Notify Table Services that buffer was modified */ CFE_TBL_Modified (MD_AppData.MD_TableHandle[TableIndex]); /* Release access to Table Services buffer */ CFE_TBL_ReleaseAddress (MD_AppData.MD_TableHandle[TableIndex]); return; } /* End of MD_UpdateTableDwellEntry */
void TT_AppInit(void) { void *TblPointer; int32 Status; /* ** Initialize app command execution counters... */ TT4_AppData.CmdCount = 0; TT4_AppData.ErrCount = 0; TT4_AppData.HkPacket.UpdateCount = 0; /* ** Initialize app configuration data... */ strcpy(TT4_AppData.PipeName, "TT_CMD_PIPE"); TT4_AppData.PipeDepth = 12; TT4_AppData.LimitHK = 2; TT4_AppData.LimitCmd = 4; /* ** Initialize event filter table... */ TT4_AppData.EventFilters[0].EventID = TT_INIT_INF_EID; TT4_AppData.EventFilters[0].Mask = CFE_EVS_NO_FILTER; TT4_AppData.EventFilters[1].EventID = TT_NOOP_INF_EID; TT4_AppData.EventFilters[1].Mask = CFE_EVS_NO_FILTER; TT4_AppData.EventFilters[2].EventID = TT_RESET_INF_EID; TT4_AppData.EventFilters[2].Mask = CFE_EVS_NO_FILTER; TT4_AppData.EventFilters[3].EventID = TT_MID_ERR_EID; TT4_AppData.EventFilters[3].Mask = CFE_EVS_NO_FILTER; TT4_AppData.EventFilters[4].EventID = TT_CC1_ERR_EID; TT4_AppData.EventFilters[4].Mask = CFE_EVS_NO_FILTER; TT4_AppData.EventFilters[5].EventID = TT_LEN_ERR_EID; TT4_AppData.EventFilters[5].Mask = CFE_EVS_NO_FILTER; /* ** Register event filter table... */ CFE_EVS_Register(TT4_AppData.EventFilters, TT_EVT_COUNT, CFE_EVS_BINARY_FILTER); /* ** Initialize housekeeping packet (clear user data area)... */ CFE_SB_InitMsg(&TT4_AppData.HkPacket, CFE_TT_HK_TLM_MID, sizeof(TT_HkPacket_t), TRUE); /* ** Create Software Bus message pipe... */ CFE_SB_CreatePipe(&TT4_AppData.CmdPipe, TT4_AppData.PipeDepth, TT4_AppData.PipeName); /* ** Subscribe to Housekeeping request commands... */ CFE_SB_Subscribe(CFE_TT_SEND_HK_MID,TT4_AppData.CmdPipe); /* ** Subscribe to TT ground command packets... */ CFE_SB_Subscribe(CFE_TT_CMD_MID,TT4_AppData.CmdPipe); /* ** Register & Initialize Table... */ Status = CFE_TBL_Register(&TT4_AppData.TblHandle, "FourNumbers", 4, /* size of table in bytes*/ CFE_TBL_OPT_DBL_BUFFER | CFE_TBL_OPT_LOAD_DUMP, &TT_TableValidationCallbackFunc); /* NULL); */ UTF_put_text("CFE_TBL_Register returned %lx\n", Status); Status = CFE_TBL_Load(TT4_AppData.TblHandle, CFE_TBL_SRC_FILE, "/ram/tt_table_values0.dat"); UTF_put_text("CFE_TBL_Load returned %lx\n", Status); Status = CFE_TBL_GetAddress(&TblPointer,TT4_AppData.TblHandle); UTF_put_text("CFE_TBL_GetAddress returned %lx\n", Status); UTF_put_text("The initial values are:%d %d %d %d\n", *(int8*)TblPointer,*(int8*)(TblPointer+1), *(int8*)(TblPointer+2),*(int8*)(TblPointer+3)); Status = CFE_TBL_ReleaseAddress(TT4_AppData.TblHandle); UTF_put_text("CFE_TBL_ReleaseAddress returned %lx\n", Status); /* ** Application startup event message... */ CFE_EVS_SendEvent(TT_INIT_INF_EID, CFE_EVS_INFORMATION, "TT: Application Initialized"); return; } /* End of TT_AppInit() */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ int32 CS_ComputeTables (CS_Res_Tables_Table_Entry_t * ResultsEntry, uint32 * ComputedCSValue, boolean * DoneWithEntry) { uint32 OffsetIntoCurrEntry = 0; uint32 FirstAddrThisCycle = 0; uint32 NumBytesThisCycle = 0; int32 NumBytesRemainingCycles = 0; uint32 NewChecksumValue = 0; int32 Status = CS_SUCCESS; int32 Result = CS_SUCCESS; int32 ResultShare = 0; int32 ResultGetInfo = 0; int32 ResultGetAddress = 0; /* variables to get the table address */ CFE_TBL_Handle_t LocalTblHandle = CFE_TBL_BAD_TABLE_HANDLE; uint32 LocalAddress = 0; CFE_TBL_Info_t TblInfo; /* By the time we get here, we know we have an enabled entry */ /* set the done flag to false originally */ * DoneWithEntry = FALSE; Result = CS_SUCCESS; /* Handshake with Table Services to get address and size of table */ /* if we already have a table handle for this table, don't get a new one */ if (ResultsEntry -> TblHandle == CFE_TBL_BAD_TABLE_HANDLE) { ResultShare = CFE_TBL_Share(&LocalTblHandle, ResultsEntry -> Name); Result = ResultShare; if (Result == CFE_SUCCESS) { ResultsEntry -> TblHandle = LocalTblHandle; } } else { LocalTblHandle = ResultsEntry -> TblHandle; } if (Result == CFE_SUCCESS) { ResultGetInfo = CFE_TBL_GetInfo(&TblInfo, ResultsEntry -> Name); } /* We want to try to to get the address even if the GetInfo fails. This provides the CFE_TBL_UNREGISTERED if the table has gone away */ if (Result == CFE_SUCCESS) { ResultGetAddress = CFE_TBL_GetAddress((void*) &LocalAddress, LocalTblHandle); Result = ResultGetAddress; } /* if the table was never loaded, release the address to prevent the table from being locked by CS, which would prevent the owner app from updating it*/ if ( ResultGetAddress == CFE_TBL_ERR_NEVER_LOADED) { CFE_TBL_ReleaseAddress(LocalTblHandle); } /* The table has dissapeared since the last time CS looked. We are checking to see if the table came back */ if (Result == CFE_TBL_ERR_UNREGISTERED) { /* unregister the old handle */ CFE_TBL_Unregister(LocalTblHandle); /* reset the stored data in the results table since the table went away */ ResultsEntry -> TblHandle = CFE_TBL_BAD_TABLE_HANDLE; ResultsEntry -> ByteOffset = 0; ResultsEntry -> TempChecksumValue = 0; ResultsEntry -> ComputedYet = FALSE; ResultsEntry -> ComparisonValue = 0; ResultsEntry -> StartAddress = 0; ResultsEntry -> NumBytesToChecksum = 0; /* Maybe the table came back, try and reshare it */ ResultShare = CFE_TBL_Share(&LocalTblHandle, ResultsEntry -> Name); if (ResultShare == CFE_SUCCESS) { ResultsEntry -> TblHandle = LocalTblHandle; ResultGetInfo = CFE_TBL_GetInfo(&TblInfo, ResultsEntry -> Name); /* need to try to get the address again */ ResultGetAddress = CFE_TBL_GetAddress((void*) &LocalAddress, LocalTblHandle); Result = ResultGetAddress; /* if the table was never loaded, release the address to prevent the table from being locked by CS, which would prevent the owner app from updating it*/ if ( ResultGetAddress == CFE_TBL_ERR_NEVER_LOADED) { CFE_TBL_ReleaseAddress(LocalTblHandle); } } else /* table was not there on the new share */ { Result = ResultShare; } } if (Result == CFE_SUCCESS || Result == CFE_TBL_INFO_UPDATED) { /* push in the get data from the table info */ ResultsEntry -> NumBytesToChecksum = TblInfo.Size; ResultsEntry -> StartAddress = LocalAddress; /* if the table has been updated since the last time we looked at it, we need to start over again. We can also use the new value as a baseline checksum */ if (Result == CFE_TBL_INFO_UPDATED) { ResultsEntry -> ByteOffset = 0; ResultsEntry -> TempChecksumValue = 0; ResultsEntry -> ComputedYet = FALSE; } OffsetIntoCurrEntry = ResultsEntry -> ByteOffset; FirstAddrThisCycle = ResultsEntry -> StartAddress + OffsetIntoCurrEntry; NumBytesRemainingCycles = ResultsEntry -> NumBytesToChecksum - OffsetIntoCurrEntry; NumBytesThisCycle = ( (CS_AppData.MaxBytesPerCycle < NumBytesRemainingCycles) ? CS_AppData.MaxBytesPerCycle : NumBytesRemainingCycles); NewChecksumValue = CFE_ES_CalculateCRC((void *) ((uint8*)FirstAddrThisCycle), NumBytesThisCycle, ResultsEntry -> TempChecksumValue, CS_DEFAULT_ALGORITHM); NumBytesRemainingCycles -= NumBytesThisCycle; /* Have we finished all of the parts for this Entry */ if (NumBytesRemainingCycles <= 0) { /* Start over if an update occurred after we started the last part */ CFE_TBL_ReleaseAddress(LocalTblHandle); Result = CFE_TBL_GetAddress((void*) &LocalAddress, LocalTblHandle); if (Result == CFE_TBL_INFO_UPDATED) { *ComputedCSValue = 0; ResultsEntry -> ComputedYet = FALSE; ResultsEntry -> ComparisonValue = 0; ResultsEntry -> ByteOffset = 0; ResultsEntry -> TempChecksumValue = 0; } else { /* No last second updates, post the result for this table */ *DoneWithEntry = TRUE; if (ResultsEntry -> ComputedYet == TRUE) { /* This is NOT the first time through this Entry. We have already computed a CS value for this Entry */ if (NewChecksumValue != ResultsEntry -> ComparisonValue) { /* If the just-computed value differ from the saved value */ Status = CS_ERROR; } else { /* The checksum passes the test. */ } } else { /* This is the first time through this Entry */ ResultsEntry -> ComputedYet = TRUE; ResultsEntry -> ComparisonValue = NewChecksumValue; } *ComputedCSValue = NewChecksumValue; ResultsEntry -> ByteOffset = 0; ResultsEntry -> TempChecksumValue = 0; } } else { /* We have not finished this Entry. Will try to finish during next wakeup */ ResultsEntry -> ByteOffset += NumBytesThisCycle; ResultsEntry -> TempChecksumValue = NewChecksumValue; *ComputedCSValue = NewChecksumValue; } /* We are done with the table for this cycle, so we need to release the address */ Result = CFE_TBL_ReleaseAddress(LocalTblHandle); if (Result != CFE_SUCCESS) { CFE_EVS_SendEvent(CS_COMPUTE_TABLES_RELEASE_ERR_EID, CFE_EVS_ERROR, "CS Tables: Could not release addresss for table %s, returned: 0x%08X", ResultsEntry -> Name, Result); } }/* end if tabled was success or updated */ else { CFE_EVS_SendEvent(CS_COMPUTE_TABLES_ERR_EID, CFE_EVS_ERROR, "CS Tables: Problem Getting table %s info Share: 0x%08X, GetInfo: 0x%08X, GetAddress: 0x%08X", ResultsEntry -> Name, ResultShare, ResultGetInfo, ResultGetAddress); Status = CS_ERR_NOT_FOUND; } return Status; } /* End of CS_ComputeTables () */
int32 SCH_HousekeepingCmd(CFE_SB_MsgPtr_t MessagePtr) { int32 TableResult = SCH_SUCCESS; if(SCH_VerifyCmdLength(MessagePtr, sizeof(SCH_NoArgsCmd_t)) == SCH_SUCCESS) { /* ** Update contents of Housekeeping Packet */ SCH_AppData.HkPacket.CmdCounter = SCH_AppData.CmdCounter; SCH_AppData.HkPacket.ErrCounter = SCH_AppData.ErrCounter; SCH_AppData.HkPacket.ScheduleActivitySuccessCount = SCH_AppData.ScheduleActivitySuccessCount; SCH_AppData.HkPacket.ScheduleActivityFailureCount = SCH_AppData.ScheduleActivityFailureCount; SCH_AppData.HkPacket.SlotsProcessedCount = SCH_AppData.SlotsProcessedCount; SCH_AppData.HkPacket.SkippedSlotsCount = SCH_AppData.SkippedSlotsCount; SCH_AppData.HkPacket.MultipleSlotsCount = SCH_AppData.MultipleSlotsCount; SCH_AppData.HkPacket.SameSlotCount = SCH_AppData.SameSlotCount; SCH_AppData.HkPacket.BadTableDataCount = SCH_AppData.BadTableDataCount; SCH_AppData.HkPacket.TableVerifySuccessCount = SCH_AppData.TableVerifySuccessCount; SCH_AppData.HkPacket.TableVerifyFailureCount = SCH_AppData.TableVerifyFailureCount; SCH_AppData.HkPacket.TablePassCount = SCH_AppData.TablePassCount; SCH_AppData.HkPacket.ValidMajorFrameCount = SCH_AppData.ValidMajorFrameCount; SCH_AppData.HkPacket.MissedMajorFrameCount = SCH_AppData.MissedMajorFrameCount; SCH_AppData.HkPacket.UnexpectedMajorFrameCount = SCH_AppData.UnexpectedMajorFrameCount; SCH_AppData.HkPacket.MinorFramesSinceTone = SCH_AppData.MinorFramesSinceTone; SCH_AppData.HkPacket.NextSlotNumber = SCH_AppData.NextSlotNumber; SCH_AppData.HkPacket.LastSyncMETSlot = SCH_AppData.LastSyncMETSlot; SCH_AppData.HkPacket.IgnoreMajorFrame = SCH_AppData.IgnoreMajorFrame; SCH_AppData.HkPacket.UnexpectedMajorFrame = SCH_AppData.UnexpectedMajorFrame; SCH_AppData.HkPacket.SyncToMET = SCH_AppData.SyncToMET; SCH_AppData.HkPacket.MajorFrameSource = SCH_AppData.MajorFrameSource; /* ** Timestamps and send housekeeping packet */ CFE_SB_TimeStampMsg((CFE_SB_Msg_t *) &SCH_AppData.HkPacket); CFE_SB_SendMsg((CFE_SB_Msg_t *) &SCH_AppData.HkPacket); /* ** Reset "high rate" event filters */ CFE_EVS_ResetAllFilters(); } /* ** Note: ** ** The following table functions will give the cFE Table Manager ** a chance to update the tables used by this application. If ** there is an error (very unlikely) the return value will cause ** us to fall out of the main process loop and terminate the SCH ** task. It may sound extreme but there is nothing for the ** Scheduler to do if it cannot access both the message ** and schedule tables. */ CFE_TBL_ReleaseAddress(SCH_AppData.ScheduleTableHandle); CFE_TBL_ReleaseAddress(SCH_AppData.MessageTableHandle); TableResult = SCH_AcquirePointers(); return(TableResult); } /* End of SCH_HousekeepingCmd() */