Skip to content

Commit

Permalink
Fix nasa#1497, Use CFE_TIME_SysTime_t instead of indiv. sec/subsec me…
Browse files Browse the repository at this point in the history
…mbers
  • Loading branch information
thnkslprpt committed Oct 26, 2023
1 parent 0316672 commit ec60708
Show file tree
Hide file tree
Showing 17 changed files with 125 additions and 137 deletions.
41 changes: 20 additions & 21 deletions docs/cFE Application Developers Guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -3208,17 +3208,16 @@ The structure of the standard file header is as follows:
```c
typedef struct
{
uint32 ContentType; /* Identifies the content type (magic #=’cFE1’) */
uint32 SubType; /* Type of ContentType, if necessary */
uint32 Length; /* Length of this primary header */
uint32 SpacecraftID; /* Spacecraft that generated the file */
uint32 ProcessorID; /* Processor that generated the file */
uint32 ApplicationID; /* Application that generated the file */
uint32 ContentType; /* Identifies the content type (magic #=’cFE1’) */
uint32 SubType; /* Type of ContentType, if necessary */
uint32 Length; /* Length of this primary header */
uint32 SpacecraftID; /* Spacecraft that generated the file */
uint32 ProcessorID; /* Processor that generated the file */
uint32 ApplicationID; /* Application that generated the file */

uint32 TimeSeconds; /* File creation timestamp (seconds) */
uint32 TimeSubSeconds; /* File creation timestamp (sub-seconds) */
CFE_TIME_SysTime_t FileCreateTime /* File creation timestamp */

char Description[32]; /* File description */
char Description[32]; /* File description */
} CFE_FS_Header_t;
```

Expand All @@ -3244,8 +3243,8 @@ The SpacecraftID, ProcessorID and ApplicationID are all automatically
filled by cFE File Services routines when creating a cFE compliant file.
These fields help identify where and how the file was created.

The TimeSeconds and TimeSubSeconds elements contain the Spacecraft Time
when the header was created.
The FileCreateTime member contains the Spacecraft Time when the header
was created.

The Description field provides a brief ASCII description of the contents
of the file.
Expand All @@ -3260,22 +3259,22 @@ An example of this function is shown below:

The opposite version of this file API is the CFE_FS_WriteHeader
function. This function populates the given header data structure with
the SpacecraftID, ProcessorID, ApplicationID, TimeSeconds and
TimeSubsecs as obtained from the Executive and Time Services. The
Developer only needs to specify the SubType and Description fields.
the SpacecraftID, ProcessorID, ApplicationID, FileCreateTime.Seconds and
FileCreateTime.Subseconds as obtained from the Executive and Time Services.
The Developer only needs to specify the SubType and Description fields.
After the function successfully writes the standard header to the file,
the given header data structure contains all of the information and the
file pointer associated with the specified file is pointing to the first
byte past the standard header.

