Skip to content

Commit

Permalink
Fix nasa#543, Expose CFE_SB_GetPktType
Browse files Browse the repository at this point in the history
  • Loading branch information
skliper committed Apr 8, 2020
1 parent 62252d1 commit 47da836
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 35 deletions.
24 changes: 24 additions & 0 deletions fsw/cfe-core/src/inc/cfe_sb.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,15 @@

#define CFE_SB_INVALID_MSG_ID 0xFFFF /**< \brief Initializer for #CFE_SB_MsgId_t values that will not match any real MsgId */

/**
* \defgroup CFESBPktTypeDefs cFE SB Packet Type Defines
* \{
*/
#define CFE_SB_PKTTYPE_CMD 1 /**< \brief #CFE_SB_GetPktType response for command packets */
#define CFE_SB_PKTTYPE_TLM 0 /**< \brief #CFE_SB_GetPktType response for telemetry packets */
#define CFE_SB_PKTTYPE_INVALID 0xFF /**< \brief #CFE_SB_GetPktType response if message type can not be determined */
/** \} */

/*
** Macro Definitions
*/
Expand Down Expand Up @@ -1358,6 +1367,21 @@ static inline CFE_SB_MsgId_t CFE_SB_ValueToMsgId(CFE_SB_MsgId_Atom_t MsgIdValue)
{
return MsgIdValue;
}

/*****************************************************************************/
/**
* \brief Identifies packet type given message ID
*
* Provides the packet type associated with the given message ID
* as defined by #CFESBPktTypeDefs
*
* \return Packet type
* \retval #CFE_SB_PKTTYPE_CMD Command packet type
* \retval #CFE_SB_PKTTYPE_TLM Telemetry packet type
* \retval #CFE_SB_PKTTYPE_INVALID Invalid/unknown packet type
*/
uint8 CFE_SB_GetPktType(CFE_SB_MsgId_t MsgId);

/**@}*/

#endif /* _cfe_sb_ */
Expand Down
2 changes: 1 addition & 1 deletion fsw/cfe-core/src/sb/cfe_sb_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -1296,7 +1296,7 @@ int32 CFE_SB_SendMsgFull(CFE_SB_Msg_t *MsgPtr,
RtgTblPtr = CFE_SB_GetRoutePtrFromIdx(RtgTblIdx);

/* For Tlm packets, increment the seq count if requested */
if((CFE_SB_GetPktType(MsgId)==CFE_SB_TLM) &&
if((CFE_SB_GetPktType(MsgId)==CFE_SB_PKTTYPE_TLM) &&
(TlmCntIncrements==CFE_SB_INCREMENT_TLM)){
RtgTblPtr->SeqCnt++;
CFE_SB_SetMsgSeqCnt((CFE_SB_Msg_t *)BufDscPtr->Buffer,
Expand Down
24 changes: 24 additions & 0 deletions fsw/cfe-core/src/sb/cfe_sb_msg_id_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,3 +185,27 @@ void CFE_SB_SetMsgId(CFE_SB_MsgPtr_t MsgPtr,

#endif
}/* end CFE_SB_SetMsgId */

/*
* Function: CFE_SB_GetPktType - See API and header file for details
*/
uint8 CFE_SB_GetPktType(CFE_SB_MsgId_t MsgId)
{

CFE_SB_MsgId_Atom_t Val = MsgId;
uint8 PktType;

if (CFE_SB_IsValidMsgId(MsgId))
{
#ifndef MESSAGE_FORMAT_IS_CCSDS_VER_2
PktType = (CFE_TST(Val,12) == true) ? CFE_SB_PKTTYPE_CMD : CFE_SB_PKTTYPE_TLM;
#else
PktType = (CFE_SB_RD_TYPE_FROM_MSGID(Val) == 1) ? CFE_SB_PKTTYPE_CMD : CFE_SB_PKTTYPE_TLM;
#endif /* MESSAGE_FORMAT_IS_CCSDS_VER_2 */
} else {
PktType = CFE_SB_PKTTYPE_INVALID;
}

return PktType;

}/* end CFE_SB_GetPktType */
30 changes: 0 additions & 30 deletions fsw/cfe-core/src/sb/cfe_sb_priv.c
Original file line number Diff line number Diff line change
Expand Up @@ -659,36 +659,6 @@ char *CFE_SB_GetAppTskName(uint32 TaskId,char *FullName){

}/* end CFE_SB_GetAppTskName */


/******************************************************************************
** Function: CFE_SB_GetPktType()
**
** Purpose:
** For CCSDS packets, this function returns the state of the cmd/tlm bit(12).
** For cmd pkts, the state is 1. For tlm pkts, the state is 0.
**
** Arguments:
**
** Return:
** None
*/
uint8 CFE_SB_GetPktType(CFE_SB_MsgId_t MsgId)
{

#ifdef MESSAGE_FORMAT_IS_CCSDS
CFE_SB_MsgId_Atom_t Val = MsgId;

#ifndef MESSAGE_FORMAT_IS_CCSDS_VER_2
return CFE_TST(Val,12);
#else
return CFE_SB_RD_TYPE_FROM_MSGID(Val);
#endif /* MESSAGE_FORMAT_IS_CCSDS_VER_2 */

#endif /* MESSAGE_FORMAT_IS_CCSDS */

}/* end CFE_SB_GetPktType */


/******************************************************************************
** Function: CFE_SB_RequestToSendEvent()
**
Expand Down
4 changes: 0 additions & 4 deletions fsw/cfe-core/src/sb/cfe_sb_priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,6 @@
#define CFE_SB_GLOBAL 0
#define CFE_SB_LOCAL 1

#define CFE_SB_TLM 0
#define CFE_SB_CMD 1

#define CFE_SB_SEND_ZEROCOPY 0
#define CFE_SB_SEND_ONECOPY 1

Expand Down Expand Up @@ -391,7 +388,6 @@ int32 CFE_SB_ZeroCopyReleaseAppId(uint32 AppId);
int32 CFE_SB_DecrBufUseCnt(CFE_SB_BufferD_t *bd);
int32 CFE_SB_ValidateMsgId(CFE_SB_MsgId_t MsgId);
int32 CFE_SB_ValidatePipeId(CFE_SB_PipeId_t PipeId);
uint8 CFE_SB_GetPktType(CFE_SB_MsgId_t MsgId);
void CFE_SB_IncrCmdCtr(int32 status);
void CFE_SB_FileWriteByteCntErr(const char *Filename,uint32 Requested,uint32 Actual);
void CFE_SB_SetSubscriptionReporting(uint32 state);
Expand Down

0 comments on commit 47da836

Please sign in to comment.