Skip to content

Commit

Permalink
Merge pull request #48 from jphickey/fix-42-use-payload
Browse files Browse the repository at this point in the history
Fix #42, use payload structure
  • Loading branch information
dzbaker authored Mar 24, 2023
2 parents 3ad3330 + 745d539 commit 550f908
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 26 deletions.
12 changes: 6 additions & 6 deletions docs/dox_src/cfs_hk.dox
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,11 @@

<H2>5. Monitoring the command counter</H2>

The #HK_HkPacket_t.CmdCounter will increment only
The #HK_HkTlm_Payload_t.CmdCounter will increment only
when the HK application receives a valid #HK_NOOP_CC.

<H2>6. Monitoring the command error counter</H2>
The #HK_HkPacket_t.ErrCounter will increment under the following conditions:
The #HK_HkTlm_Payload_t.ErrCounter will increment under the following conditions:
a. Invalid command code
b. Unexpected packet length field for #HK_SEND_COMBINED_PKT_MID command
c. Unexpected packet length field for #HK_SEND_HK_MID command
Expand All @@ -213,20 +213,20 @@
<H2>7. Monitoring the 'Combined Packets Sent" counter</H2>

Each time a #HK_SEND_COMBINED_PKT_MID \copybrief HK_SEND_COMBINED_PKT_MID is
received without error #HK_HkPacket_t.CombinedPacketsSent will increment.
received without error #HK_HkTlm_Payload_t.CombinedPacketsSent will increment.

<H2>8. Monitoring the 'Missing Data" counter</H2>

Each time a #HK_SEND_COMBINED_PKT_MID \copybrief HK_SEND_COMBINED_PKT_MID is
received without error, the HK app begins checking the 'Data Present' flag (located
in the run-time table) for each of the data sections that make up the output packet.
If a data portion is missing, HK sends a debug event (which is filtered by default)
and increments #HK_HkPacket_t.MissingDataCtr.
and increments #HK_HkTlm_Payload_t.MissingDataCtr.
The event will display the Message ID of the input message that would normally
provide the missing portion.

<B>NOTE:</B> HK will report only one missing data portion in any output message.
The #HK_HkPacket_t.MissingDataCtr will advance
The #HK_HkTlm_Payload_t.MissingDataCtr will advance
by one count (at most) and send one event (at most) for each
#HK_SEND_COMBINED_PKT_MID.

Expand All @@ -238,7 +238,7 @@
The HK memory pool is used to allocate the memory needed to store the output
packets. Each time a new copy table is processed, the memory for the output
packets is dynamically allocated from the memory pool. The memory pool handle is
sent down in #HK_HkPacket_t.
sent down in #HK_HkTlm_Payload_t.
It is possible to get statistics from the cFE ES application on the memory pool
used by this application. #CFE_ES_SEND_MEM_POOL_STATS_CC is
used to get statistics will need this memory pool handle as a command parameter.
Expand Down
26 changes: 21 additions & 5 deletions fsw/inc/hk_msg.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,24 @@
*/

/**
* \brief Send Combined Output Message Command
* \brief Send Combined Output Payload
*
* This structure contains the format of the command used to inform HK to send
* the specified combined output message
*/
typedef struct
{
CFE_SB_MsgId_t OutMsgToSend; /**< \brief MsgId of combined tlm pkt to send */
} HK_SendCombinedPkt_Payload_t;

/**
* \brief Send Combined Output Message Command
*/
typedef struct
{
CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command Message Header */

CFE_SB_MsgId_t OutMsgToSend; /**< \brief MsgId of combined tlm pkt to send */
HK_SendCombinedPkt_Payload_t Payload;
} HK_SendCombinedPktCmd_t;

/**
Expand Down Expand Up @@ -80,18 +88,26 @@ typedef struct
*/

/**
* \brief HK Application housekeeping Packet
* \brief HK Application housekeeping Payload
*/
typedef struct
{
CFE_MSG_TelemetryHeader_t TelemetryHeader; /**< \brief Telemetry Message Header */

uint8 CmdCounter; /**< \brief Count of valid commands received */
uint8 ErrCounter; /**< \brief Count of invalid commands received */
uint16 Padding; /**< \brief Padding to force 32 bit alignment */
uint16 CombinedPacketsSent; /**< \brief Count of combined tlm pkts sent */
uint16 MissingDataCtr; /**< \brief Number of times missing data was detected */
CFE_ES_MemHandle_t MemPoolHandle; /**< \brief Memory pool handle used to get mempool diags */
} HK_HkTlm_Payload_t;

/**
* \brief HK Application housekeeping Packet
*/
typedef struct
{
CFE_MSG_TelemetryHeader_t TelemetryHeader; /**< \brief Telemetry Message Header */

HK_HkTlm_Payload_t Payload;
} HK_HkPacket_t;

