Skip to content

Commit

Permalink
Merge pull request #2522 from nasa/integration-candidate
Browse files Browse the repository at this point in the history
cFE Integration candidate: Equuleus-rc1+dev6
  • Loading branch information
dzbaker authored Feb 29, 2024
2 parents 9e5d452 + 6b3d9d1 commit 4577b78
Show file tree
Hide file tree
Showing 10 changed files with 671 additions and 118 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## Development Build: equuleus-rc1+dev100
- Add runtime TopicId conversion routines to SB
- See <https://github.com/nasa/cFE/pull/2520>

## Development Build: equuleus-rc1+dev96
- change CFE_MSG_Message from union to struct
- Remove unreachable/dead branch in CFE_ES_RunPerfLogDump()
Expand Down
127 changes: 127 additions & 0 deletions modules/core_api/fsw/inc/cfe_sb.h
Original file line number Diff line number Diff line change
Expand Up @@ -853,6 +853,133 @@ static inline CFE_SB_MsgId_t CFE_SB_ValueToMsgId(CFE_SB_MsgId_Atom_t MsgIdValue)
CFE_SB_MsgId_t Result = CFE_SB_MSGID_C(MsgIdValue);
return Result;
}

/*****************************************************************************/
/**
* \brief Converts a topic ID and instance number combination into a MsgID value integer
*
* \par Description
* This function accepts a data pair of topic ID + instance number and returns the
* corresponding MsgID Value (integer) for commands.
*
* \par Assumptions and Notes:
* A topic ID identifies a certain data stream from an application, for example
* the CFE Software bus ground commands (CFE_MISSION_SB_CMD_TOPICID). In
* contrast to MsgID, the topic ID is consistent across all CPUs in a system, whereas
* each CPU instance will have a unique MsgID.
*
* CPU instance numbers are 1-based. The instance number of 0 is reserved
* for "global" MsgID values that are the same on all CPUs. The PSP function
* may be used to obtain the current CPU number for the host processor.
*
* \sa CFE_SB_TlmTopicIdToMsgId(), CFE_PSP_GetProcessorId()
*
* \return Integer representation of the #CFE_SB_MsgId_t
*/
CFE_SB_MsgId_Atom_t CFE_SB_CmdTopicIdToMsgId(uint16 TopicId, uint16 InstanceNum);

/*****************************************************************************/
/**
* \brief Converts a topic ID and instance number combination into a MsgID value integer
*
* \par Description
* This function accepts a data pair of topic ID + instance number and returns the
* corresponding MsgID Value (integer) for telemetry.
*
* \par Assumptions and Notes:
* A topic ID identifies a certain data stream from an application, for example
* the CFE Software bus housekeeping telemetry (CFE_MISSION_SB_HK_TLM_TOPICID). In
* contrast to MsgID, the topic ID is consistent across all CPUs in a system, whereas
* each CPU instance will have a unique MsgID.
*
* CPU instance numbers are 1-based. The instance number of 0 is reserved
* for "global" MsgID values that are the same on all CPUs. The PSP function
* may be used to obtain the current CPU number for the host processor.
*
* \sa CFE_SB_CmdTopicIdToMsgId(), CFE_PSP_GetProcessorId()
*
* \return Integer representation of the #CFE_SB_MsgId_t
*/
CFE_SB_MsgId_Atom_t CFE_SB_TlmTopicIdToMsgId(uint16 TopicId, uint16 InstanceNum);

/*****************************************************************************/
/**
* \brief Converts a topic ID to a MsgID value integer for Global commands
*
* \par Description
* This is a wrapper around CFE_SB_CmdTopicIdToMsgId() for topic IDs which
* are the same on all CPUs within a system (i.e. not specific to a certain
* processor)
*
* \par Assumptions and Notes:
* Global MsgIDs may be used when only a single instance of a service exists
* within the system. The CFE framework does not use this feature for commands,
* but is defined for future use.
*
* \sa CFE_SB_CmdTopicIdToMsgId(), CFE_SB_LocalCmdTopicIdToMsgId()
*
* \return Integer representation of the #CFE_SB_MsgId_t
*/
CFE_SB_MsgId_Atom_t CFE_SB_GlobalCmdTopicIdToMsgId(uint16 TopicId);

/*****************************************************************************/
/**
* \brief Converts a topic ID to a MsgID value integer for Global telemetry
*
* \par Description
* This is a wrapper around CFE_SB_TlmTopicIdToMsgId() for topic IDs which
* are the same on all CPUs within a system (i.e. not specific to a certain
* processor)
*
* \par Assumptions and Notes:
* Global MsgIDs may be used when only a single instance of a service exists
* within the system. An example for such telemetry is the time synchronization
* service published by CFE_TIME.
*
* \sa CFE_SB_TlmTopicIdToMsgId(), CFE_SB_LocalTlmTopicIdToMsgId()
*
* \return Integer representation of the #CFE_SB_MsgId_t
*/
CFE_SB_MsgId_Atom_t CFE_SB_GlobalTlmTopicIdToMsgId(uint16 TopicId);

