Skip to content

Commit

Permalink
Merge branch 'fix-666-sb-message-alignment' into jph-wip-baseline-202…
Browse files Browse the repository at this point in the history
…00508
  • Loading branch information
jphickey committed May 8, 2020
2 parents de8d14e + 5e71fe2 commit 7a608f0
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 23 deletions.
2 changes: 1 addition & 1 deletion fsw/cfe-core/src/inc/cfe_es_msg.h
Original file line number Diff line number Diff line change
Expand Up @@ -1586,7 +1586,7 @@ typedef struct

typedef struct
{
uint8 TlmHeader[CFE_SB_TLM_HDR_SIZE]; /**< \brief cFE Software Bus Telemetry Message Header */
CFE_SB_TlmHdr_t TlmHeader; /**< \brief cFE Software Bus Telemetry Message Header */
CFE_ES_ShellPacket_Payload_t Payload;
}CFE_ES_ShellTlm_t;

Expand Down
10 changes: 8 additions & 2 deletions fsw/cfe-core/src/inc/cfe_sb.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,16 @@ typedef union {
}CFE_SB_Msg_t;

/** \brief Generic Software Bus Command Header Type Definition */
typedef CCSDS_CommandPacket_t CFE_SB_CmdHdr_t;
typedef union {
CCSDS_CommandPacket_t Cmd;
CFE_SB_Msg_t BaseMsg; /**< Base type (primary header) */
} CFE_SB_CmdHdr_t;

/** \brief Generic Software Bus Telemetry Header Type Definition */
typedef CCSDS_TelemetryPacket_t CFE_SB_TlmHdr_t;
typedef union {
CCSDS_TelemetryPacket_t Tlm;
CFE_SB_Msg_t BaseMsg; /**< Base type (primary header) */
} CFE_SB_TlmHdr_t;

#define CFE_SB_CMD_HDR_SIZE (sizeof(CFE_SB_CmdHdr_t))/**< \brief Size of #CFE_SB_CmdHdr_t in bytes */
#define CFE_SB_TLM_HDR_SIZE (sizeof(CFE_SB_TlmHdr_t))/**< \brief Size of #CFE_SB_TlmHdr_t in bytes */
Expand Down
4 changes: 2 additions & 2 deletions fsw/cfe-core/src/inc/cfe_time_msg.h
Original file line number Diff line number Diff line change
Expand Up @@ -878,7 +878,7 @@ typedef struct
*/
typedef struct
{
uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE];
CFE_SB_CmdHdr_t CmdHeader;

} CFE_TIME_ToneSignalCmd_t;

Expand All @@ -888,7 +888,7 @@ typedef struct
*/
typedef struct
{
uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE];
CFE_SB_CmdHdr_t CmdHeader;

} CFE_TIME_FakeToneCmd_t;

Expand Down
30 changes: 15 additions & 15 deletions fsw/cfe-core/src/sb/cfe_sb_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,21 +211,21 @@ CFE_TIME_SysTime_t CFE_SB_GetMsgTime(CFE_SB_MsgPtr_t MsgPtr)

#if (CFE_MISSION_SB_PACKET_TIME_FORMAT == CFE_MISSION_SB_TIME_32_16_SUBS)

memcpy(&LocalSecs32, &TlmHdrPtr->Sec.Time[0], 4);
memcpy(&LocalSubs16, &TlmHdrPtr->Sec.Time[4], 2);
memcpy(&LocalSecs32, &TlmHdrPtr->Tlm.Sec.Time[0], 4);
memcpy(&LocalSubs16, &TlmHdrPtr->Tlm.Sec.Time[4], 2);
/* convert packet data into CFE_TIME_SysTime_t format */
LocalSubs32 = ((uint32) LocalSubs16) << 16;

#elif (CFE_MISSION_SB_PACKET_TIME_FORMAT == CFE_MISSION_SB_TIME_32_32_SUBS)

memcpy(&LocalSecs32, &TlmHdrPtr->Sec.Time[0], 4);
memcpy(&LocalSubs32, &TlmHdrPtr->Sec.Time[4], 4);
memcpy(&LocalSecs32, &TlmHdrPtr->Tlm.Sec.Time[0], 4);
memcpy(&LocalSubs32, &TlmHdrPtr->Tlm.Sec.Time[4], 4);
/* no conversion necessary -- packet format = CFE_TIME_SysTime_t format */

#elif (CFE_MISSION_SB_PACKET_TIME_FORMAT == CFE_MISSION_SB_TIME_32_32_M_20)

memcpy(&LocalSecs32, &TlmHdrPtr->Sec.Time[0], 4);
memcpy(&LocalSubs32, &TlmHdrPtr->Sec.Time[4], 4);
memcpy(&LocalSecs32, &TlmHdrPtr->Tlm.Sec.Time[0], 4);
memcpy(&LocalSubs32, &TlmHdrPtr->Tlm.Sec.Time[4], 4);
/* convert packet data into CFE_TIME_SysTime_t format */
LocalSubs32 = CFE_TIME_Micro2SubSecs((LocalSubs32 >> 12));

