Skip to content

Commit 993d9cd

Browse files
committed
Merge pull request #2544 from jphickey:fix-2543-tbl-time
Fix #2543, consistent TIME values for TBL structures
2 parents 100acae + 32cc4d0 commit 993d9cd

File tree

10 files changed

+64
-89
lines changed

10 files changed

+64
-89
lines changed

docs/src/mnem_maps/cfe_tbl_tlm_mnem_map

+1-2
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ TBL_ACTBUFADD=$sc_$cpu_TBL_ActBufAdd \
4141
TBL_IACTBUFADD=$sc_$cpu_TBL_IActBufAdd \
4242
TBL_VALFUNCPTR=$sc_$cpu_TBL_ValFuncPtr \
4343
TBL_TIMELASTUPD="$sc_$cpu_TBL_TimeLastUpd, $sc_$cpu_TBL_TLUSECONDS, $sc_$cpu_TBL_TLUSUBSECONDS" \
44-
TBL_FILECSECONDS=$sc_$cpu_TBL_FILECSECONDS \
45-
TBL_FILECSUBSECONDS=$sc_$cpu_TBL_FILECSUBSECONDS \
44+
TBL_FILECTIME=$sc_$cpu_TBL_FILECTIME \
4645
TBL_LOADEDONCE=$sc_$cpu_TBL_LoadedOnce \
4746
TBL_UPDATEPNDNG=$sc_$cpu_TBL_UpdatePndng \
4847
TBL_DUMPONLY=$sc_$cpu_TBL_DumpOnly \

modules/core_api/fsw/inc/cfe_tbl_api_typedefs.h