/*****************************************************************************/
/**
* \brief Converts a topic ID to a MsgID value integer for local commands
*
* \par Description
* This is a wrapper around CFE_SB_CmdTopicIdToMsgId() for topic IDs which
* are unique on all CPUs within a system (i.e. specific to a certain
* processor)
*
* \par Assumptions and Notes:
* This assumes the caller is referring to a service running on the same
* processor instance as itself.
*
* \sa CFE_SB_CmdTopicIdToMsgId(), CFE_SB_LocalTlmTopicIdToMsgId()
*
* \return Integer representation of the #CFE_SB_MsgId_t
*/
CFE_SB_MsgId_Atom_t CFE_SB_LocalCmdTopicIdToMsgId(uint16 TopicId);

/*****************************************************************************/
/**
* \brief Converts a topic ID to a MsgID value integer for local telemetry
*
* \par Description
* This is a wrapper around CFE_SB_TlmTopicIdToMsgId() for topic IDs which
* are unique on all CPUs within a system (i.e. specific to a certain
* processor)
*
* \par Assumptions and Notes:
* This assumes the caller is referring to a service running on the same
* processor instance as itself.
*
* \sa CFE_SB_TlmTopicIdToMsgId(), CFE_SB_LocalCmdTopicIdToMsgId()
*
* \return Integer representation of the #CFE_SB_MsgId_t
*/
CFE_SB_MsgId_Atom_t CFE_SB_LocalTlmTopicIdToMsgId(uint16 TopicId);

/** @} */

#endif /* CFE_SB_H */
2 changes: 1 addition & 1 deletion modules/core_api/fsw/inc/cfe_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#define CFE_VERSION_H

