From 129164bd31b84aa4fabefaedcc8602a715b56231 Mon Sep 17 00:00:00 2001 From: Jacob Hageman Date: Wed, 10 Jun 2020 15:02:53 -0400 Subject: [PATCH] Fix #711, Minor bug fixes --- fsw/cfe-core/src/msg/CMakeLists.txt | 6 ++-- fsw/cfe-core/src/msg/src/cfe_msg_ccsdsext.c | 14 ++++---- .../src/msg/src/cfe_msg_initdefaulthdr_v2.c | 35 +++++++++++++++++++ fsw/cfe-core/src/msg/src/cfe_msg_msgid_v2.c | 4 +-- 4 files changed, 46 insertions(+), 13 deletions(-) create mode 100644 fsw/cfe-core/src/msg/src/cfe_msg_initdefaulthdr_v2.c diff --git a/fsw/cfe-core/src/msg/CMakeLists.txt b/fsw/cfe-core/src/msg/CMakeLists.txt index b3baab4d1..a35fa9c17 100644 --- a/fsw/cfe-core/src/msg/CMakeLists.txt +++ b/fsw/cfe-core/src/msg/CMakeLists.txt @@ -28,12 +28,10 @@ set(MODULE_SRCS if (MISSION_INCLUDE_CCSDSEXT_HEADER) list(APPEND MODULE_SRCS src/cfe_msg_ccsdsext.c - src/cfe_msg_initdefaulthdr_v2.c -) + src/cfe_msg_initdefaulthdr_v2.c) else (MISSION_INCLUDE_CCSDSEXT_HEADER) list(APPEND MODULE_SRCS - src/cfe_msg_initdefaulthdr_v1.c -) + src/cfe_msg_initdefaulthdr_v1.c) endif (MISSION_INCLUDE_CCSDSEXT_HEADER) add_library(${MODULE_NAME} STATIC ${MODULE_SRCS}) diff --git a/fsw/cfe-core/src/msg/src/cfe_msg_ccsdsext.c b/fsw/cfe-core/src/msg/src/cfe_msg_ccsdsext.c index 37403b3cf..03a6358e8 100644 --- a/fsw/cfe-core/src/msg/src/cfe_msg_ccsdsext.c +++ b/fsw/cfe-core/src/msg/src/cfe_msg_ccsdsext.c @@ -51,7 +51,7 @@ void CFE_MSG_SetDefaultCCSDSExt(CFE_MSG_Message_t *MsgPtr) /* Default bits of the subsystem, for whatever isn't set by MsgId */ CFE_MSG_SetSubsystem(MsgPtr, (CFE_MSG_Subsystem_t)CFE_PLATFORM_DEFAULT_SUBSYS); - CFE_MSB_SetSystem(MsgPtr, (CFE_MSG_System_t)CFE_MISSION_SPACECRAFT_ID); + CFE_MSG_SetSystem(MsgPtr, (CFE_MSG_System_t)CFE_MISSION_SPACECRAFT_ID); } /****************************************************************************** @@ -188,7 +188,7 @@ int32 CFE_MSG_GetSubsystem(const CFE_MSG_Message_t *MsgPtr, CFE_MSG_Subsystem_t return CFE_MSG_BAD_ARGUMENT; } - CFE_MSG_GetHeaderField(MsgPtr->CCSDS.Ext.Subsystem, Subsystem, CFE_MSG_SUBSYSTEM_MASK); + CFE_MSG_GetHeaderField(MsgPtr->CCSDS.Ext.Subsystem, Subsystem, CFE_MSG_SUBSYS_MASK); return CFE_SUCCESS; } @@ -198,12 +198,12 @@ int32 CFE_MSG_GetSubsystem(const CFE_MSG_Message_t *MsgPtr, CFE_MSG_Subsystem_t */ int32 CFE_MSG_SetSubsystem(CFE_MSG_Message_t *MsgPtr, CFE_MSG_Subsystem_t Subsystem) { - if (MsgPtr == NULL || ((Subsystem & CFE_MSG_SUBSYSTEM_MASK) != 0)) + if (MsgPtr == NULL || ((Subsystem & CFE_MSG_SUBSYS_MASK) != 0)) { return CFE_MSG_BAD_ARGUMENT; } - CFE_MSG_SetHeaderField(MsgPtr->CCSDS.Ext.Subsystem, Subsystem, CFE_MSG_SUBSYSTEM_MASK); + CFE_MSG_SetHeaderField(MsgPtr->CCSDS.Ext.Subsystem, Subsystem, CFE_MSG_SUBSYS_MASK); return CFE_SUCCESS; } @@ -219,7 +219,7 @@ int32 CFE_MSG_GetSystem(const CFE_MSG_Message_t *MsgPtr, CFE_MSG_System_t *Syste return CFE_MSG_BAD_ARGUMENT; } - *System = (MSGPtr->CCSDS.Ext.SystemId[0] << 8) + MsgPtr->CCSDS.Ext.SystemId[1]; + *System = (MsgPtr->CCSDS.Ext.SystemId[0] << 8) + MsgPtr->CCSDS.Ext.SystemId[1]; return CFE_SUCCESS; } @@ -234,8 +234,8 @@ int32 CFE_MSG_SetSystem(CFE_MSG_Message_t *MsgPtr, CFE_MSG_System_t System) return CFE_MSG_BAD_ARGUMENT; } - MSGPtr->CCSDS.Ext.SystemId[0] = (System >> 8) & 0xFF; - MSGPtr->CCSDS.Ext.SystemId[1] = System & 0xFF; + MsgPtr->CCSDS.Ext.SystemId[0] = (System >> 8) & 0xFF; + MsgPtr->CCSDS.Ext.SystemId[1] = System & 0xFF; return CFE_SUCCESS; } diff --git a/fsw/cfe-core/src/msg/src/cfe_msg_initdefaulthdr_v2.c b/fsw/cfe-core/src/msg/src/cfe_msg_initdefaulthdr_v2.c new file mode 100644 index 000000000..c11f15347 --- /dev/null +++ b/fsw/cfe-core/src/msg/src/cfe_msg_initdefaulthdr_v2.c @@ -0,0 +1,35 @@ +/* +** GSC-18128-1, "Core Flight Executive Version 6.7" +** +** Copyright (c) 2006-2019 United States Government as represented by +** the Administrator of the National Aeronautics and Space Administration. +** All Rights Reserved. +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +/****************************************************************************** + * Message default header initialization - implementation without CCSDS + * extended header + */ +#include "cfe_msg_hdr.h" +#include "cfe_msg_defaults.h" + +/****************************************************************************** + * Top level message initialization - See header file for details + */ +void CFE_MSG_InitDefaultHdr(CFE_MSG_Message_t *MsgPtr) +{ + CFE_MSG_SetDefaultCCSDSPri(MsgPtr); + CFE_MSG_SetDefaultCCSDSExt(MsgPtr); +} diff --git a/fsw/cfe-core/src/msg/src/cfe_msg_msgid_v2.c b/fsw/cfe-core/src/msg/src/cfe_msg_msgid_v2.c index 5f40d3ab0..e266ec008 100644 --- a/fsw/cfe-core/src/msg/src/cfe_msg_msgid_v2.c +++ b/fsw/cfe-core/src/msg/src/cfe_msg_msgid_v2.c @@ -69,7 +69,7 @@ int32 CFE_MSG_GetMsgId(const CFE_MSG_Message_t *MsgPtr, CFE_SB_MsgId_t *MsgId) { msgidval |= CFE_MSG_MSGID_TYPE_MASK; } - msgidval |= (MsgPtr->CCSDS.Ext.APIDQSubsystem[1] << 8) & CFE_MSG_MSGID_SUBSYS_MASK; + msgidval |= (MsgPtr->CCSDS.Ext.Subsystem[1] << 8) & CFE_MSG_MSGID_SUBSYS_MASK; *MsgId = CFE_SB_ValueToMsgId(msgidval); @@ -94,7 +94,7 @@ int32 CFE_MSG_SetMsgId(CFE_MSG_Message_t *MsgPtr, CFE_SB_MsgId_t MsgId) (MsgPtr->CCSDS.Pri.StreamId[1] & ~CFE_MSG_MSGID_APID_MASK) | (msgidval & CFE_MSG_MSGID_APID_MASK); /* Set APIDQ Subsystem bits */ - MsgPtr->CCSDS.Ext.APIDQSubsystem[1] = ((msgidval & CFE_MSG_MSGID_SUBSYS_MASK) >> 8); + MsgPtr->CCSDS.Ext.Subsystem[1] = ((msgidval & CFE_MSG_MSGID_SUBSYS_MASK) >> 8); /* Set type, ignores return since no failure action */ if ((msgidval & CFE_MSG_MSGID_TYPE_MASK) != 0)