From 7d6cc07ac0be776f4384a4e47c2a66a0799e8d03 Mon Sep 17 00:00:00 2001 From: Figueroa Date: Thu, 21 Jul 2022 12:34:56 -0400 Subject: [PATCH] Fix #37, Attempt to send message when file complete Adds reference of DS_FileTransmit() within DS_FileCloseDest() --- fsw/src/ds_file.c | 95 ++++++++++++++++++++++++++++++++++++++++++++++- fsw/src/ds_file.h | 16 ++++++++ fsw/src/ds_msg.h | 10 +++++ 3 files changed, 120 insertions(+), 1 deletion(-) 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