Skip to content

Commit

Permalink
Fix #37, Attempt to send message when file complete
Browse files Browse the repository at this point in the history
Adds reference of DS_FileTransmit() within DS_FileCloseDest()
Adds forgotten semi-colon, Changes function header comment,
Adds msgid for complete file info, Changes struct header comment
  • Loading branch information
chillfig committed Jul 21, 2022
1 parent 367d412 commit 12d30a4
Show file tree
Hide file tree
Showing 4 changed files with 121 additions and 1 deletion.
1 change: 1 addition & 0 deletions fsw/platform_inc/ds_msgids.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@

#define DS_HK_TLM_MID 0x08B8 /**< \brief DS Hk Telemetry Message ID ****/
#define DS_DIAG_TLM_MID 0x08B9 /**< \brief DS File Info Telemetry Message ID ****/
#define DS_COMP_TLM_MID 0x08BA /**< \brief DS Completed File Info Telemetry Message ID ****/

/**\}*/

Expand Down
95 changes: 94 additions & 1 deletion fsw/src/ds_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "ds_verify.h"

#include "ds_appdefs.h"
#include "ds_msgids.h"

#include "ds_msg.h"
#include "ds_app.h"
Expand Down Expand Up @@ -966,7 +967,12 @@ void DS_FileCloseDest(int32 FileIndex)
*/
OS_close(FileStatus->FileHandle);
#endif


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

/*
** Reset status for this destination file...
*/
Expand Down Expand Up @@ -1025,6 +1031,93 @@ void DS_FileTestAge(uint32 ElapsedSeconds)

} /* End of DS_FileTestAge() */

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* DS_FileTransmit() - transmit file info */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

void DS_FileTransmit(int32 FileIndex)
{
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?

/*
** 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() */

/************************/
/* End of File Comment */
/************************/
16 changes: 16 additions & 0 deletions fsw/src/ds_file.h
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,22 @@ void DS_FileCloseDest(int32 FileIndex);
*/
void DS_FileTestAge(uint32 ElapsedSeconds);

/**
* \brief Transmit file information telemetry handler
*
* \par Description
* Create and send a telemetry packet containing the current
* status for a closed destination file.
*
* \par Assumptions, External Events, and Notes:
* (none)
*
* \param[in] FileIndex Destination file index
*
* \sa #DS_GET_FILE_INFO_CC, #DS_GetFileInfoCmd_t, #DS_FileInfoPkt_t
*/
void DS_FileTransmit(int32 FileIndex);

/**
* \brief Determine whether Software Bus message packet is filtered
*
Expand Down
10 changes: 10 additions & 0 deletions fsw/src/ds_msg.h
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,16 @@ typedef struct
DS_FileInfo_t FileInfo[DS_DEST_FILE_CNT]; /**< \brief Current state of destination files */
} DS_FileInfoPkt_t;

/**
* \brief Completed application file info
*/
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_FileCompletePkt_t;

/**\}*/

#endif

0 comments on commit 12d30a4

Please sign in to comment.