+3-4
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,9 @@ typedef enum CFE_TBL_SrcEnum
108108
/** \brief Table Info */
109109
typedef struct CFE_TBL_Info
110110
{
111-
size_t Size; /**< \brief Size, in bytes, of Table */
112-
uint32 NumUsers; /**< \brief Number of Apps with access to the table */
113-
uint32 FileCreateTimeSecs; /**< \brief File creation time from last file loaded into table */
114-
uint32 FileCreateTimeSubSecs; /**< \brief File creation time from last file loaded into table */
111+
size_t Size; /**< \brief Size, in bytes, of Table */
112+
uint32 NumUsers; /**< \brief Number of Apps with access to the table */
113+
CFE_TIME_SysTime_t FileTime; /**< \brief File creation time from last file loaded into table */
115114
uint32 Crc; /**< \brief Most recently calculated CRC by TBL services on table contents */
116115
CFE_TIME_SysTime_t TimeOfLastUpdate; /**< \brief Time when Table was last updated */
117116
bool TableLoadedOnce; /**< \brief Flag indicating whether table has been loaded once or not */

modules/core_api/fsw/inc/cfe_time_api_typedefs.h

+9
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,15 @@
4444
#define CFE_TIME_PRINTED_STRING_SIZE \
4545
24 /**< \brief Required size of buffer to be passed into #CFE_TIME_Print (includes null terminator) */
4646

47+
/**
48+
* A general-purpose initializer for CFE_TIME_SysTime_t values.
49+
*
50+
* Represents "time zero" in the CFE_TIME_SysTime_t domain. This
51+
* can be used as a general purpose initializer for instantiations
52+
* of the CFE_TIME_SysTime_t type.
53+
*/
54+
#define CFE_TIME_ZERO_VALUE ((CFE_TIME_SysTime_t) {0, 0})
55+
4756
/*****************************************************************************/
4857
/*
4958
** Type Definitions

modules/tbl/config/default_cfe_tbl_msgdefs.h

+1-3
Original file line numberDiff line numberDiff line change
@@ -251,9 +251,7 @@ typedef struct CFE_TBL_TblRegPacket_Payload
251251
\brief Ptr to Owner App's function that validates tbl contents */
252252
CFE_TIME_SysTime_t TimeOfLastUpdate; /**< \cfetlmmnemonic \TBL_TIMELASTUPD
253253
\brief Time when Table was last updated */
254-
uint32 FileCreateTimeSecs; /**< \cfetlmmnemonic \TBL_FILECSECONDS
255-
\brief File creation time from last file loaded into table */
256-
uint32 FileCreateTimeSubSecs; /**< \cfetlmmnemonic \TBL_FILECSUBSECONDS
254+
CFE_TIME_SysTime_t FileTime; /**< \cfetlmmnemonic \TBL_FILECTIME
257255
\brief File creation time from last file loaded into table */
258256
bool TableLoadedOnce; /**< \cfetlmmnemonic \TBL_LOADEDONCE
259257
\brief Flag indicating whether table has been loaded once or not */

modules/tbl/eds/cfe_tbl.xml

+2-7
Original file line numberDiff line numberDiff line change
@@ -292,14 +292,9 @@
292292
\cfetlmmnemonic \TBL_TIMELASTUPD
293293
</LongDescription>
294294
</Entry>
295-
<Entry name="FileCreateTimeSecs" type="BASE_TYPES/uint32" shortDescription="File creation time from last file loaded into table">
295+
<Entry name="FileTime" type="CFE_TIME/SysTime" shortDescription="File creation time from last file loaded into table">
296296
<LongDescription>
297-
\cfetlmmnemonic \TBL_FILECSECONDS
298-
</LongDescription>
299-
</Entry>
300-
<Entry name="FileCreateTimeSubSecs" type="BASE_TYPES/uint32" shortDescription="File creation time from last file loaded into table">
301-
<LongDescription>
302-
\cfetlmmnemonic \TBL_FILECSUBSECONDS
297+
\cfetlmmnemonic \TBL_FILECTIME
303298
</LongDescription>
304299
</Entry>
305300
<Entry name="TableLoadedOnce" type="BASE_TYPES/uint8" shortDescription="Flag indicating whether table has been loaded once or not">

modules/tbl/fsw/src/cfe_tbl_api.c

+8-12
Original file line numberDiff line numberDiff line change
@@ -425,8 +425,8 @@ CFE_Status_t CFE_TBL_Load(CFE_TBL_Handle_t TblHandle, CFE_TBL_SrcEnum_t SrcType,
425425

426426
snprintf(RegRecPtr->Buffers[0].DataSource, sizeof(RegRecPtr->Buffers[0].DataSource), "Addr 0x%08lX",
427427
(unsigned long)SrcDataPtr);
428-
RegRecPtr->Buffers[0].FileCreateTimeSecs = 0;
429-
RegRecPtr->Buffers[0].FileCreateTimeSubSecs = 0;
428+
429+
RegRecPtr->Buffers[0].FileTime = CFE_TIME_ZERO_VALUE;
430430

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

485485
snprintf(WorkingBufferPtr->DataSource, sizeof(WorkingBufferPtr->DataSource), "Addr 0x%08lX",
486486
(unsigned long)SrcDataPtr);
487-
WorkingBufferPtr->FileCreateTimeSecs = 0;
488-
WorkingBufferPtr->FileCreateTimeSubSecs = 0;
487+
488+
WorkingBufferPtr->FileTime = CFE_TIME_ZERO_VALUE;
489489

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

11131113
/* Return information on last load and update */
1114-
TblInfoPtr->TimeOfLastUpdate = RegRecPtr->TimeOfLastUpdate;
1115-
TblInfoPtr->FileCreateTimeSecs = RegRecPtr->Buffers[RegRecPtr->ActiveBufferIndex].FileCreateTimeSecs;
1116-
TblInfoPtr->FileCreateTimeSubSecs = RegRecPtr->Buffers[RegRecPtr->ActiveBufferIndex].FileCreateTimeSubSecs;
1117-
TblInfoPtr->Crc = RegRecPtr->Buffers[RegRecPtr->ActiveBufferIndex].Crc;
1114+
TblInfoPtr->TimeOfLastUpdate = RegRecPtr->TimeOfLastUpdate;
1115+
TblInfoPtr->FileTime = RegRecPtr->Buffers[RegRecPtr->ActiveBufferIndex].FileTime;
1116+
TblInfoPtr->Crc = RegRecPtr->Buffers[RegRecPtr->ActiveBufferIndex].Crc;
11181117
strncpy(TblInfoPtr->LastFileLoaded, RegRecPtr->LastFileLoaded, sizeof(TblInfoPtr->LastFileLoaded) - 1);
11191118
TblInfoPtr->LastFileLoaded[sizeof(TblInfoPtr->LastFileLoaded) - 1] = 0;
11201119

@@ -1148,7 +1147,6 @@ CFE_Status_t CFE_TBL_DumpToBuffer(CFE_TBL_Handle_t TblHandle)
11481147
int32 Status;
11491148
CFE_TBL_RegistryRec_t *RegRecPtr = NULL;
11501149
CFE_TBL_DumpControl_t *DumpCtrlPtr = NULL;
1151-
CFE_TIME_SysTime_t DumpTime;
11521150
CFE_ES_AppId_t ThisAppId;
11531151

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

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

11851181
/* Disassociate the dump request from the table */
11861182
RegRecPtr->DumpControlIndex = CFE_TBL_NO_DUMP_PENDING;

modules/tbl/fsw/src/cfe_tbl_internal.c

+10-18
Original file line numberDiff line numberDiff line change
@@ -562,8 +562,8 @@ int32 CFE_TBL_LoadFromFile(const char *AppName, CFE_TBL_LoadBuff_t *WorkingBuffe
562562
WorkingBufferPtr->DataSource[sizeof(WorkingBufferPtr->DataSource) - 1] = '\0';
563563

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

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

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

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

1293-
WorkingBufferPtr->FileCreateTimeSecs = CritRegRecPtr->FileCreateTimeSecs;
1294-
WorkingBufferPtr->FileCreateTimeSubSecs = CritRegRecPtr->FileCreateTimeSubSecs;
1288+
WorkingBufferPtr->FileTime = CritRegRecPtr->FileTime;
12951289

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

1300-
RegRecPtr->TimeOfLastUpdate.Seconds = CritRegRecPtr->TimeOfLastUpdate.Seconds;
1301-
RegRecPtr->TimeOfLastUpdate.Subseconds = CritRegRecPtr->TimeOfLastUpdate.Subseconds;
1302-
RegRecPtr->TableLoadedOnce = CritRegRecPtr->TableLoadedOnce;
1294+
RegRecPtr->TimeOfLastUpdate = CritRegRecPtr->TimeOfLastUpdate;
1295+
RegRecPtr->TableLoadedOnce = CritRegRecPtr->TableLoadedOnce;
13031296

13041297
/* Compute the CRC on the specified table buffer */
13051298
WorkingBufferPtr->Crc =
@@ -1344,13 +1337,12 @@ void CFE_TBL_RegisterWithCriticalTableRegistry(CFE_TBL_CritRegRec_t *CritRegRecP
13441337
CritRegRecPtr->CDSHandle = RegRecPtr->CDSHandle;
13451338
strncpy(CritRegRecPtr->Name, TblName, sizeof(CritRegRecPtr->Name) - 1);
13461339
CritRegRecPtr->Name[sizeof(CritRegRecPtr->Name) - 1] = '\0';
1347-
CritRegRecPtr->FileCreateTimeSecs = 0;
1348-
CritRegRecPtr->FileCreateTimeSubSecs = 0;
13491340
CritRegRecPtr->LastFileLoaded[0] = '\0';
1350-
CritRegRecPtr->TimeOfLastUpdate.Seconds = 0;
1351-
CritRegRecPtr->TimeOfLastUpdate.Subseconds = 0;
13521341
CritRegRecPtr->TableLoadedOnce = false;
13531342

1343+
CritRegRecPtr->FileTime = CFE_TIME_ZERO_VALUE;
1344+
CritRegRecPtr->TimeOfLastUpdate = CFE_TIME_ZERO_VALUE;
1345+
13541346
CFE_ES_CopyToCDS(CFE_TBL_Global.CritRegHandle, CFE_TBL_Global.CritReg);
13551347
}
13561348
else

modules/tbl/fsw/src/cfe_tbl_task.h

+20-23
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,12 @@ typedef struct
132132
*/
133133
typedef struct
134134
{
135-
void * BufferPtr; /**< \brief Pointer to Load Buffer */
136-
uint32 FileCreateTimeSecs; /**< \brief File creation time from last file loaded into table */
137-
uint32 FileCreateTimeSubSecs; /**< \brief File creation time from last file loaded into table */
138-
uint32 Crc; /**< \brief Last calculated CRC for this buffer's contents */
139-
bool Taken; /**< \brief Flag indicating whether buffer is in use */
140-
bool Validated; /**< \brief Flag indicating whether the buffer has been successfully validated */
141-
char DataSource[OS_MAX_PATH_LEN]; /**< \brief Source of data put into buffer (filename or memory address) */
135+
void * BufferPtr; /**< \brief Pointer to Load Buffer */
136+
CFE_TIME_SysTime_t FileTime; /**< \brief Time stamp from last file loaded into table */
137+
uint32 Crc; /**< \brief Last calculated CRC for this buffer's contents */
138+
bool Taken; /**< \brief Flag indicating whether buffer is in use */
139+
bool Validated; /**< \brief Flag indicating whether the buffer has been successfully validated */
140+
char DataSource[OS_MAX_PATH_LEN]; /**< \brief Source of data put into buffer (filename or memory address) */
142141
} CFE_TBL_LoadBuff_t;
143142

144143
/**
@@ -209,10 +208,9 @@ typedef struct
209208
*/
210209
typedef struct
211210
{
212-
CFE_ES_CDSHandle_t CDSHandle; /**< \brief Handle to Critical Data Store for Critical Tables */
213-
uint32 FileCreateTimeSecs; /**< \brief File creation time from last file loaded into table */
214-
uint32 FileCreateTimeSubSecs; /**< \brief File creation time from last file loaded into table */
215-
CFE_TIME_SysTime_t TimeOfLastUpdate; /**< \brief Time when Table was last updated */
211+
CFE_ES_CDSHandle_t CDSHandle; /**< \brief Handle to Critical Data Store for Critical Tables */
212+
CFE_TIME_SysTime_t FileTime; /**< \brief File creation time from last file loaded into table */
213+
CFE_TIME_SysTime_t TimeOfLastUpdate; /**< \brief Time when Table was last updated */
216214
char LastFileLoaded[OS_MAX_PATH_LEN]; /**< \brief Filename of last file loaded into table */
217215
char Name[CFE_TBL_MAX_FULL_NAME_LEN]; /**< \brief Processor specific table name */
218216
bool TableLoadedOnce; /**< \brief Flag indicating whether table has been loaded once or not */
@@ -240,18 +238,17 @@ typedef struct
240238
*/
241239
typedef struct
242240
{
243-
CFE_ES_MemOffset_t Size; /**< \brief Size, in bytes, of Table */
244-
CFE_TIME_SysTime_t TimeOfLastUpdate; /**< \brief Time when Table was last updated */
245-
uint32 NumUsers; /**< \brief Number of applications that are sharing the table */
246-
int32 LoadInProgress; /**< \brief Flag identifies inactive buffer and whether load in progress */
247-
uint32 FileCreateTimeSecs; /**< \brief File creation time from last file loaded into table */
248-
uint32 FileCreateTimeSubSecs; /**< \brief File creation time from last file loaded into table */
249-
uint32 Crc; /**< \brief Most recent CRC computed by TBL Services on table contents */
250-
bool ValidationFunc; /**< \brief Flag indicating whether table has an associated Validation func*/
251-
bool TableLoadedOnce; /**< \brief Flag indicating whether table has been loaded once or not */
252-
bool LoadPending; /**< \brief Flag indicating an inactive buffer is ready to be copied */
253-
bool DumpOnly; /**< \brief Flag indicating Table is NOT to be loaded */
254-
bool DoubleBuffered; /**< \brief Flag indicating Table has a dedicated inactive buffer */
241+
CFE_ES_MemOffset_t Size; /**< \brief Size, in bytes, of Table */
242+
CFE_TIME_SysTime_t TimeOfLastUpdate; /**< \brief Time when Table was last updated */
243+
uint32 NumUsers; /**< \brief Number of applications that are sharing the table */
244+
int32 LoadInProgress; /**< \brief Flag identifies inactive buffer and whether load in progress */
245+
CFE_TIME_SysTime_t FileTime; /**< \brief File creation time from last file loaded into table */
246+
uint32 Crc; /**< \brief Most recent CRC computed by TBL Services on table contents */
247+
bool ValidationFunc; /**< \brief Flag indicating whether table has an associated Validation func*/
248+
bool TableLoadedOnce; /**< \brief Flag indicating whether table has been loaded once or not */
249+
bool LoadPending; /**< \brief Flag indicating an inactive buffer is ready to be copied */
250+
bool DumpOnly; /**< \brief Flag indicating Table is NOT to be loaded */
251+
bool DoubleBuffered; /**< \brief Flag indicating Table has a dedicated inactive buffer */
255252
char Name[CFE_TBL_MAX_FULL_NAME_LEN]; /**< \brief Processor specific table name */
256253
char LastFileLoaded[OS_MAX_PATH_LEN]; /**< \brief Filename of last file loaded into table */
257254
char OwnerAppName[OS_MAX_API_NAME]; /**< \brief Application Name of App that Registered Table */

0 commit comments

Comments
 (0)