Expand Down Expand Up @@ -267,23 +267,23 @@ int32 CFE_SB_SetMsgTime(CFE_SB_MsgPtr_t MsgPtr, CFE_TIME_SysTime_t NewTime)

/* convert time from CFE_TIME_SysTime_t format to packet format */
LocalSubs16 = (uint16) (NewTime.Subseconds >> 16);
memcpy(&TlmHdrPtr->Sec.Time[0], &NewTime.Seconds, 4);
memcpy(&TlmHdrPtr->Sec.Time[4], &LocalSubs16, 2);
memcpy(&TlmHdrPtr->Tlm.Sec.Time[0], &NewTime.Seconds, 4);
memcpy(&TlmHdrPtr->Tlm.Sec.Time[4], &LocalSubs16, 2);
Result = CFE_SUCCESS;

#elif (CFE_MISSION_SB_PACKET_TIME_FORMAT == CFE_MISSION_SB_TIME_32_32_SUBS)

/* no conversion necessary -- packet format = CFE_TIME_SysTime_t format */
memcpy(&TlmHdrPtr->Sec.Time[0], &NewTime.Seconds, 4);
memcpy(&TlmHdrPtr->Sec.Time[4], &NewTime.Subseconds, 4);
memcpy(&TlmHdrPtr->Tlm.Sec.Time[0], &NewTime.Seconds, 4);
memcpy(&TlmHdrPtr->Tlm.Sec.Time[4], &NewTime.Subseconds, 4);
Result = CFE_SUCCESS;

#elif (CFE_MISSION_SB_PACKET_TIME_FORMAT == CFE_MISSION_SB_TIME_32_32_M_20)

/* convert time from CFE_TIME_SysTime_t format to packet format */
LocalSubs32 = CFE_TIME_Sub2MicroSecs(NewTime.Subseconds) << 12;
memcpy(&TlmHdrPtr->Sec.Time[0], &NewTime.Seconds, 4);
memcpy(&TlmHdrPtr->Sec.Time[4], &LocalSubs32, 4);
memcpy(&TlmHdrPtr->Tlm.Sec.Time[0], &NewTime.Seconds, 4);
memcpy(&TlmHdrPtr->Tlm.Sec.Time[4], &LocalSubs32, 4);
Result = CFE_SUCCESS;

#endif
Expand Down Expand Up @@ -319,7 +319,7 @@ uint16 CFE_SB_GetCmdCode(CFE_SB_MsgPtr_t MsgPtr)
/* Cast the input pointer to a Cmd Msg pointer */
CmdHdrPtr = (CFE_SB_CmdHdr_t *)MsgPtr;

return CCSDS_RD_FC(CmdHdrPtr->Sec);
return CCSDS_RD_FC(CmdHdrPtr->Cmd.Sec);
}/* end CFE_SB_GetCmdCode */


Expand All @@ -339,7 +339,7 @@ int32 CFE_SB_SetCmdCode(CFE_SB_MsgPtr_t MsgPtr,
/* Cast the input pointer to a Cmd Msg pointer */
CmdHdrPtr = (CFE_SB_CmdHdr_t *)MsgPtr;

CCSDS_WR_FC(CmdHdrPtr->Sec,CmdCode);
CCSDS_WR_FC(CmdHdrPtr->Cmd.Sec,CmdCode);

return CFE_SUCCESS;

Expand All @@ -362,7 +362,7 @@ uint16 CFE_SB_GetChecksum(CFE_SB_MsgPtr_t MsgPtr)
/* cast the input pointer to a Cmd Msg pointer */
CmdHdrPtr = (CFE_SB_CmdHdr_t *)MsgPtr;

return CCSDS_RD_CHECKSUM(CmdHdrPtr->Sec);
return CCSDS_RD_CHECKSUM(CmdHdrPtr->Cmd.Sec);

}/* end CFE_SB_GetChecksum */

Expand Down
4 changes: 2 additions & 2 deletions fsw/cfe-core/src/time/cfe_time_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ typedef struct
/*
** Local 1Hz wake-up command packet (not related to time at tone)...
*/
CCSDS_CommandPacket_t Local1HzCmd;
CFE_SB_CmdHdr_t Local1HzCmd;

/*
** Time at the tone command packets (sent by time servers)...
Expand All @@ -294,7 +294,7 @@ typedef struct
* "tone signal" message above.
*/
#if (CFE_MISSION_TIME_CFG_FAKE_TONE == true)
CCSDS_CommandPacket_t ToneSendCmd;
CFE_SB_CmdHdr_t ToneSendCmd;
#endif

/*
Expand Down
2 changes: 1 addition & 1 deletion fsw/cfe-core/unit-test/sb_UT.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ void Test_SB_Macros(void)
*/
void Test_SB_CCSDSSecHdr_Macros(void)
{
CFE_SB_CmdHdr_t NoParamPkt;
CCSDS_CommandPacket_t NoParamPkt;

uint32 ExpRtn;
uint32 ActRtn;
Expand Down

0 comments on commit 7a608f0

Please sign in to comment.