In addition to the functions for obtaining and writing the entire
header, there are two functions for manipulating the TimeSeconds and
TimeSubseconds fields of the header. The first of these is the
CFE_FS_UpdateHeaderTime function. This function takes the specified
file and sets the TimeSeconds and TimeSubsecs fields equal to the
current time as obtained from CFE_TIME_GetTime. The second function,
CFE_FS_SetHeaderTime, allows the Developer to set the create time in
the standard header equal to a time specified using the
header, there are two functions for manipulating the FileCreateTime.Seconds
and FileCreateTime.Subseconds fields of the header. The first of these is
the CFE_FS_UpdateHeaderTime function. This function takes the specified
file and sets the FileCreateTime.Seconds and FileCreateTime.Subseconds
fields equal to the current time as obtained from CFE_TIME_GetTime. The
second function, CFE_FS_SetHeaderTime, allows the Developer to set the
create time in the standard header equal to a time specified using the
CFE_TIME_SysTime_t data format. This function may be useful when time
tagging experiment data with the time the data was acquired rather than
the time the file was created.
Expand Down
5 changes: 2 additions & 3 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 All @@ -51,4 +50,4 @@ TBL_NAME=$sc_$cpu_TBL_Name[CFE_TB_MAX_FULL_NAME_LEN] \
TBL_LASTFILEUPD=$sc_$cpu_TBL_LastFileUpd[OS_MAX_PATH_LEN] \
TBL_OWNERAPP=$sc_$cpu_TBL_OwnerApp[OS_MAX_API_NAME] \
TBL_CRITICAL=$sc_$cpu_TBL_Spare3 \
TBL_SPARE4=$sc_$cpu_TBL_Spare4
TBL_SPARE4=$sc_$cpu_TBL_Spare4
7 changes: 4 additions & 3 deletions modules/cfe_testcase/src/fs_header_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,13 @@ void TestTimeStamp(void)
UtAssert_VOIDCALL(CFE_FS_InitHeader(&Header, TestDescription, CFE_FS_SubType_ES_ERLOG));
UtAssert_INT32_EQ(CFE_FS_WriteHeader(fd, &Header), sizeof(CFE_FS_Header_t));
UtAssert_INT32_EQ(CFE_FS_SetTimestamp(fd, NewTimestamp), CFE_SUCCESS);
UtAssert_INT32_EQ(OS_lseek(fd, 0, OS_SEEK_CUR), (offsetof(CFE_FS_Header_t, TimeSeconds) + sizeof(NewTimestamp)));
UtAssert_INT32_EQ(OS_lseek(fd, 0, OS_SEEK_CUR),
(offsetof(CFE_FS_Header_t, FileCreateTime.Seconds) + sizeof(NewTimestamp)));

UtAssert_INT32_EQ(CFE_FS_ReadHeader(&ReadHeader, fd), sizeof(CFE_FS_Header_t));

UtAssert_UINT32_EQ(0xFFFFFFFF, ReadHeader.TimeSeconds);
UtAssert_UINT32_EQ(0xFFFFFFFF, ReadHeader.TimeSubSeconds);
UtAssert_UINT32_EQ(0xFFFFFFFF, ReadHeader.FileCreateTime.Seconds);
UtAssert_UINT32_EQ(0xFFFFFFFF, ReadHeader.FileCreateTime.Subseconds);

CFE_Assert_STATUS_ERROR(CFE_FS_SetTimestamp(OS_OBJECT_ID_UNDEFINED, NewTimestamp));

