Skip to content

Commit

Permalink
Post CCB review changes, Add new title for MOVEFILES variable
Browse files Browse the repository at this point in the history
  • Loading branch information
jdfiguer authored and jdfiguer committed Mar 20, 2024
1 parent 621a2fa commit 27e9171
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 48 deletions.
8 changes: 3 additions & 5 deletions docs/dox_src/cfs_ds.dox
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,10 @@
the platform.

<h2>Move File Capability</h2>
If the DS_MOVE_FILES configuration parameter is set to a non-empty string, the telemetry
If the MoveFilesDestDir global variable is set to a non-empty string at app initialization, the telemetry
database, Destination File table load images and the File Table display page
require changes. The Destination File Table rdl file uses the DS_MOVE_FILES
definition in the ds_platform_cfg.h file. However, in order to get the
required parameter included in telemetry, this configuration parameter must be
set to 1 rather than TRUE. The table images must include this parameter in
require changes. The Destination File Table rdl file uses the DS_MOVEFILES_DESTDIR
definition in the ds_platform_cfg.h file. The table images must include this parameter in
order to load successfully and the display page must be modified to display
this parameter.
**/
Expand Down
34 changes: 17 additions & 17 deletions fsw/inc/ds_platform_cfg.h
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,22 @@
*/
#define DS_FILE_HEADER_TYPE 1

/**
* \brief Application Per Packet Pipe Limit
*
* \par Description:
* This parameter defines the per packet pipe limit. This is
* the max number of packets with the same Message ID that may
* be in the DS input pipe at any one time. This value should
* be large enough to accommodate a burst of packets (usually
* event packets) plus a suitable margin.
*
* \par Limits:
* The value must be greater than zero and cannot exceed the
* definition of #DS_APP_PIPE_DEPTH.
*/
#define DS_PER_PACKET_PIPE_LIMIT 45

/**
* \brief Move Files to Downlink Directory After Close Selection
*
Expand All @@ -444,23 +460,7 @@
* non-empty string = add move pathname field to Destination File Table
* empty string = do not add move pathname to Destination File Table
*/
#define DS_MOVE_FILES "Move to downlink directory"

/**
* \brief Application Per Packet Pipe Limit
*
* \par Description:
* This parameter defines the per packet pipe limit. This is
* the max number of packets with the same Message ID that may
* be in the DS input pipe at any one time. This value should
* be large enough to accommodate a burst of packets (usually
* event packets) plus a suitable margin.
*
* \par Limits:
* The value must be greater than zero and cannot exceed the
* definition of #DS_APP_PIPE_DEPTH.
*/
#define DS_PER_PACKET_PIPE_LIMIT 45
#define DS_MOVEFILES_DESTDIR "Move to downlink directory"

/**\}*/

Expand Down
1 change: 1 addition & 0 deletions fsw/src/ds_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ CFE_Status_t DS_AppInitialize(void)
memset(&DS_AppData, 0, sizeof(DS_AppData));

DS_AppData.AppEnableState = DS_DEF_ENABLE_STATE;
strncpy(DS_AppData.MoveFilesDestDir, DS_MOVEFILES_DESTDIR, sizeof(DS_AppData.MoveFilesDestDir));

/*
** Mark files as closed
Expand Down
7 changes: 7 additions & 0 deletions fsw/src/ds_app.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@
#define DS_SB_TIMEOUT 1000
#define DS_SECS_PER_TIMEOUT (DS_SB_TIMEOUT / 1000)

/**
* \brief Array size for DS file move trigger
*/
#define MOVE_FILES_TRIGGER_SIZE 64

/**
* \brief Current state of destination files
*/
Expand Down Expand Up @@ -104,6 +109,8 @@ typedef struct

DS_HashLink_t HashLinks[DS_PACKETS_IN_FILTER_TABLE]; /**< \brief Hash table linked list elements */
DS_HashLink_t *HashTable[DS_HASH_TABLE_ENTRIES]; /**< \brief Each hash table entry is a linked list */

char MoveFilesDestDir[MOVE_FILES_TRIGGER_SIZE]; /**< \brief Triggers file move to downlink directory if non-empty, disables otherwise */
} DS_AppData_t;

/** \brief DS global data structure reference */
Expand Down
2 changes: 1 addition & 1 deletion fsw/src/ds_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -811,7 +811,7 @@ void DS_FileCloseDest(int32 FileIndex)
*/
OS_close(FileStatus->FileHandle);

