Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #2543, consistent TIME values for TBL structures #2544

Merged
merged 1 commit into from
Apr 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions docs/src/mnem_maps/cfe_tbl_tlm_mnem_map
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ TBL_ACTBUFADD=$sc_$cpu_TBL_ActBufAdd \
TBL_IACTBUFADD=$sc_$cpu_TBL_IActBufAdd \
TBL_VALFUNCPTR=$sc_$cpu_TBL_ValFuncPtr \
TBL_TIMELASTUPD="$sc_$cpu_TBL_TimeLastUpd, $sc_$cpu_TBL_TLUSECONDS, $sc_$cpu_TBL_TLUSUBSECONDS" \
TBL_FILECSECONDS=$sc_$cpu_TBL_FILECSECONDS \
TBL_FILECSUBSECONDS=$sc_$cpu_TBL_FILECSUBSECONDS \
TBL_FILECTIME=$sc_$cpu_TBL_FILECTIME \
TBL_LOADEDONCE=$sc_$cpu_TBL_LoadedOnce \
TBL_UPDATEPNDNG=$sc_$cpu_TBL_UpdatePndng \
TBL_DUMPONLY=$sc_$cpu_TBL_DumpOnly \
Expand Down
7 changes: 3 additions & 4 deletions modules/core_api/fsw/inc/cfe_tbl_api_typedefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,9 @@ typedef enum CFE_TBL_SrcEnum
/** \brief Table Info */
typedef struct CFE_TBL_Info
{
size_t Size; /**< \brief Size, in bytes, of Table */
uint32 NumUsers; /**< \brief Number of Apps with access to the table */
uint32 FileCreateTimeSecs; /**< \brief File creation time from last file loaded into table */
uint32 FileCreateTimeSubSecs; /**< \brief File creation time from last file loaded into table */
size_t Size; /**< \brief Size, in bytes, of Table */
uint32 NumUsers; /**< \brief Number of Apps with access to the table */
CFE_TIME_SysTime_t FileTime; /**< \brief File creation time from last file loaded into table */
uint32 Crc; /**< \brief Most recently calculated CRC by TBL services on table contents */
CFE_TIME_SysTime_t TimeOfLastUpdate; /**< \brief Time when Table was last updated */
bool TableLoadedOnce; /**< \brief Flag indicating whether table has been loaded once or not */
Expand Down
9 changes: 9 additions & 0 deletions modules/core_api/fsw/inc/cfe_time_api_typedefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@
#define CFE_TIME_PRINTED_STRING_SIZE \
24 /**< \brief Required size of buffer to be passed into #CFE_TIME_Print (includes null terminator) */

/**
* A general-purpose initializer for CFE_TIME_SysTime_t values.
*
* Represents "time zero" in the CFE_TIME_SysTime_t domain. This
* can be used as a general purpose initializer for instantiations
* of the CFE_TIME_SysTime_t type.
*/
#define CFE_TIME_ZERO_VALUE ((CFE_TIME_SysTime_t) {0, 0})

/*****************************************************************************/
/*
** Type Definitions
Expand Down
4 changes: 1 addition & 3 deletions modules/tbl/config/default_cfe_tbl_msgdefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,7 @@ typedef struct CFE_TBL_TblRegPacket_Payload
\brief Ptr to Owner App's function that validates tbl contents */
CFE_TIME_SysTime_t TimeOfLastUpdate; /**< \cfetlmmnemonic \TBL_TIMELASTUPD
\brief Time when Table was last updated */
uint32 FileCreateTimeSecs; /**< \cfetlmmnemonic \TBL_FILECSECONDS
\brief File creation time from last file loaded into table */
uint32 FileCreateTimeSubSecs; /**< \cfetlmmnemonic \TBL_FILECSUBSECONDS
CFE_TIME_SysTime_t FileTime; /**< \cfetlmmnemonic \TBL_FILECTIME
\brief File creation time from last file loaded into table */
bool TableLoadedOnce; /**< \cfetlmmnemonic \TBL_LOADEDONCE
\brief Flag indicating whether table has been loaded once or not */
Expand Down
9 changes: 2 additions & 7 deletions modules/tbl/eds/cfe_tbl.xml
Original file line number Diff line number Diff line change
Expand Up @@ -292,14 +292,9 @@
\cfetlmmnemonic \TBL_TIMELASTUPD
</LongDescription>
</Entry>
<Entry name="FileCreateTimeSecs" type="BASE_TYPES/uint32" shortDescription="File creation time from last file loaded into table">
<Entry name="FileTime" type="CFE_TIME/SysTime" shortDescription="File creation time from last file loaded into table">
<LongDescription>
\cfetlmmnemonic \TBL_FILECSECONDS
</LongDescription>
</Entry>
<Entry name="FileCreateTimeSubSecs" type="BASE_TYPES/uint32" shortDescription="File creation time from last file loaded into table">
<LongDescription>
\cfetlmmnemonic \TBL_FILECSUBSECONDS
\cfetlmmnemonic \TBL_FILECTIME
</LongDescription>
</Entry>
<Entry name="TableLoadedOnce" type="BASE_TYPES/uint8" shortDescription="Flag indicating whether table has been loaded once or not">
Expand Down
20 changes: 8 additions & 12 deletions modules/tbl/fsw/src/cfe_tbl_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -425,8 +425,8 @@ CFE_Status_t CFE_TBL_Load(CFE_TBL_Handle_t TblHandle, CFE_TBL_SrcEnum_t SrcType,

snprintf(RegRecPtr->Buffers[0].DataSource, sizeof(RegRecPtr->Buffers[0].DataSource), "Addr 0x%08lX",
(unsigned long)SrcDataPtr);
RegRecPtr->Buffers[0].FileCreateTimeSecs = 0;
RegRecPtr->Buffers[0].FileCreateTimeSubSecs = 0;

RegRecPtr->Buffers[0].FileTime = CFE_TIME_ZERO_VALUE;

CFE_EVS_SendEventWithAppID(CFE_TBL_LOAD_SUCCESS_INF_EID, CFE_EVS_EventType_DEBUG, CFE_TBL_Global.TableTaskAppId,
"Successfully loaded '%s' from '%s'", RegRecPtr->Name,
Expand Down Expand Up @@ -484,8 +484,8 @@ CFE_Status_t CFE_TBL_Load(CFE_TBL_Handle_t TblHandle, CFE_TBL_SrcEnum_t SrcType,

snprintf(WorkingBufferPtr->DataSource, sizeof(WorkingBufferPtr->DataSource), "Addr 0x%08lX",
(unsigned long)SrcDataPtr);
WorkingBufferPtr->FileCreateTimeSecs = 0;
WorkingBufferPtr->FileCreateTimeSubSecs = 0;

WorkingBufferPtr->FileTime = CFE_TIME_ZERO_VALUE;

/* Compute the CRC on the specified table buffer */
WorkingBufferPtr->Crc =
Expand Down Expand Up @@ -1111,10 +1111,9 @@ CFE_Status_t CFE_TBL_GetInfo(CFE_TBL_Info_t *TblInfoPtr, const char *TblName)
TblInfoPtr->TableLoadedOnce = RegRecPtr->TableLoadedOnce;

/* Return information on last load and update */
TblInfoPtr->TimeOfLastUpdate = RegRecPtr->TimeOfLastUpdate;
TblInfoPtr->FileCreateTimeSecs = RegRecPtr->Buffers[RegRecPtr->ActiveBufferIndex].FileCreateTimeSecs;
TblInfoPtr->FileCreateTimeSubSecs = RegRecPtr->Buffers[RegRecPtr->ActiveBufferIndex].FileCreateTimeSubSecs;
TblInfoPtr->Crc = RegRecPtr->Buffers[RegRecPtr->ActiveBufferIndex].Crc;
TblInfoPtr->TimeOfLastUpdate = RegRecPtr->TimeOfLastUpdate;
TblInfoPtr->FileTime = RegRecPtr->Buffers[RegRecPtr->ActiveBufferIndex].FileTime;
TblInfoPtr->Crc = RegRecPtr->Buffers[RegRecPtr->ActiveBufferIndex].Crc;
strncpy(TblInfoPtr->LastFileLoaded, RegRecPtr->LastFileLoaded, sizeof(TblInfoPtr->LastFileLoaded) - 1);
TblInfoPtr->LastFileLoaded[sizeof(TblInfoPtr->LastFileLoaded) - 1] = 0;

Expand Down Expand Up @@ -1148,7 +1147,6 @@ CFE_Status_t CFE_TBL_DumpToBuffer(CFE_TBL_Handle_t TblHandle)
int32 Status;
CFE_TBL_RegistryRec_t *RegRecPtr = NULL;
CFE_TBL_DumpControl_t *DumpCtrlPtr = NULL;
CFE_TIME_SysTime_t DumpTime;
CFE_ES_AppId_t ThisAppId;

Status = CFE_TBL_TxnStartFromHandle(&Txn, TblHandle, CFE_TBL_TxnContext_ACCESSOR_APP);
Expand Down Expand Up @@ -1178,9 +1176,7 @@ CFE_Status_t CFE_TBL_DumpToBuffer(CFE_TBL_Handle_t TblHandle)
memcpy(DumpCtrlPtr->DumpBufferPtr->BufferPtr, RegRecPtr->Buffers[0].BufferPtr, DumpCtrlPtr->Size);

/* Save the current time so that the header in the dump file can have the correct time */
DumpTime = CFE_TIME_GetTime();
DumpCtrlPtr->DumpBufferPtr->FileCreateTimeSecs = DumpTime.Seconds;
DumpCtrlPtr->DumpBufferPtr->FileCreateTimeSubSecs = DumpTime.Subseconds;
DumpCtrlPtr->DumpBufferPtr->FileTime = CFE_TIME_GetTime();

/* Disassociate the dump request from the table */
RegRecPtr->DumpControlIndex = CFE_TBL_NO_DUMP_PENDING;
Expand Down
28 changes: 10 additions & 18 deletions modules/tbl/fsw/src/cfe_tbl_internal.c
Original file line number Diff line number Diff line change
Expand Up @@ -562,8 +562,8 @@ int32 CFE_TBL_LoadFromFile(const char *AppName, CFE_TBL_LoadBuff_t *WorkingBuffe
WorkingBufferPtr->DataSource[sizeof(WorkingBufferPtr->DataSource) - 1] = '\0';

/* Save file creation time for later storage into Registry */
WorkingBufferPtr->FileCreateTimeSecs = StdFileHeader.TimeSeconds;
WorkingBufferPtr->FileCreateTimeSubSecs = StdFileHeader.TimeSubSeconds;
WorkingBufferPtr->FileTime.Seconds = StdFileHeader.TimeSeconds;
WorkingBufferPtr->FileTime.Subseconds = StdFileHeader.TimeSubSeconds;

/* Compute the CRC on the specified table buffer */
WorkingBufferPtr->Crc =
Expand Down Expand Up @@ -651,10 +651,7 @@ int32 CFE_TBL_UpdateInternal(CFE_TBL_Handle_t TblHandle, CFE_TBL_RegistryRec_t *
RegRecPtr->LastFileLoaded[sizeof(RegRecPtr->LastFileLoaded) - 1] = 0;

/* Save the file creation time from the loaded file into the Table Registry */
RegRecPtr->Buffers[0].FileCreateTimeSecs =
CFE_TBL_Global.LoadBuffs[RegRecPtr->LoadInProgress].FileCreateTimeSecs;
RegRecPtr->Buffers[0].FileCreateTimeSubSecs =
CFE_TBL_Global.LoadBuffs[RegRecPtr->LoadInProgress].FileCreateTimeSubSecs;
RegRecPtr->Buffers[0].FileTime = CFE_TBL_Global.LoadBuffs[RegRecPtr->LoadInProgress].FileTime;

/* Save the previously computed CRC into the new buffer */
RegRecPtr->Buffers[0].Crc = CFE_TBL_Global.LoadBuffs[RegRecPtr->LoadInProgress].Crc;
Expand Down Expand Up @@ -992,9 +989,7 @@ void CFE_TBL_UpdateCriticalTblCDS(CFE_TBL_RegistryRec_t *RegRecPtr)
if (CritRegRecPtr != NULL)
{
/* Save information related to the source of the data stored in the table in Critical Table Registry */
CritRegRecPtr->FileCreateTimeSecs = RegRecPtr->Buffers[RegRecPtr->ActiveBufferIndex].FileCreateTimeSecs;
CritRegRecPtr->FileCreateTimeSubSecs =
RegRecPtr->Buffers[RegRecPtr->ActiveBufferIndex].FileCreateTimeSubSecs;
CritRegRecPtr->FileTime = RegRecPtr->Buffers[RegRecPtr->ActiveBufferIndex].FileTime;
strncpy(CritRegRecPtr->LastFileLoaded, RegRecPtr->LastFileLoaded,
sizeof(CritRegRecPtr->LastFileLoaded) - 1);
CritRegRecPtr->LastFileLoaded[sizeof(CritRegRecPtr->LastFileLoaded) - 1] = '\0';
Expand Down Expand Up @@ -1290,16 +1285,14 @@ CFE_Status_t CFE_TBL_RestoreTableDataFromCDS(CFE_TBL_RegistryRec_t *RegRecPtr, c
sizeof(WorkingBufferPtr->DataSource) - 1);
WorkingBufferPtr->DataSource[sizeof(WorkingBufferPtr->DataSource) - 1] = '\0';

WorkingBufferPtr->FileCreateTimeSecs = CritRegRecPtr->FileCreateTimeSecs;
WorkingBufferPtr->FileCreateTimeSubSecs = CritRegRecPtr->FileCreateTimeSubSecs;
WorkingBufferPtr->FileTime = CritRegRecPtr->FileTime;

strncpy(RegRecPtr->LastFileLoaded, CritRegRecPtr->LastFileLoaded,
sizeof(RegRecPtr->LastFileLoaded) - 1);
RegRecPtr->LastFileLoaded[sizeof(RegRecPtr->LastFileLoaded) - 1] = '\0';

RegRecPtr->TimeOfLastUpdate.Seconds = CritRegRecPtr->TimeOfLastUpdate.Seconds;
RegRecPtr->TimeOfLastUpdate.Subseconds = CritRegRecPtr->TimeOfLastUpdate.Subseconds;
RegRecPtr->TableLoadedOnce = CritRegRecPtr->TableLoadedOnce;
RegRecPtr->TimeOfLastUpdate = CritRegRecPtr->TimeOfLastUpdate;
RegRecPtr->TableLoadedOnce = CritRegRecPtr->TableLoadedOnce;

/* Compute the CRC on the specified table buffer */
WorkingBufferPtr->Crc =
Expand Down Expand Up @@ -1344,13 +1337,12 @@ void CFE_TBL_RegisterWithCriticalTableRegistry(CFE_TBL_CritRegRec_t *CritRegRecP
CritRegRecPtr->CDSHandle = RegRecPtr->CDSHandle;
strncpy(CritRegRecPtr->Name, TblName, sizeof(CritRegRecPtr->Name) - 1);
CritRegRecPtr->Name[sizeof(CritRegRecPtr->Name) - 1] = '\0';
CritRegRecPtr->FileCreateTimeSecs = 0;
CritRegRecPtr->FileCreateTimeSubSecs = 0;
CritRegRecPtr->LastFileLoaded[0] = '\0';
CritRegRecPtr->TimeOfLastUpdate.Seconds = 0;
CritRegRecPtr->TimeOfLastUpdate.Subseconds = 0;
CritRegRecPtr->TableLoadedOnce = false;

CritRegRecPtr->FileTime = CFE_TIME_ZERO_VALUE;
CritRegRecPtr->TimeOfLastUpdate = CFE_TIME_ZERO_VALUE;

CFE_ES_CopyToCDS(CFE_TBL_Global.CritRegHandle, CFE_TBL_Global.CritReg);
}
else
Expand Down
43 changes: 20 additions & 23 deletions modules/tbl/fsw/src/cfe_tbl_task.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,12 @@ typedef struct
*/
typedef struct
{
void * BufferPtr; /**< \brief Pointer to Load Buffer */
uint32 FileCreateTimeSecs; /**< \brief File creation time from last file loaded into table */
uint32 FileCreateTimeSubSecs; /**< \brief File creation time from last file loaded into table */
uint32 Crc; /**< \brief Last calculated CRC for this buffer's contents */
bool Taken; /**< \brief Flag indicating whether buffer is in use */
bool Validated; /**< \brief Flag indicating whether the buffer has been successfully validated */
char DataSource[OS_MAX_PATH_LEN]; /**< \brief Source of data put into buffer (filename or memory address) */
void * BufferPtr; /**< \brief Pointer to Load Buffer */
CFE_TIME_SysTime_t FileTime; /**< \brief Time stamp from last file loaded into table */
uint32 Crc; /**< \brief Last calculated CRC for this buffer's contents */
bool Taken; /**< \brief Flag indicating whether buffer is in use */
bool Validated; /**< \brief Flag indicating whether the buffer has been successfully validated */
char DataSource[OS_MAX_PATH_LEN]; /**< \brief Source of data put into buffer (filename or memory address) */
} CFE_TBL_LoadBuff_t;

/**
Expand Down Expand Up @@ -209,10 +208,9 @@ typedef struct
*/
typedef struct
{
CFE_ES_CDSHandle_t CDSHandle; /**< \brief Handle to Critical Data Store for Critical Tables */
uint32 FileCreateTimeSecs; /**< \brief File creation time from last file loaded into table */
uint32 FileCreateTimeSubSecs; /**< \brief File creation time from last file loaded into table */
CFE_TIME_SysTime_t TimeOfLastUpdate; /**< \brief Time when Table was last updated */
CFE_ES_CDSHandle_t CDSHandle; /**< \brief Handle to Critical Data Store for Critical Tables */
CFE_TIME_SysTime_t FileTime; /**< \brief File creation time from last file loaded into table */
CFE_TIME_SysTime_t TimeOfLastUpdate; /**< \brief Time when Table was last updated */
char LastFileLoaded[OS_MAX_PATH_LEN]; /**< \brief Filename of last file loaded into table */
char Name[CFE_TBL_MAX_FULL_NAME_LEN]; /**< \brief Processor specific table name */
bool TableLoadedOnce; /**< \brief Flag indicating whether table has been loaded once or not */
Expand Down Expand Up @@ -240,18 +238,17 @@ typedef struct
*/
typedef struct
{
CFE_ES_MemOffset_t Size; /**< \brief Size, in bytes, of Table */
CFE_TIME_SysTime_t TimeOfLastUpdate; /**< \brief Time when Table was last updated */
uint32 NumUsers; /**< \brief Number of applications that are sharing the table */
int32 LoadInProgress; /**< \brief Flag identifies inactive buffer and whether load in progress */
uint32 FileCreateTimeSecs; /**< \brief File creation time from last file loaded into table */
uint32 FileCreateTimeSubSecs; /**< \brief File creation time from last file loaded into table */
uint32 Crc; /**< \brief Most recent CRC computed by TBL Services on table contents */
bool ValidationFunc; /**< \brief Flag indicating whether table has an associated Validation func*/
bool TableLoadedOnce; /**< \brief Flag indicating whether table has been loaded once or not */
bool LoadPending; /**< \brief Flag indicating an inactive buffer is ready to be copied */
bool DumpOnly; /**< \brief Flag indicating Table is NOT to be loaded */
bool DoubleBuffered; /**< \brief Flag indicating Table has a dedicated inactive buffer */
CFE_ES_MemOffset_t Size; /**< \brief Size, in bytes, of Table */
CFE_TIME_SysTime_t TimeOfLastUpdate; /**< \brief Time when Table was last updated */
uint32 NumUsers; /**< \brief Number of applications that are sharing the table */
int32 LoadInProgress; /**< \brief Flag identifies inactive buffer and whether load in progress */
CFE_TIME_SysTime_t FileTime; /**< \brief File creation time from last file loaded into table */
uint32 Crc; /**< \brief Most recent CRC computed by TBL Services on table contents */
bool ValidationFunc; /**< \brief Flag indicating whether table has an associated Validation func*/
bool TableLoadedOnce; /**< \brief Flag indicating whether table has been loaded once or not */
bool LoadPending; /**< \brief Flag indicating an inactive buffer is ready to be copied */
bool DumpOnly; /**< \brief Flag indicating Table is NOT to be loaded */
bool DoubleBuffered; /**< \brief Flag indicating Table has a dedicated inactive buffer */
char Name[CFE_TBL_MAX_FULL_NAME_LEN]; /**< \brief Processor specific table name */
char LastFileLoaded[OS_MAX_PATH_LEN]; /**< \brief Filename of last file loaded into table */
char OwnerAppName[OS_MAX_API_NAME]; /**< \brief Application Name of App that Registered Table */
Expand Down
Loading
Loading