Skip to content

Commit

Permalink
Fix #37, Adds file transmit feature at file completion
Browse files Browse the repository at this point in the history
Adds FileStatus as the sole parameter to DS_FileTransmit(), Adds unit test,
Adds inclusion of ds_apps.h to ds_msg.h, Removes whitespaces, Adds dereference
  • Loading branch information
chillfig committed Jul 25, 2022
1 parent ee82dd5 commit a269a84
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 70 deletions.
72 changes: 5 additions & 67 deletions fsw/src/ds_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -967,12 +967,12 @@ void DS_FileCloseDest(int32 FileIndex)
*/
OS_close(FileStatus->FileHandle);
#endif

/*
** Transmit file information telemetry...
*/
DS_FileTransmit(FileIndex);
DS_FileTransmit(FileStatus);

/*
** Reset status for this destination file...
*/
Expand Down Expand Up @@ -1037,83 +1037,21 @@ void DS_FileTestAge(uint32 ElapsedSeconds)
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

void DS_FileTransmit(int32 FileIndex)
void DS_FileTransmit(DS_AppFileStatus_t *FileStatus)
{
DS_FileCompletePkt_t DS_FileCompletePkt;

/*
** Create and send a file info packet...
*/
// CFE_EVS_SendEvent(DS_GET_FILE_INFO_CMD_EID, CFE_EVS_EventType_DEBUG, "GET FILE INFO command"); Should DS_FileTransmit() be a ds_cmds.c cmd?
DS_FileCompletePkt_t DS_FileCompletePkt = {.FileStatus = *FileStatus};

/*
** Initialize file info telemetry...
*/
CFE_MSG_Init(&DS_FileCompletePkt.TlmHeader.Msg, CFE_SB_ValueToMsgId(DS_COMP_TLM_MID), sizeof(DS_FileCompletePkt_t));

/*
** Process destination file info data...
*/

/*
** Set file age and size...
*/
DS_FileCompletePkt.FileInfo.FileAge = DS_AppData.FileStatus[FileIndex].FileAge;
DS_FileCompletePkt.FileInfo.FileSize = DS_AppData.FileStatus[FileIndex].FileSize;

/*
** Set file growth rate (computed when process last HK request)...
*/
DS_FileCompletePkt.FileInfo.FileRate = DS_AppData.FileStatus[FileIndex].FileRate;

/*
** Set current filename sequence count...
*/
DS_FileCompletePkt.FileInfo.SequenceCount = DS_AppData.FileStatus[FileIndex].FileCount;

/*
** Set file enable/disable state...
*/
if (DS_AppData.DestFileTblPtr == (DS_DestFileTable_t *)NULL)
{
DS_FileCompletePkt.FileInfo.EnableState = DS_DISABLED;
}
else
{
DS_FileCompletePkt.FileInfo.EnableState = DS_AppData.FileStatus[FileIndex].FileState;
}

/*
** Set file open/closed state...
*/
if (!OS_ObjectIdDefined(DS_AppData.FileStatus[FileIndex].FileHandle))
{
DS_FileCompletePkt.FileInfo.OpenState = DS_CLOSED;
}
else
{
DS_FileCompletePkt.FileInfo.OpenState = DS_OPEN;

/*
** Set current open filename...
*/
if (DS_MOVE_FILES == true)
{
strcpy(DS_FileCompletePkt.FileInfo.FileName, DS_AppData.FileStatus[FileIndex].FileName);
}
else
{
strcpy(DS_FileCompletePkt.FileInfo.FileName, DS_AppData.DestFileTblPtr->File[FileIndex].Movename);
}
}

/*
** Timestamp and send file info telemetry...
*/
CFE_SB_TimeStampMsg(&DS_FileCompletePkt.TlmHeader.Msg);
CFE_SB_TransmitMsg(&DS_FileCompletePkt.TlmHeader.Msg, true);


return;

} /* End of DS_CmdGetCompleteFileInfo() */
Expand Down
4 changes: 2 additions & 2 deletions fsw/src/ds_file.h
Original file line number Diff line number Diff line change
Expand Up @@ -298,11 +298,11 @@ void DS_FileTestAge(uint32 ElapsedSeconds);
* \par Assumptions, External Events, and Notes:
* (none)
*
* \param[in] FileIndex Destination file index
* \param[in] FileStatus Current state of destination file
*
* \sa #DS_GET_FILE_INFO_CC, #DS_GetFileInfoCmd_t, #DS_FileInfoPkt_t
*/
void DS_FileTransmit(int32 FileIndex);
void DS_FileTransmit(DS_AppFileStatus_t *FileStatus);

/**
* \brief Determine whether Software Bus message packet is filtered
Expand Down
3 changes: 2 additions & 1 deletion fsw/src/ds_msg.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

#include "cfe.h"
#include "ds_platform_cfg.h"
#include "ds_app.h"

/**
* \defgroup cfsdscmdstructs CFS Data Storage Command Structures
Expand Down Expand Up @@ -363,7 +364,7 @@ typedef struct
{
CFE_MSG_TelemetryHeader_t TlmHeader; /**< \brief cFE Software Bus telemetry message header */

DS_FileInfo_t FileInfo; /**< \brief Current state of destination files */
DS_AppFileStatus_t FileStatus; /**< \brief Current state of destination file */
} DS_FileCompletePkt_t;

/**\}*/
Expand Down
13 changes: 13 additions & 0 deletions unit-test/ds_file_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -1739,6 +1739,17 @@ void DS_IsPacketFiltered_Test_TimeFilter3(void)
UtAssert_BOOL_TRUE(Result);
}

void DS_FileTransmit_Test_Nominal(void)
{
/* Execute the function being tested */
UtAssert_VOIDCALL(DS_FileTransmit(&DS_AppData.FileStatus[0]));

/* Verify results */
UtAssert_STUB_COUNT(CFE_MSG_Init, 1);
UtAssert_STUB_COUNT(CFE_SB_TimeStampMsg, 1);
UtAssert_STUB_COUNT(CFE_SB_TransmitMsg, 1);
}

void UtTest_Setup(void)
{
UtTest_Add(DS_FileStorePacket_Test_Nominal, DS_Test_Setup, DS_Test_TearDown, "DS_FileStorePacket_Test_Nominal");
Expand Down Expand Up @@ -1855,6 +1866,8 @@ void UtTest_Setup(void)
UtTest_Add(DS_IsPacketFiltered_Test_TimeFilter3, DS_Test_Setup, DS_Test_TearDown,
"DS_IsPacketFiltered_Test_TimeFilter3");

UtTest_Add(DS_FileTransmit_Test_Nominal, DS_Test_Setup, DS_Test_TearDown, "DS_FileTransmit_Test_Nominal");

} /* end DS_File_Test_AddTestCases */

/************************/
Expand Down

0 comments on commit a269a84

Please sign in to comment.