Expand Down
3 changes: 1 addition & 2 deletions modules/core_api/eds/cfe_fs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,7 @@
<FixedValueEntry name="SpacecraftID" type="BASE_TYPES/uint32" shortDescription="Spacecraft that generated the file" fixedValue="${CFE_MISSION/SPACECRAFT_ID}" />
<Entry name="ProcessorID" type="BASE_TYPES/uint32" shortDescription="Processor that generated the file" />
<Entry name="ApplicationID" type="BASE_TYPES/uint32" shortDescription="Application that generated the file" />
<Entry name="TimeSeconds" type="BASE_TYPES/uint32" shortDescription="File creation timestamp (seconds)" />
<Entry name="TimeSubSeconds" type="BASE_TYPES/uint32" shortDescription="File creation timestamp (sub-seconds)" />
<Entry name="FileCreateTime" type="CFE_TIME/SysTime" shortDescription="File creation timestamp" />
<Entry name="Description" type="FileDescription" shortDescription="File description" />
</EntryList>
</ContainerDataType>
Expand Down
8 changes: 3 additions & 5 deletions modules/core_api/fsw/inc/cfe_fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,8 @@ void CFE_FS_InitHeader(CFE_FS_Header_t *Hdr, const char *Description, uint32 Sub
** -# \link #CFE_FS_Header_t::SpacecraftID \c SpacecraftID \endlink - Filled with the Spacecraft ID
** -# \link #CFE_FS_Header_t::ProcessorID \c ProcessorID \endlink - Filled with the Processor ID
** -# \link #CFE_FS_Header_t::ApplicationID \c ApplicationID \endlink - Filled with the Application ID
** -# \link #CFE_FS_Header_t::TimeSeconds \c TimeSeconds \endlink - Filled with the Time, in seconds, as obtained
** by #CFE_TIME_GetTime
** -# \link #CFE_FS_Header_t::TimeSubSeconds \c TimeSubSeconds \endlink - Filled with the Time, subseconds, as
** obtained by #CFE_TIME_GetTime
** -# \link #CFE_FS_Header_t::FileCreateTime \c FileCreateTime \endlink - Filled with the Time, in seconds,
** as obtained by #CFE_TIME_GetTime
**
** \par Assumptions, External Events, and Notes:
** -# The File has already been successfully opened using #OS_OpenCreate and
Expand Down Expand Up @@ -148,7 +146,7 @@ CFE_Status_t CFE_FS_WriteHeader(osal_id_t FileDes, CFE_FS_Header_t *Hdr);
** \brief Modifies the Time Stamp field in the Standard cFE File Header for the specified file
**
** \par Description
** This API will modify the \link #CFE_FS_Header_t::TimeSeconds timestamp \endlink found
** This API will modify the \link #CFE_FS_Header_t::FileCreateTime timestamp \endlink found
** in the Standard cFE File Header of the specified file. The timestamp will be replaced
** with the time specified by the caller.
**
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
6 changes: 3 additions & 3 deletions modules/fs/config/default_cfe_fs_filedef.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
#define CFE_FS_FILEHDR_H

#include "common_types.h"
#include "cfe_fs_interface_cfg.h" /* to define CFE_FS_HDR_DESC_MAX_LEN */
#include "cfe_fs_interface_cfg.h" /* to define CFE_FS_HDR_DESC_MAX_LEN */
#include "cfe_time_extern_typedefs.h" /* To get the definition of CFE_TIME_SysTime_t */

/**
* @brief File subtypes used within cFE
Expand Down Expand Up @@ -189,8 +190,7 @@ typedef struct CFE_FS_Header
uint32 ProcessorID; /**< \brief Processor that generated the file */
uint32 ApplicationID; /**< \brief Application that generated the file */

uint32 TimeSeconds; /**< \brief File creation timestamp (seconds) */
uint32 TimeSubSeconds; /**< \brief File creation timestamp (sub-seconds) */
CFE_TIME_SysTime_t FileCreateTime; /**< \brief File creation timestamp */

char Description[CFE_FS_HDR_DESC_MAX_LEN]; /**< \brief File description */
} CFE_FS_Header_t;
Expand Down
3 changes: 1 addition & 2 deletions modules/fs/eds/cfe_fs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,7 @@
<FixedValueEntry name="SpacecraftID" type="BASE_TYPES/uint32" shortDescription="Spacecraft that generated the file" fixedValue="${CFE_MISSION/SPACECRAFT_ID}" />
<Entry name="ProcessorID" type="BASE_TYPES/uint32" shortDescription="Processor that generated the file" />
<Entry name="ApplicationID" type="BASE_TYPES/uint32" shortDescription="Application that generated the file" />
<Entry name="TimeSeconds" type="BASE_TYPES/uint32" shortDescription="File creation timestamp (seconds)" />
<Entry name="TimeSubSeconds" type="BASE_TYPES/uint32" shortDescription="File creation timestamp (sub-seconds)" />
<Entry name="FileCreateTime" type="CFE_TIME/SysTime" shortDescription="File creation timestamp" />
<Entry name="Description" type="FileDescription" shortDescription="File description" />
</EntryList>
</ContainerDataType>
Expand Down
12 changes: 6 additions & 6 deletions modules/fs/fsw/src/cfe_fs_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,9 @@ CFE_Status_t CFE_FS_WriteHeader(osal_id_t FileDes, CFE_FS_Header_t *Hdr)
/*
** Fill in the timestamp fields...
*/
Time = CFE_TIME_GetTime();
Hdr->TimeSeconds = Time.Seconds;
Hdr->TimeSubSeconds = Time.Subseconds;
Time = CFE_TIME_GetTime();
Hdr->FileCreateTime.Seconds = Time.Seconds;
Hdr->FileCreateTime.Subseconds = Time.Subseconds;

