diff --git a/modules/msg/fsw/src/cfe_msg_msgid_v1.c b/modules/msg/fsw/src/cfe_msg_msgid_v1.c index 47c002a0c..fe8ef8156 100644 --- a/modules/msg/fsw/src/cfe_msg_msgid_v1.c +++ b/modules/msg/fsw/src/cfe_msg_msgid_v1.c @@ -65,8 +65,9 @@ int32 CFE_MSG_SetMsgId(CFE_MSG_Message_t *MsgPtr, CFE_SB_MsgId_t MsgId) return CFE_MSG_BAD_ARGUMENT; } - MsgPtr->CCSDS.Pri.StreamId[0] = (uint8)(msgidval >> 8); - MsgPtr->CCSDS.Pri.StreamId[1] = (uint8)(msgidval); + /* Shift and mask bytes to be endian agnostic */ + MsgPtr->CCSDS.Pri.StreamId[0] = (msgidval >> 8) & 0xFF; + MsgPtr->CCSDS.Pri.StreamId[1] = msgidval & 0xFF; return CFE_SUCCESS; }