Skip to content

Commit

Permalink
TEST: Reports SB mempool NumFreeBytes for margin calculations
Browse files Browse the repository at this point in the history
  • Loading branch information
skliper committed May 10, 2024
1 parent 7f5ebcd commit ce8fffd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions modules/sb/fsw/src/cfe_sb_buf.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,12 @@ CFE_SB_BufferD_t *CFE_SB_GetBufferFromPool(size_t MaxMsgSize)

/* Add the size of the actual buffer to the memory-in-use ctr and */
/* adjust the high water mark if needed */
#if 0
CFE_ES_MemPoolStats_t PoolStats;
CFE_ES_GetMemPoolStats(&PoolStats, CFE_SB_Global.Mem.PoolHdl);
CFE_ES_WriteToSysLog("CFE SB alloc size = %ld, actual size = %d, pool num free %d\n", AllocSize,
CFE_ES_GetPoolBufInfo(CFE_SB_Global.Mem.PoolHdl, addr), PoolStats.NumFreeBytes);
#endif
CFE_SB_Global.StatTlmMsg.Payload.MemInUse += AllocSize;
if (CFE_SB_Global.StatTlmMsg.Payload.MemInUse > CFE_SB_Global.StatTlmMsg.Payload.PeakMemInUse)
{
Expand Down
6 changes: 6 additions & 0 deletions modules/sb/fsw/src/cfe_sb_task.c
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,12 @@ int32 CFE_SB_SendHKTlmCmd(const CFE_SB_SendHkCmd_t *data)
CFE_SB_Global.HKTlmMsg.Payload.UnmarkedMem =
CFE_PLATFORM_SB_BUF_MEMORY_BYTES - CFE_SB_Global.StatTlmMsg.Payload.PeakMemInUse;

CFE_ES_MemPoolStats_t PoolStats;
CFE_ES_GetMemPoolStats(&PoolStats, CFE_SB_Global.Mem.PoolHdl);
CFE_ES_WriteToSysLog("CFE SB Memory info: in use %d, peak %d, total %d, poolfree %d\n",
CFE_SB_Global.StatTlmMsg.Payload.MemInUse, CFE_SB_Global.StatTlmMsg.Payload.PeakMemInUse,
CFE_PLATFORM_SB_BUF_MEMORY_BYTES, PoolStats.NumFreeBytes);

CFE_SB_UnlockSharedData(__FILE__, __LINE__);

CFE_SB_TimeStampMsg(CFE_MSG_PTR(CFE_SB_Global.HKTlmMsg.TelemetryHeader));
Expand Down

0 comments on commit ce8fffd

Please sign in to comment.