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
  • Loading branch information
chillfig committed Jul 21, 2022
1 parent 367d412 commit effd2c7
Show file tree
Hide file tree
Showing 3 changed files with 114 additions and 0 deletions.
88 changes: 88 additions & 0 deletions 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 @@ -1025,6 +1026,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 */
/************************/
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 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 effd2c7

Please sign in to comment.