Skip to content

Commit

Permalink
Fix #1497, Use CFE_TIME_SysTime_t instead of indiv. sec/subsec members
Browse files Browse the repository at this point in the history
  • Loading branch information
thnkslprpt committed Apr 2, 2023
1 parent 7af467e commit ffb16f1
Show file tree
Hide file tree
Showing 9 changed files with 68 additions and 77 deletions.
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_FILECRTIME="$sc_$cpu_TBL_FileCrTime, $sc_$cpu_TBL_FCTSECONDS, $sc_$cpu_TBL_FCTSUBSECONDS" \
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 FileCreateTime; /**< \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: 2 additions & 7 deletions modules/tbl/eds/cfe_tbl.xml
Original file line number Diff line number Diff line change
Expand Up @@ -301,14 +301,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="FileCreateTime" 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_FILECRTIME
</LongDescription>
</Entry>
<Entry name="TableLoadedOnce" type="BASE_TYPES/uint8" shortDescription="Flag indicating whether table has been loaded once or not">
Expand Down
4 changes: 1 addition & 3 deletions modules/tbl/fsw/inc/cfe_tbl_msg.h
Original file line number Diff line number Diff line change
Expand Up @@ -804,9 +804,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 FileCreateTime; /**< \cfetlmmnemonic \TBL_FILECRTIME
\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
32 changes: 17 additions & 15 deletions modules/tbl/fsw/src/cfe_tbl_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -396,8 +396,9 @@ CFE_Status_t CFE_TBL_Register(CFE_TBL_Handle_t *TblHandlePtr, const char *Name,
strncpy(WorkingBufferPtr->DataSource, CritRegRecPtr->LastFileLoaded,
sizeof(WorkingBufferPtr->DataSource) - 1);
WorkingBufferPtr->DataSource[sizeof(WorkingBufferPtr->DataSource) - 1] = '\0';
WorkingBufferPtr->FileCreateTimeSecs = CritRegRecPtr->FileCreateTimeSecs;
WorkingBufferPtr->FileCreateTimeSubSecs = CritRegRecPtr->FileCreateTimeSubSecs;
WorkingBufferPtr->FileCreateTime.Seconds = CritRegRecPtr->FileCreateTime.Seconds;
WorkingBufferPtr->FileCreateTime.Subseconds =
CritRegRecPtr->FileCreateTime.Subseconds;
strncpy(RegRecPtr->LastFileLoaded, CritRegRecPtr->LastFileLoaded,
sizeof(RegRecPtr->LastFileLoaded) - 1);
RegRecPtr->LastFileLoaded[sizeof(RegRecPtr->LastFileLoaded) - 1] = '\0';
Expand Down Expand Up @@ -440,8 +441,8 @@ CFE_Status_t CFE_TBL_Register(CFE_TBL_Handle_t *TblHandlePtr, const char *Name,
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->FileCreateTime.Seconds = 0;
CritRegRecPtr->FileCreateTime.Subseconds = 0;
CritRegRecPtr->LastFileLoaded[0] = '\0';
CritRegRecPtr->TimeOfLastUpdate.Seconds = 0;
CritRegRecPtr->TimeOfLastUpdate.Subseconds = 0;
Expand Down Expand Up @@ -722,8 +723,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].FileCreateTime.Seconds = 0;
RegRecPtr->Buffers[0].FileCreateTime.Subseconds = 0;

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 @@ -781,8 +782,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->FileCreateTime.Seconds = 0;
WorkingBufferPtr->FileCreateTime.Subseconds = 0;

/* Compute the CRC on the specified table buffer */
WorkingBufferPtr->Crc =
Expand Down Expand Up @@ -1408,10 +1409,11 @@ 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->FileCreateTime.Seconds = RegRecPtr->Buffers[RegRecPtr->ActiveBufferIndex].FileCreateTime.Seconds;
TblInfoPtr->FileCreateTime.Subseconds =
RegRecPtr->Buffers[RegRecPtr->ActiveBufferIndex].FileCreateTime.Subseconds;
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 @@ -1461,9 +1463,9 @@ 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;
DumpTime = CFE_TIME_GetTime();
DumpCtrlPtr->DumpBufferPtr->FileCreateTime.Seconds = DumpTime.Seconds;
DumpCtrlPtr->DumpBufferPtr->FileCreateTime.Subseconds = DumpTime.Subseconds;

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

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

/* Compute the CRC on the specified table buffer */
WorkingBufferPtr->Crc =
Expand Down Expand Up @@ -984,10 +984,10 @@ 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].FileCreateTime.Seconds =
CFE_TBL_Global.LoadBuffs[RegRecPtr->LoadInProgress].FileCreateTime.Seconds;
RegRecPtr->Buffers[0].FileCreateTime.Subseconds =
CFE_TBL_Global.LoadBuffs[RegRecPtr->LoadInProgress].FileCreateTime.Subseconds;

/* Save the previously computed CRC into the new buffer */
RegRecPtr->Buffers[0].Crc = CFE_TBL_Global.LoadBuffs[RegRecPtr->LoadInProgress].Crc;
Expand Down Expand Up @@ -1329,9 +1329,10 @@ 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->FileCreateTime.Seconds =
RegRecPtr->Buffers[RegRecPtr->ActiveBufferIndex].FileCreateTime.Seconds;
CritRegRecPtr->FileCreateTime.Subseconds =
RegRecPtr->Buffers[RegRecPtr->ActiveBufferIndex].FileCreateTime.Subseconds;
strncpy(CritRegRecPtr->LastFileLoaded, RegRecPtr->LastFileLoaded,
sizeof(CritRegRecPtr->LastFileLoaded) - 1);
CritRegRecPtr->LastFileLoaded[sizeof(CritRegRecPtr->LastFileLoaded) - 1] = '\0';
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 FileCreateTime; /**< \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) */
} CFE_TBL_LoadBuff_t;

/*******************************************************************************/
Expand Down Expand Up @@ -204,10 +203,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 FileCreateTime; /**< \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 @@ -235,18 +233,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 FileCreateTime; /**< \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

0 comments on commit ffb16f1

Please sign in to comment.