/**\}*/
Expand Down
4 changes: 2 additions & 2 deletions fsw/inc/hk_msgdefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
* \par Command Verification
* Successful execution of this command may be verified with the
* following telemetry:
* - #HK_HkPacket_t.CmdCounter will increment
* - #HK_HkTlm_Payload_t.CmdCounter will increment
* - The #HK_NOOP_CMD_EID informational event message will be generated
*
* \par Error Conditions
Expand All @@ -70,7 +70,7 @@
* \par Command Verification
* Successful execution of this command may be verified with the
* following telemetry:
* - #HK_HkPacket_t.CmdCounter will be reset
* - #HK_HkTlm_Payload_t.CmdCounter will be reset
* - The #HK_RESET_CNTRS_CMD_EID informational event message will
* be generated
*
Expand Down
18 changes: 11 additions & 7 deletions fsw/src/hk_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -392,9 +392,9 @@ void HK_AppPipe(const CFE_SB_Buffer_t *BufPtr)
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void HK_SendCombinedHKCmd(const CFE_SB_Buffer_t *BufPtr)
{
const HK_SendCombinedPktCmd_t *CmdPtr;
const HK_SendCombinedPkt_Payload_t *CmdPtr;

CmdPtr = (const HK_SendCombinedPktCmd_t *)BufPtr;
CmdPtr = &((const HK_SendCombinedPktCmd_t *)BufPtr)->Payload;

HK_SendCombinedHkPacket(CmdPtr->OutMsgToSend);
}
Expand All @@ -406,12 +406,16 @@ void HK_SendCombinedHKCmd(const CFE_SB_Buffer_t *BufPtr)
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void HK_HousekeepingCmd(const CFE_MSG_CommandHeader_t *Msg)
{
HK_HkTlm_Payload_t *PayloadPtr;

PayloadPtr = &HK_AppData.HkPacket.Payload;

/* copy data into housekeeping packet */
HK_AppData.HkPacket.CmdCounter = HK_AppData.CmdCounter;
HK_AppData.HkPacket.ErrCounter = HK_AppData.ErrCounter;
HK_AppData.HkPacket.MissingDataCtr = HK_AppData.MissingDataCtr;
HK_AppData.HkPacket.CombinedPacketsSent = HK_AppData.CombinedPacketsSent;
HK_AppData.HkPacket.MemPoolHandle = HK_AppData.MemPoolHandle;
PayloadPtr->CmdCounter = HK_AppData.CmdCounter;
PayloadPtr->ErrCounter = HK_AppData.ErrCounter;
PayloadPtr->MissingDataCtr = HK_AppData.MissingDataCtr;
PayloadPtr->CombinedPacketsSent = HK_AppData.CombinedPacketsSent;
PayloadPtr->MemPoolHandle = HK_AppData.MemPoolHandle;

/* Send housekeeping telemetry packet... */
CFE_SB_TimeStampMsg(CFE_MSG_PTR(HK_AppData.HkPacket.TelemetryHeader));
Expand Down
14 changes: 8 additions & 6 deletions unit-test/hk_app_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -1223,6 +1223,7 @@ void Test_HK_HousekeepingCmd(void)
CFE_MSG_CommandHeader_t DummyMsg;
uint8 call_count_CFE_SB_TimeStampMsg;
uint8 call_count_CFE_SB_TransmitMsg;
HK_HkTlm_Payload_t * PayloadPtr;

/* Setup app data values */
HK_AppData.CmdCounter = 1;
Expand All @@ -1240,12 +1241,13 @@ void Test_HK_HousekeepingCmd(void)
call_count_CFE_SB_TransmitMsg = UT_GetStubCount(UT_KEY(CFE_SB_TransmitMsg));

/* Assert */
UtAssert_INT32_EQ(HK_AppData.CmdCounter, HK_AppData.HkPacket.CmdCounter);
UtAssert_INT32_EQ(HK_AppData.ErrCounter, HK_AppData.HkPacket.ErrCounter);
UtAssert_INT32_EQ(HK_AppData.MissingDataCtr, HK_AppData.HkPacket.MissingDataCtr);
UtAssert_INT32_EQ(HK_AppData.CombinedPacketsSent, HK_AppData.HkPacket.CombinedPacketsSent);
UtAssert_True(CFE_RESOURCEID_TEST_EQUAL(HK_AppData.MemPoolHandle, HK_AppData.HkPacket.MemPoolHandle),
"CFE_RESOURCEID_TEST_EQUAL(HK_AppData.MemPoolHandle, HK_AppData.HkPacket.MemPoolHandle)");
PayloadPtr = &HK_AppData.HkPacket.Payload;
UtAssert_INT32_EQ(HK_AppData.CmdCounter, PayloadPtr->CmdCounter);
UtAssert_INT32_EQ(HK_AppData.ErrCounter, PayloadPtr->ErrCounter);
UtAssert_INT32_EQ(HK_AppData.MissingDataCtr, PayloadPtr->MissingDataCtr);
UtAssert_INT32_EQ(HK_AppData.CombinedPacketsSent, PayloadPtr->CombinedPacketsSent);
UtAssert_True(CFE_RESOURCEID_TEST_EQUAL(HK_AppData.MemPoolHandle, PayloadPtr->MemPoolHandle),
"CFE_RESOURCEID_TEST_EQUAL(HK_AppData.MemPoolHandle, PayloadPtr->MemPoolHandle)");

UtAssert_INT32_EQ(call_count_CFE_SB_TimeStampMsg, 1);
UtAssert_INT32_EQ(call_count_CFE_SB_TransmitMsg, 1);
Expand Down

0 comments on commit 550f908

Please sign in to comment.