diff --git a/fsw/src/ds_file.c b/fsw/src/ds_file.c index e19e04c..91e8be5 100644 --- a/fsw/src/ds_file.c +++ b/fsw/src/ds_file.c @@ -29,6 +29,7 @@ #include "ds_verify.h" #include "ds_appdefs.h" +#include "ds_msgids.h" #include "ds_msg.h" #include "ds_app.h" @@ -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... */ @@ -1025,6 +1031,93 @@ void DS_FileTestAge(uint32 ElapsedSeconds) } /* End of DS_FileTestAge() */ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* */ +/* DS_CmdGetCompleteFileInfo() - get 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_DIAG_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 */ /************************/ diff --git a/fsw/src/ds_file.h b/fsw/src/ds_file.h index 605f0e3..e2d69eb 100644 --- a/fsw/src/ds_file.h +++ b/fsw/src/ds_file.h @@ -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 * diff --git a/fsw/src/ds_msg.h b/fsw/src/ds_msg.h index 9e2d9c3..30d78ee 100644 --- a/fsw/src/ds_msg.h +++ b/fsw/src/ds_msg.h @@ -356,6 +356,16 @@ typedef struct DS_FileInfo_t FileInfo[DS_DEST_FILE_CNT]; /**< \brief Current state of destination files */ } DS_FileInfoPkt_t; +/** + * \brief 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