if (strlen(DS_MOVE_FILES) > 0)
if (strlen(DS_AppData.MoveFilesDestDir) > 0)
{
/*
** Move file only if table has a downlink directory name...
Expand Down
8 changes: 4 additions & 4 deletions fsw/src/ds_verify.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,6 @@
#error DS_FILE_HEADER_TYPE must be 0 or 1!
#endif

#ifndef DS_MOVE_FILES
#error "DS_MOVE_FILES must be defined!"
#endif

#ifndef DS_PER_PACKET_PIPE_LIMIT
#error DS_PER_PACKET_PIPE_LIMIT must be defined!
#elif (DS_PER_PACKET_PIPE_LIMIT < 1)
Expand All @@ -202,4 +198,8 @@
#error DS_PER_PACKET_PIPE_LIMIT cannot be greater than DS_APP_PIPE_DEPTH!
#endif

#ifndef DS_MOVEFILES_DESTDIR
#error "DS_MOVEFILES_DESTDIR must be defined!"
#endif

#endif
2 changes: 1 addition & 1 deletion unit-test/ds_cmds_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -1276,7 +1276,7 @@ void DS_CloseAllCmd_Test_Nominal(void)
DS_AppData.FileStatus[i].FileHandle = OS_OBJECT_ID_UNDEFINED;
}

if (strlen(DS_MOVE_FILES) > 0)
if (strlen(DS_AppData.MoveFilesDestDir) > 0)
{
strncpy(DS_AppData.DestFileTblPtr->File[0].Movename, "", DS_PATHNAME_BUFSIZE);
}
Expand Down
64 changes: 44 additions & 20 deletions unit-test/ds_file_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ void DS_FileSetupWrite_Test_MaxFileSizeExceeded(void)
strncpy(DS_AppData.FileStatus[FileIndex].FileName, "directory1/",
sizeof(DS_AppData.FileStatus[FileIndex].FileName));

if (strlen(DS_MOVE_FILES) > 0)
if (strlen(DS_AppData.MoveFilesDestDir) > 0)
{
strncpy(DS_AppData.DestFileTblPtr->File[FileIndex].Movename, "directory2/movename/",
sizeof(DS_AppData.DestFileTblPtr->File[FileIndex].Movename));
Expand Down Expand Up @@ -572,7 +572,7 @@ void DS_FileCreateDest_Test_ClosedFileHandle(void)
DS_AppData.DestFileTblPtr->File[FileIndex].FileNameType = DS_BY_COUNT;
DS_AppData.FileStatus[FileIndex].FileCount = 1;

if (strlen(DS_MOVE_FILES) > 0)
if (strlen(DS_AppData.MoveFilesDestDir) > 0)
{
DS_AppData.DestFileTblPtr->File[FileIndex].Movename[0] = '\0';
}
Expand Down Expand Up @@ -897,7 +897,8 @@ void DS_FileUpdateHeader_Test_PlatformConfigCFE_SeekError(void)

void DS_FileCloseDest_Test_PlatformConfigMoveFiles_Nominal(void)
{
int32 FileIndex = 0;
int32 FileIndex = 0;
const char MoveFilesTrigger[] = "Move to downlink directory";

/* Set up the handle */
OS_OpenCreate(&DS_AppData.FileStatus[FileIndex].FileHandle, NULL, 0, 0);
Expand All @@ -906,6 +907,7 @@ void DS_FileCloseDest_Test_PlatformConfigMoveFiles_Nominal(void)
sizeof(DS_AppData.FileStatus[FileIndex].FileName));
strncpy(DS_AppData.DestFileTblPtr->File[FileIndex].Movename, "directory2/movename/",
sizeof(DS_AppData.DestFileTblPtr->File[FileIndex].Movename));
strncpy(DS_AppData.MoveFilesDestDir, MoveFilesTrigger, sizeof(DS_AppData.MoveFilesDestDir));

/* Execute the function being tested */
UtAssert_VOIDCALL(DS_FileCloseDest(FileIndex));
Expand All @@ -920,7 +922,9 @@ void DS_FileCloseDest_Test_PlatformConfigMoveFiles_Nominal(void)

