Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion docs/dox_src/cfs_hk.dox
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,13 @@
The HK app will not zero-out or alter the missing data section(s) in any way.
The missing data values will match the last 'good' section received.

<H2>9. Using the Memory Pool handle to get mempool stats</H2>
<H2>9. Monitoring the 'Packet Not Found" counter</H2>

If the combined HK Packet cannot be found in the current HK Copy Table, an
informational event will be sent, and the #HK_HkTlm_Payload_t.PacketNotFoundCtr
will be incremented.

<H2>10. Using the Memory Pool handle to get mempool stats</H2>

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
Expand Down
3 changes: 2 additions & 1 deletion fsw/inc/hk_msg.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ typedef struct
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 */
uint8 PacketNotFoundCtr; /**< \brief Number of times a requested packet was not found */
uint8 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;

Expand Down
2 changes: 2 additions & 0 deletions fsw/src/hk_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ void HK_SendHkCmd(const CFE_SB_Buffer_t *BufPtr)
/* copy data into housekeeping packet */
PayloadPtr->CmdCounter = HK_AppData.CmdCounter;
PayloadPtr->ErrCounter = HK_AppData.ErrCounter;
PayloadPtr->PacketNotFoundCtr = HK_AppData.PacketNotFoundCtr;
PayloadPtr->MissingDataCtr = HK_AppData.MissingDataCtr;
PayloadPtr->CombinedPacketsSent = HK_AppData.CombinedPacketsSent;
PayloadPtr->MemPoolHandle = HK_AppData.MemPoolHandle;
Expand Down Expand Up @@ -373,6 +374,7 @@ void HK_ResetHkData(void)
HK_AppData.CmdCounter = 0;
HK_AppData.ErrCounter = 0;
HK_AppData.CombinedPacketsSent = 0;
HK_AppData.PacketNotFoundCtr = 0;
HK_AppData.MissingDataCtr = 0;
}

Expand Down
3 changes: 2 additions & 1 deletion fsw/src/hk_app.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ typedef struct
uint8 CmdCounter; /**< \brief Number of valid commands received */
uint8 ErrCounter; /**< \brief Number of invalid commands received */

uint16 MissingDataCtr; /**< \brief Number of times missing data was detected */
uint8 PacketNotFoundCtr; /**< \brief Number of times a requested packet was not found */
uint8 MissingDataCtr; /**< \brief Number of times missing data was detected */
uint16 CombinedPacketsSent; /**< \brief Count of combined output msgs sent */

CFE_ES_MemHandle_t MemPoolHandle; /**< \brief HK mempool handle for output pkts */
Expand Down
2 changes: 2 additions & 0 deletions fsw/src/hk_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,8 @@ void HK_SendCombinedHkPacket(CFE_SB_MsgId_t WhichMidToSend)

if (PacketFound == false)
{
HK_AppData.PacketNotFoundCtr++;

CFE_EVS_SendEvent(HK_UNKNOWN_COMBINED_PACKET_EID, CFE_EVS_EventType_INFORMATION,
"Combined HK Packet 0x%08lX is not found in current HK Copy Table",
(unsigned long)CFE_SB_MsgIdToValue(WhichMidToSend));
Expand Down
5 changes: 3 additions & 2 deletions fsw/src/hk_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,9 @@ int32 HK_TearDownOldCopyTable(hk_copy_table_entry_t *CpyTblPtr, hk_runtime_tbl_e
*
* \par Description
* This routine searches for the combined HK that contains the specified
* MID. Once found, the packet is sent. If not found, an event is
* generated. Also sets the data pieces for this output pkt
* MID. Once found, the packet is sent. If not found, PacketNotFoundCtr
* is incremented, and an event is generated. Also sets the data pieces
* for this output pkt
*
* \par Assumptions, External Events, and Notes:
* None
Expand Down
8 changes: 6 additions & 2 deletions unit-test/hk_app_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -930,8 +930,9 @@ void Test_HK_SendHkCmd(void)
/* Setup app data values */
HK_AppData.CmdCounter = 1;
HK_AppData.ErrCounter = 2;
HK_AppData.MissingDataCtr = 3;
HK_AppData.CombinedPacketsSent = 4;
HK_AppData.PacketNotFoundCtr = 3;
HK_AppData.MissingDataCtr = 4;
HK_AppData.CombinedPacketsSent = 5;
HK_AppData.MemPoolHandle = HK_UT_MEMPOOL_1;

memset(&Msg, 0, sizeof(Msg));
Expand All @@ -946,6 +947,7 @@ void Test_HK_SendHkCmd(void)
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.PacketNotFoundCtr, PayloadPtr->PacketNotFoundCtr);
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),
Expand Down Expand Up @@ -1055,6 +1057,7 @@ void Test_HK_ResetHkData(void)
HK_AppData.CmdCounter = 1;
HK_AppData.ErrCounter = 1;
HK_AppData.CombinedPacketsSent = 1;
HK_AppData.PacketNotFoundCtr = 1;
HK_AppData.MissingDataCtr = 1;

/* Act */
Expand All @@ -1064,6 +1067,7 @@ void Test_HK_ResetHkData(void)
UtAssert_INT32_EQ(HK_AppData.CmdCounter, 0);
UtAssert_INT32_EQ(HK_AppData.ErrCounter, 0);
UtAssert_INT32_EQ(HK_AppData.CombinedPacketsSent, 0);
UtAssert_INT32_EQ(HK_AppData.PacketNotFoundCtr, 0);
UtAssert_INT32_EQ(HK_AppData.MissingDataCtr, 0);

call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent));
Expand Down
5 changes: 5 additions & 0 deletions unit-test/hk_utils_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -1047,6 +1047,7 @@ void Test_HK_SendCombinedHkPacket_NoMissingData(void)

/* Assert */
UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0);
UtAssert_INT32_EQ(HK_AppData.PacketNotFoundCtr, 0);
UtAssert_INT32_EQ(HK_AppData.MissingDataCtr, 0);
UtAssert_INT32_EQ(call_count_CFE_SB_TimeStampMsg, 1);
UtAssert_INT32_EQ(call_count_CFE_SB_TransmitMsg, 1);
Expand Down Expand Up @@ -1123,6 +1124,8 @@ void Test_HK_SendCombinedHkPacket_EmptyTable(void)
call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent));

/* Assert */
UtAssert_INT32_EQ(HK_AppData.PacketNotFoundCtr, 1);

UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 1);

UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, HK_UNKNOWN_COMBINED_PACKET_EID);
Expand Down Expand Up @@ -1172,6 +1175,8 @@ void Test_HK_SendCombinedHkPacket_PacketNotFound(void)
call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent));

/* Assert */
UtAssert_INT32_EQ(HK_AppData.PacketNotFoundCtr, 1);

UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 1);

UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, HK_UNKNOWN_COMBINED_PACKET_EID);
Expand Down