-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix nasa#711, Seperate sechdr access functions
Also enables source selection and out-of-tree mission defined overrides
- Loading branch information
Showing
7 changed files
with
368 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,168 @@ | ||
/* | ||
** 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 access APIs | ||
*/ | ||
|
||
#ifndef _cfe_msg_ | ||
#define _cfe_msg_ | ||
|
||
/* | ||
* Includes | ||
*/ | ||
#include "common_types.h" | ||
#include "cfe_mission_cfg.h" | ||
#include "cfe_sb.h" | ||
|
||
/** @defgroup CFEAPIMSGChecksum cFE Checksum Control APIs | ||
* @{ | ||
*/ | ||
|
||
/*****************************************************************************/ | ||
/** | ||
** \brief Gets the checksum field from a software bus message. | ||
** | ||
** \par Description | ||
** This routine gets the checksum (or other message integrity check | ||
** value) from a software bus message. The contents and location of | ||
** this field will depend on the underlying implementation of software | ||
** bus messages. It may be a checksum, a CRC, or some other algorithm. | ||
** Users should not call this function as part of a message integrity | ||
** check (call #CFE_SB_ValidateChecksum instead). | ||
** | ||
** \par Assumptions, External Events, and Notes: | ||
** - If the underlying implementation of software bus messages does not | ||
** include a checksum field, then this routine will return a zero. | ||
** | ||
** \param[in] MsgPtr A pointer to the buffer that contains the software bus message. | ||
** This must point to the first byte of the message header. | ||
** | ||
** \return The checksum included in the software bus message header (if present), otherwise, | ||
** returns a checksum value of zero. | ||
**/ | ||
uint16 CFE_MSG_GetChecksum(CFE_SB_MsgPtr_t MsgPtr); | ||
|
||
/*****************************************************************************/ | ||
/** | ||
** \brief Calculates and sets the checksum of a software bus message | ||
** | ||
** \par Description | ||
** This routine calculates the checksum of a software bus message according | ||
** to an implementation-defined algorithm. Then, it sets the checksum field | ||
** in the message with the calculated value. The contents and location of | ||
** this field will depend on the underlying implementation of software bus | ||
** messages. It may be a checksum, a CRC, or some other algorithm. | ||
** | ||
** \par Assumptions, External Events, and Notes: | ||
** - If the underlying implementation of software bus messages does not | ||
** include a checksum field, then this routine will do nothing. | ||
** | ||
** \param[in] MsgPtr A pointer to the buffer that contains the software bus message. | ||
** This must point to the first byte of the message header. | ||
** | ||
** \sa #CFE_SB_ValidateChecksum, #CFE_SB_GetChecksum | ||
**/ | ||
void CFE_MSG_GenerateChecksum(CFE_SB_MsgPtr_t MsgPtr); | ||
|
||
/*****************************************************************************/ | ||
/** | ||
** \brief Validates the checksum of a software bus message. | ||
** | ||
** \par Description | ||
** This routine calculates the expected checksum of a software bus message | ||
** according to an implementation-defined algorithm. Then, it checks the | ||
** calculated value against the value in the message's checksum. If the | ||
** checksums do not match, this routine will generate an event message | ||
** reporting the error. | ||
** | ||
** \par Assumptions, External Events, and Notes: | ||
** - If the underlying implementation of software bus messages does not | ||
** include a checksum field, then this routine will always return \c true. | ||
** | ||
** \param[in] MsgPtr A pointer to the buffer that contains the software bus message. | ||
** This must point to the first byte of the message header. | ||
** | ||
** \return Boolean checksum result | ||
** \retval true The checksum field in the packet is valid. | ||
** \retval false The checksum field in the packet is not valid or the message type is wrong. | ||
** | ||
** \sa #CFE_SB_GenerateChecksum, #CFE_SB_GetChecksum | ||
**/ | ||
bool CFE_MSG_ValidateChecksum(CFE_SB_MsgPtr_t MsgPtr); | ||
/**@}*/ | ||
|
||
/** @defgropu CFEAPIMSGCmdCode cFE Command Code APIs | ||
* @{ | ||
*/ | ||
|
||
/*****************************************************************************/ | ||
/** | ||
** \brief Sets the command code field in a software bus message. | ||
** | ||
** \par Description | ||
** This routine sets the command code of a software bus message (if SB | ||
** messages are implemented as CCSDS packets, this will be the function code). | ||
** | ||
** \par Assumptions, External Events, and Notes: | ||
** - If the underlying implementation of software bus messages does not | ||
** include a command code field, then this routine will do nothing to | ||
** the message contents and will return #CFE_SB_WRONG_MSG_TYPE. | ||
** | ||
** \param[in] MsgPtr A pointer to the buffer that contains the software bus message. | ||
** This must point to the first byte of the message header. | ||
** | ||
** \param[in] CmdCode The command code to include in the message. | ||
** | ||
** \return Execution status, see \ref CFEReturnCodes | ||
** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS | ||
** \retval #CFE_SB_WRONG_MSG_TYPE \copybrief CFE_SB_WRONG_MSG_TYPE | ||
** | ||
**/ | ||
int32 CFE_MSG_SetCmdCode(CFE_SB_MsgPtr_t MsgPtr, | ||
uint16 CmdCode); | ||
|
||
/*****************************************************************************/ | ||
/** | ||
** \brief Gets the command code field from a software bus message. | ||
** | ||
** \par Description | ||
** This routine gets the command code from a software bus message (if | ||
** SB messages are implemented as CCSDS packets, this will be the function | ||
** code). | ||
** | ||
** \par Assumptions, External Events, and Notes: | ||
** - If the underlying implementation of software bus messages does not | ||
** include a command code field, then this routine will return a zero. | ||
** | ||
** \param[in] MsgPtr A pointer to the buffer that contains the software bus message. | ||
** This must point to the first byte of the message header. | ||
** | ||
** \return The command code included in the software bus message header (if present). | ||
** Otherwise, returns a command code value of zero. | ||
** | ||
** \sa #CFE_SB_GetUserData, #CFE_SB_GetMsgId, #CFE_SB_GetUserDataLength, #CFE_SB_GetTotalMsgLength, | ||
** #CFE_SB_GetMsgTime, #CFE_SB_SetCmdCode, #CFE_SB_GetChecksum | ||
**/ | ||
uint16 CFE_MSG_GetCmdCode(CFE_SB_MsgPtr_t MsgPtr); | ||
|
||
/**@}*/ | ||
|
||
#endif /* _cfe_msg_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
################################################################## | ||
# | ||
# cFE message module CMake build recipe | ||
# | ||
# This CMakeLists.txt adds source files for | ||
# message module included in the cFE distribution. Selected | ||
# files are built into a static library that in turn | ||
# is linked into the final executable. | ||
# | ||
# Note this is different than applications which are dynamically | ||
# linked to support runtime loading. The core applications all | ||
# use static linkage. | ||
# | ||
################################################################## | ||
|
||
# Add the basic set of files which are always built | ||
set(CFE_ALL_MODULE_SRCS ${CFE_ALL_MODULE_SRCS} | ||
${CMAKE_CURRENT_SOURCE_DIR}/cfe_msg_checksum.c | ||
${CMAKE_CURRENT_SOURCE_DIR}/cfe_msg_fc.c | ||
PARENT_SCOPE | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* | ||
** 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. | ||
*/ | ||
|
||
/****************************************************************************** | ||
* Checksum field access functions | ||
*/ | ||
#include "cfe_msg.h" | ||
#include "cfe_sb.h" | ||
|
||
/****************************************************************************** | ||
* Get checksum - See API and header file for details | ||
*/ | ||
uint16 CFE_MSG_GetChecksum(CFE_SB_MsgPtr_t MsgPtr) | ||
{ | ||
CFE_SB_CmdHdr_t *CmdHdrPtr; | ||
|
||
/* if msg type is telemetry or there is no secondary hdr... */ | ||
if((CCSDS_RD_TYPE(MsgPtr->Hdr) == CCSDS_TLM)||(CCSDS_RD_SHDR(MsgPtr->Hdr) == 0)){ | ||
return 0; | ||
}/* end if */ | ||
|
||
/* cast the input pointer to a Cmd Msg pointer */ | ||
CmdHdrPtr = (CFE_SB_CmdHdr_t *)MsgPtr; | ||
|
||
return CCSDS_RD_CHECKSUM(CmdHdrPtr->Cmd.Sec); | ||
} | ||
|
||
/****************************************************************************** | ||
* Calculate and set checksum field - See API and header file for details | ||
*/ | ||
void CFE_MSG_GenerateChecksum(CFE_SB_MsgPtr_t MsgPtr) | ||
{ | ||
CCSDS_CommandPacket_t *CmdPktPtr; | ||
|
||
/* if msg type is telemetry or there is no secondary hdr... */ | ||
if((CCSDS_RD_TYPE(MsgPtr->Hdr) == CCSDS_TLM)||(CCSDS_RD_SHDR(MsgPtr->Hdr) == 0)){ | ||
return; | ||
}/* end if */ | ||
|
||
CmdPktPtr = (CCSDS_CommandPacket_t *)MsgPtr; | ||
|
||
CCSDS_LoadCheckSum(CmdPktPtr); | ||
} | ||
|
||
/****************************************************************************** | ||
* Validate checksum - See API and header file for details | ||
*/ | ||
bool CFE_MSG_ValidateChecksum(CFE_SB_MsgPtr_t MsgPtr) | ||
{ | ||
CCSDS_CommandPacket_t *CmdPktPtr; | ||
|
||
/* if msg type is telemetry or there is no secondary hdr... */ | ||
if((CCSDS_RD_TYPE(MsgPtr->Hdr) == CCSDS_TLM)||(CCSDS_RD_SHDR(MsgPtr->Hdr) == 0)){ | ||
return false; | ||
}/* end if */ | ||
|
||
CmdPktPtr = (CCSDS_CommandPacket_t *)MsgPtr; | ||
|
||
return CCSDS_ValidCheckSum (CmdPktPtr); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
** 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. | ||
*/ | ||
|
||
/****************************************************************************** | ||
* Command function code field access functions | ||
*/ | ||
#include "cfe_msg.h" | ||
#include "cfe_sb.h" | ||
#include "cfe_error.h" | ||
|
||
/****************************************************************************** | ||
* Get Command function code - See API and header file for details | ||
*/ | ||
uint16 CFE_MSG_GetCmdCode(CFE_SB_MsgPtr_t MsgPtr) | ||
{ | ||
CFE_SB_CmdHdr_t *CmdHdrPtr; | ||
|
||
/* if msg type is telemetry or there is no secondary hdr, return 0 */ | ||
if((CCSDS_RD_TYPE(MsgPtr->Hdr) == CCSDS_TLM)||(CCSDS_RD_SHDR(MsgPtr->Hdr) == 0)){ | ||
return 0; | ||
}/* end if */ | ||
|
||
/* Cast the input pointer to a Cmd Msg pointer */ | ||
CmdHdrPtr = (CFE_SB_CmdHdr_t *)MsgPtr; | ||
|
||
return CCSDS_RD_FC(CmdHdrPtr->Cmd.Sec); | ||
} | ||
|
||
/****************************************************************************** | ||
* Set Command function code - See API and header file for details | ||
*/ | ||
int32 CFE_MSG_SetCmdCode(CFE_SB_MsgPtr_t MsgPtr, | ||
uint16 CmdCode) | ||
{ | ||
CFE_SB_CmdHdr_t *CmdHdrPtr; | ||
|
||
/* if msg type is telemetry or there is no secondary hdr... */ | ||
if((CCSDS_RD_TYPE(MsgPtr->Hdr) == CCSDS_TLM)||(CCSDS_RD_SHDR(MsgPtr->Hdr) == 0)){ | ||
return CFE_SB_WRONG_MSG_TYPE; | ||
}/* end if */ | ||
|
||
/* Cast the input pointer to a Cmd Msg pointer */ | ||
CmdHdrPtr = (CFE_SB_CmdHdr_t *)MsgPtr; | ||
|
||
CCSDS_WR_FC(CmdHdrPtr->Cmd.Sec,CmdCode); | ||
|
||
return CFE_SUCCESS; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
//TODO add header | ||
#include "cfe_sb.h" | ||
|
||
/* | ||
* Function: CFE_SB_SetMsgTime - See API and header file for details | ||
*/ | ||
int32 CFE_SB_SetMsgTime(CFE_SB_MsgPtr_t MsgPtr, CFE_TIME_SysTime_t NewTime) | ||
{ | ||
//TODO implement | ||
return CFE_SUCCESS; | ||
} | ||
|
||
/* | ||
* Function: CFE_SB_GetMsgTime - See API and header file for details | ||
*/ | ||
CFE_TIME_SysTime_t CFE_SB_GetMsgTime(CFE_SB_MsgPtr_t MsgPtr) | ||
{ | ||
CFE_TIME_SysTime_t TimeFromMsg; | ||
|
||
//TODO implement | ||
return TimeFromMsg; | ||
} | ||
|
Oops, something went wrong.