void DS_FileCloseDest_Test_PlatformConfigMoveFiles_MoveError(void)
{
int32 FileIndex = 0;
int32 FileIndex = 0;
const char MoveFilesTrigger[] = "Move to downlink directory";
strncpy(DS_AppData.MoveFilesDestDir, MoveFilesTrigger, sizeof(DS_AppData.MoveFilesDestDir));

/* Set up the handle */
OS_OpenCreate(&DS_AppData.FileStatus[FileIndex].FileHandle, NULL, 0, 0);
Expand All @@ -946,8 +950,9 @@ void DS_FileCloseDest_Test_PlatformConfigMoveFiles_MoveError(void)

void DS_FileCloseDest_Test_PlatformConfigMoveFiles_FilenameTooLarge(void)
{
int32 FileIndex = 0;
const char DirName[] = "directory1/";
int32 FileIndex = 0;
const char DirName[] = "directory1/";
const char MoveFilesTrigger[] = "Move to downlink directory";

/* Set up the handle */
OS_OpenCreate(&DS_AppData.FileStatus[FileIndex].FileHandle, NULL, 0, 0);
Expand All @@ -958,6 +963,7 @@ void DS_FileCloseDest_Test_PlatformConfigMoveFiles_FilenameTooLarge(void)
DS_AppData.FileStatus[FileIndex].FileName[DS_TOTAL_FNAME_BUFSIZE - 1] = '\0';
strncpy(DS_AppData.DestFileTblPtr->File[FileIndex].Movename, "directory2/movename/",
sizeof(DS_AppData.DestFileTblPtr->File[FileIndex].Movename));
strncpy(DS_AppData.MoveFilesDestDir, MoveFilesTrigger, sizeof(DS_AppData.MoveFilesDestDir));

/* Execute the function being tested */
UtAssert_VOIDCALL(DS_FileCloseDest(FileIndex));
Expand All @@ -972,13 +978,15 @@ void DS_FileCloseDest_Test_PlatformConfigMoveFiles_FilenameTooLarge(void)

void DS_FileCloseDest_Test_PlatformConfigMoveFiles_FilenameNull(void)
{
int32 FileIndex = 0;
int32 FileIndex = 0;
const char MoveFilesTrigger[] = "Move to downlink directory";

/* Set up the handle */
OS_OpenCreate(&DS_AppData.FileStatus[FileIndex].FileHandle, NULL, 0, 0);

strncpy(DS_AppData.DestFileTblPtr->File[FileIndex].Movename, "directory2/movename",
sizeof(DS_AppData.DestFileTblPtr->File[FileIndex].Movename));
strncpy(DS_AppData.MoveFilesDestDir, MoveFilesTrigger, sizeof(DS_AppData.MoveFilesDestDir));

/* Execute the function being tested */
UtAssert_VOIDCALL(DS_FileCloseDest(FileIndex));
Expand All @@ -993,12 +1001,33 @@ void DS_FileCloseDest_Test_PlatformConfigMoveFiles_FilenameNull(void)
UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1);
}

void DS_FileCloseDest_Test_MoveFilesFalse(void)
void DS_FileCloseDest_Test_PlatformConfigMoveFiles_MovenameNull(void)
{
int32 FileIndex = 0;
int32 FileIndex = 0;
const char MoveFilesTrigger[] = "Move to downlink directory";

/* Set up the handle */
OS_OpenCreate(&DS_AppData.FileStatus[FileIndex].FileHandle, NULL, 0, 0);

strncpy(DS_AppData.DestFileTblPtr->File[FileIndex].Movename, "",
sizeof(DS_AppData.DestFileTblPtr->File[FileIndex].Movename));
strncpy(DS_AppData.MoveFilesDestDir, MoveFilesTrigger, sizeof(DS_AppData.MoveFilesDestDir));

/* Execute the function being tested */
UtAssert_VOIDCALL(DS_FileCloseDest(FileIndex));

/* Verify results */
UtAssert_STUB_COUNT(CFE_SB_MessageStringGet, 0);
}

void DS_FileCloseDest_Test_PlatformConfigMoveFiles_EmptyMoveFilesTrigger(void)
{
int32 FileIndex = 0;
const char MoveFilesTrigger[] = "";

/* Set up the handle */
OS_OpenCreate(&DS_AppData.FileStatus[FileIndex].FileHandle, NULL, 0, 0);
strncpy(DS_AppData.MoveFilesDestDir, MoveFilesTrigger, sizeof(DS_AppData.MoveFilesDestDir));

/* Execute the function being tested */
UtAssert_VOIDCALL(DS_FileCloseDest(FileIndex));
Expand Down Expand Up @@ -1304,17 +1333,12 @@ void UtTest_Setup(void)
UT_DS_TEST_ADD(DS_FileUpdateHeader_Test_PlatformConfigCFE_SeekError);
}

if (strlen(DS_MOVE_FILES) > 0)
{
UT_DS_TEST_ADD(DS_FileCloseDest_Test_PlatformConfigMoveFiles_Nominal);
UT_DS_TEST_ADD(DS_FileCloseDest_Test_PlatformConfigMoveFiles_MoveError);
UT_DS_TEST_ADD(DS_FileCloseDest_Test_PlatformConfigMoveFiles_FilenameTooLarge);
UT_DS_TEST_ADD(DS_FileCloseDest_Test_PlatformConfigMoveFiles_FilenameNull);
}
else
{
UT_DS_TEST_ADD(DS_FileCloseDest_Test_MoveFilesFalse);
}
UT_DS_TEST_ADD(DS_FileCloseDest_Test_PlatformConfigMoveFiles_Nominal);
UT_DS_TEST_ADD(DS_FileCloseDest_Test_PlatformConfigMoveFiles_MoveError);
UT_DS_TEST_ADD(DS_FileCloseDest_Test_PlatformConfigMoveFiles_FilenameTooLarge);
UT_DS_TEST_ADD(DS_FileCloseDest_Test_PlatformConfigMoveFiles_FilenameNull);
UT_DS_TEST_ADD(DS_FileCloseDest_Test_PlatformConfigMoveFiles_MovenameNull);
UT_DS_TEST_ADD(DS_FileCloseDest_Test_PlatformConfigMoveFiles_EmptyMoveFilesTrigger);

UT_DS_TEST_ADD(DS_FileTestAge_Test_Nominal);
UT_DS_TEST_ADD(DS_FileTestAge_Test_ExceedMaxAge);
Expand Down

0 comments on commit 27e9171

Please sign in to comment.