/* Development Build Macro Definitions */
#define CFE_BUILD_NUMBER 96 /**< @brief Development: Number of development git commits since CFE_BUILD_BASELINE */
#define CFE_BUILD_NUMBER 100 /**< @brief Development: Number of development git commits since CFE_BUILD_BASELINE */
#define CFE_BUILD_BASELINE "equuleus-rc1" /**< @brief Development: Reference git tag for build number */
#define CFE_BUILD_DEV_CYCLE "equuleus-rc2" /**< @brief Development: Release name for current development cycle */
#define CFE_BUILD_CODENAME "Equuleus" /**< @brief: Development: Code name for the current build */
Expand Down
5 changes: 3 additions & 2 deletions modules/core_api/ut-stubs/src/cfe_config_stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,11 @@ uint32 CFE_Config_GetValue(CFE_ConfigId_t ConfigId)
* Generated stub function for CFE_Config_GetVersionString()
* ----------------------------------------------------
*/
void CFE_Config_GetVersionString(char *Buf, size_t Size, const char *Component, const char *SrcVersion, const char *CodeName, const char *LastOffcRel)
void CFE_Config_GetVersionString(char *Buf, size_t Size, const char *Component, const char *SrcVersion,
const char *CodeName, const char *LastOffcRel)
{
UT_GenStub_AddParam(CFE_Config_GetVersionString, char *, Buf);
UT_GenStub_AddParam(CFE_Config_GetVersionString, size_t , Size);
UT_GenStub_AddParam(CFE_Config_GetVersionString, size_t, Size);
UT_GenStub_AddParam(CFE_Config_GetVersionString, const char *, Component);
UT_GenStub_AddParam(CFE_Config_GetVersionString, const char *, SrcVersion);
UT_GenStub_AddParam(CFE_Config_GetVersionString, const char *, CodeName);
Expand Down
139 changes: 139 additions & 0 deletions modules/core_api/ut-stubs/src/cfe_sb_handlers.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,149 @@ static CFE_SB_StubMsg_MetaData_t *CFE_SB_StubMsg_GetMetaData(const CFE_MSG_Messa

return MetaPtr;
}

/*------------------------------------------------------------
*
* Helper function to fabricate a MsgID value for testing purposes
*
* Note this is not intended to match a real MsgID value used in flight
* software builds, it is just for UT. The fabricated value just needs
* to pass the "CFE_SB_IsValidMsgId()" test.
*
*------------------------------------------------------------*/
static void UT_CFE_SB_FabricateMsgIdValue(UT_EntryKey_t FuncKey, bool IsCmd, uint16 TopicId, uint16 InstanceNum)
{
CFE_SB_MsgId_Atom_t MsgIdValue;

/* This makes the bits line up with the "traditional" use of the first 16
* bits of a CCSDS space packet as a MsgId */
MsgIdValue = 1;
if (IsCmd)
{
MsgIdValue |= 2;
}
MsgIdValue <<= 4;
MsgIdValue |= InstanceNum & 0xF;
MsgIdValue <<= 7;
MsgIdValue |= TopicId & 0x7F;

UT_Stub_SetReturnValue(FuncKey, MsgIdValue);
}

/*
** Functions
*/

/*------------------------------------------------------------
*
* Default handler for CFE_SB_LocalCmdTopicIdToMsgId coverage stub function
*
*------------------------------------------------------------*/
void UT_DefaultHandler_CFE_SB_LocalCmdTopicIdToMsgId(void *UserObj, UT_EntryKey_t FuncKey,
const UT_StubContext_t *Context)
{
uint16 TopicId;

if (!UT_Stub_GetInt32StatusCode(Context, NULL))
{
TopicId = UT_Hook_GetArgValueByName(Context, "TopicId", uint16);

UT_CFE_SB_FabricateMsgIdValue(FuncKey, true, TopicId, 1);
}
}

/*------------------------------------------------------------
*
* Default handler for CFE_SB_LocalTlmTopicIdToMsgId coverage stub function
*
*------------------------------------------------------------*/
void UT_DefaultHandler_CFE_SB_LocalTlmTopicIdToMsgId(void *UserObj, UT_EntryKey_t FuncKey,
const UT_StubContext_t *Context)
{
uint16 TopicId;

if (!UT_Stub_GetInt32StatusCode(Context, NULL))
{
TopicId = UT_Hook_GetArgValueByName(Context, "TopicId", uint16);

UT_CFE_SB_FabricateMsgIdValue(FuncKey, false, TopicId, 1);
}
}

/*------------------------------------------------------------
*
* Default handler for CFE_SB_GlobalCmdTopicIdToMsgId coverage stub function
*
*------------------------------------------------------------*/
void UT_DefaultHandler_CFE_SB_GlobalCmdTopicIdToMsgId(void *UserObj, UT_EntryKey_t FuncKey,
const UT_StubContext_t *Context)
{
uint16 TopicId;

if (!UT_Stub_GetInt32StatusCode(Context, NULL))
{
TopicId = UT_Hook_GetArgValueByName(Context, "TopicId", uint16);

UT_CFE_SB_FabricateMsgIdValue(FuncKey, true, TopicId, 0);
}
}

/*------------------------------------------------------------
*
* Default handler for CFE_SB_GlobalTlmTopicIdToMsgId coverage stub function
*
*------------------------------------------------------------*/
void UT_DefaultHandler_CFE_SB_GlobalTlmTopicIdToMsgId(void *UserObj, UT_EntryKey_t FuncKey,
const UT_StubContext_t *Context)
{
uint16 TopicId;

if (!UT_Stub_GetInt32StatusCode(Context, NULL))
{
TopicId = UT_Hook_GetArgValueByName(Context, "TopicId", uint16);

UT_CFE_SB_FabricateMsgIdValue(FuncKey, false, TopicId, 0);
}
}

/*------------------------------------------------------------
*
* Default handler for CFE_SB_CmdTopicIdToMsgId coverage stub function
*
*------------------------------------------------------------*/
void UT_DefaultHandler_CFE_SB_CmdTopicIdToMsgId(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context)
{
uint16 TopicId;
uint16 InstanceNum;

if (!UT_Stub_GetInt32StatusCode(Context, NULL))
{
TopicId = UT_Hook_GetArgValueByName(Context, "TopicId", uint16);
InstanceNum = UT_Hook_GetArgValueByName(Context, "InstanceNum", uint16);

UT_CFE_SB_FabricateMsgIdValue(FuncKey, true, TopicId, InstanceNum);
}
}

/*------------------------------------------------------------
*
* Default handler for CFE_SB_TlmTopicIdToMsgId coverage stub function
*
*------------------------------------------------------------*/
void UT_DefaultHandler_CFE_SB_TlmTopicIdToMsgId(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context)
{
uint16 TopicId;
uint16 InstanceNum;

if (!UT_Stub_GetInt32StatusCode(Context, NULL))
{
TopicId = UT_Hook_GetArgValueByName(Context, "TopicId", uint16);
InstanceNum = UT_Hook_GetArgValueByName(Context, "InstanceNum", uint16);

UT_CFE_SB_FabricateMsgIdValue(FuncKey, false, TopicId, InstanceNum);
}
}

/*------------------------------------------------------------
*
* Default handler for CFE_SB_CreatePipe coverage stub function
Expand Down
Loading

0 comments on commit 4577b78

Please sign in to comment.