/*
** Determine if this is a little endian processor
Expand Down Expand Up @@ -285,7 +285,7 @@ CFE_Status_t CFE_FS_SetTimestamp(osal_id_t FileDes, CFE_TIME_SysTime_t NewTimest
CFE_TIME_SysTime_t OutTimestamp = NewTimestamp;
int32 FileOffset = 0;

FileOffset = ((char *)&TempHdr.TimeSeconds - (char *)&TempHdr.ContentType);
FileOffset = ((char *)&TempHdr.FileCreateTime.Seconds - (char *)&TempHdr.ContentType);
OsStatus = OS_lseek(FileDes, FileOffset, OS_SEEK_SET);

if (OsStatus == FileOffset)
Expand Down Expand Up @@ -338,8 +338,8 @@ void CFE_FS_ByteSwapCFEHeader(CFE_FS_Header_t *Hdr)
CFE_FS_ByteSwapUint32(&Hdr->SpacecraftID);
CFE_FS_ByteSwapUint32(&Hdr->ProcessorID);
CFE_FS_ByteSwapUint32(&Hdr->ApplicationID);
CFE_FS_ByteSwapUint32(&Hdr->TimeSeconds);
CFE_FS_ByteSwapUint32(&Hdr->TimeSubSeconds);
CFE_FS_ByteSwapUint32(&Hdr->FileCreateTime.Seconds);
CFE_FS_ByteSwapUint32(&Hdr->FileCreateTime.Subseconds);
}

/*----------------------------------------------------------------
Expand Down
20 changes: 10 additions & 10 deletions modules/fs/ut-coverage/fs_UT.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,14 +195,14 @@ void Test_CFE_FS_ByteSwapCFEHeader(void)
UtPrintf("Begin Test Byte Swap cFE Header");

UT_InitData();
Hdr.ContentType = 0x11223344;
Hdr.SubType = 0x22334455;
Hdr.Length = 0x33445566;
Hdr.SpacecraftID = 0x44556677;
Hdr.ProcessorID = 0x55667788;
Hdr.ApplicationID = 0x66778899;
Hdr.TimeSeconds = 0x778899aa;
Hdr.TimeSubSeconds = 0x8899aabb;
Hdr.ContentType = 0x11223344;
Hdr.SubType = 0x22334455;
Hdr.Length = 0x33445566;
Hdr.SpacecraftID = 0x44556677;
Hdr.ProcessorID = 0x55667788;
Hdr.ApplicationID = 0x66778899;
Hdr.FileCreateTime.Seconds = 0x778899aa;
Hdr.FileCreateTime.Subseconds = 0x8899aabb;

/* Test byte-swapping the header values */
CFE_FS_ByteSwapCFEHeader(&Hdr);
Expand All @@ -213,8 +213,8 @@ void Test_CFE_FS_ByteSwapCFEHeader(void)
UtAssert_UINT32_EQ(Hdr.SpacecraftID, 0x77665544);
UtAssert_UINT32_EQ(Hdr.ProcessorID, 0x88776655);
UtAssert_UINT32_EQ(Hdr.ApplicationID, 0x99887766);
UtAssert_UINT32_EQ(Hdr.TimeSeconds, 0xaa998877);
UtAssert_UINT32_EQ(Hdr.TimeSubSeconds, 0xbbaa9988);
UtAssert_UINT32_EQ(Hdr.FileCreateTime.Seconds, 0xaa998877);
UtAssert_UINT32_EQ(Hdr.FileCreateTime.Subseconds, 0xbbaa9988);
}

/*
Expand Down
6 changes: 2 additions & 4 deletions modules/tbl/config/default_cfe_tbl_msgdefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -251,10 +251,8 @@ 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
\brief File creation time from last file loaded into table */
CFE_TIME_SysTime_t FileCreateTime; /**< \cfetlmmnemonic \TBL_FILECRTIME
\brief File creation time from last file loaded */
bool TableLoadedOnce; /**< \cfetlmmnemonic \TBL_LOADEDONCE
\brief Flag indicating whether table has been loaded once or not */
bool LoadPending; /**< \cfetlmmnemonic \TBL_UPDATEPNDNG
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 @@ -302,14 +302,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
Loading

0 comments on commit ec60708

Please sign in to comment.