Skip to content

Commit

Permalink
CFS-42: Add SB and SBR Files
Browse files Browse the repository at this point in the history
  • Loading branch information
astrogeco committed Apr 19, 2021
1 parent cb7dbec commit f394953
Show file tree
Hide file tree
Showing 25 changed files with 9,668 additions and 0 deletions.
834 changes: 834 additions & 0 deletions modules/core_api/fsw/inc/cfe_sb.h

Large diffs are not rendered by default.

160 changes: 160 additions & 0 deletions modules/core_api/fsw/inc/cfe_sb_api_typedefs.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
/*
** 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.
*/

/**
* @file
*
* Purpose:
* This header file contains all definitions for the cFE Software Bus
* Application Programmer's Interface.
*
* Author: R.McGraw/SSI
*
*/

#ifndef CFE_SB_API_TYPEDEFS_H
#define CFE_SB_API_TYPEDEFS_H

/*
** Includes
*/
#include "common_types.h"
#include "cfe_sb_extern_typedefs.h"
#include "cfe_msg_api_typedefs.h"
#include "cfe_resourceid_api_typedefs.h"
#include "cfe_msg_hdr.h"

/*
** Defines
*/
#define CFE_SB_POLL 0 /**< \brief Option used with #CFE_SB_ReceiveBuffer to request immediate pipe status */
#define CFE_SB_PEND_FOREVER -1 /**< \brief Option used with #CFE_SB_ReceiveBuffer to force a wait for next message */
#define CFE_SB_SUBSCRIPTION 0 /**< \brief Subtype specifier used in #CFE_SB_SingleSubscriptionTlm_t by SBN App */
#define CFE_SB_UNSUBSCRIPTION 1 /**< \brief Subtype specified used in #CFE_SB_SingleSubscriptionTlm_t by SBN App */

/* ------------------------------------------------------ */
/* Macro Constants for use with the CFE_SB_MsgId_t type */
/* ------------------------------------------------------ */

/**
* \brief Translation macro to convert from MsgId integer values to opaque/abstract API values
*
* This conversion exists in macro form to allow compile-time evaluation for constants, and
* should not be used directly in application code.
*
* For applications, use the CFE_SB_ValueToMsgId() inline function instead.
*
* \sa CFE_SB_ValueToMsgId()
*/
#define CFE_SB_MSGID_WRAP_VALUE(val) ((CFE_SB_MsgId_t)(val))

/**
* \brief Translation macro to convert to MsgId integer values from opaque/abstract API values
*
* This conversion exists in macro form to allow compile-time evaluation for constants, and
* should not be used directly in application code.
*
* For applications, use the CFE_SB_MsgIdToValue() inline function instead.
*
* \sa CFE_SB_MsgIdToValue()
*/
#define CFE_SB_MSGID_UNWRAP_VALUE(mid) ((CFE_SB_MsgId_Atom_t)(mid))

/**
* \brief Reserved value for CFE_SB_MsgId_t that will not match any valid MsgId
*
* This rvalue macro can be used for static/compile-time data initialization to ensure that
* the initialized value does not alias to a valid MsgId object.
*/
#define CFE_SB_MSGID_RESERVED CFE_SB_MSGID_WRAP_VALUE(-1)

/**
* \brief A literal of the CFE_SB_MsgId_t type representing an invalid ID
*
* This value should be used for runtime initialization of CFE_SB_MsgId_t values.
*
* \note This may be a compound literal in a future revision. Per C99, compound
* literals are lvalues, not rvalues, so this value should not be used in
* static/compile-time data initialization. For static data initialization
* purposes (rvalue), #CFE_SB_MSGID_RESERVED should be used instead.
* However, in the current implementation, they are equivalent.
*/
#define CFE_SB_INVALID_MSG_ID CFE_SB_MSGID_RESERVED

/**
* \brief Cast/Convert a generic CFE_ResourceId_t to a CFE_SB_PipeId_t
*/
#define CFE_SB_PIPEID_C(val) ((CFE_SB_PipeId_t)CFE_RESOURCEID_WRAP(val))

/**
* \brief A CFE_SB_PipeId_t value which is always invalid
*
* This may be used as a safe initializer for CFE_SB_PipeId_t values
*/
#define CFE_SB_INVALID_PIPE CFE_SB_PIPEID_C(CFE_RESOURCEID_UNDEFINED)

/*
** Pipe option bit fields.
*/
#define CFE_SB_PIPEOPTS_IGNOREMINE \
0x00000001 /**< \brief Messages sent by the app that owns this pipe will not be sent to this pipe. */

#define CFE_SB_DEFAULT_QOS ((CFE_SB_Qos_t) {0}) /**< \brief Default Qos macro */

/*
** Type Definitions
*/

/** \brief Software Bus generic message */
typedef union CFE_SB_Msg
{
CFE_MSG_Message_t Msg; /**< \brief Base message type without enforced alignment */
long long int LongInt; /**< \brief Align to support Long Integer */
long double LongDouble; /**< \brief Align to support Long Double */
} CFE_SB_Buffer_t;

#ifndef CFE_OMIT_DEPRECATED_6_8

/** \brief Deperecated type to minimize required changes */
typedef CFE_SB_Buffer_t CFE_SB_Msg_t;

/** \brief Deperecated type to minimize required changes */
typedef CFE_MSG_CommandHeader_t CFE_SB_CmdHdr_t;

/** \brief Deperecated type to minimize required changes */
typedef CFE_MSG_TelemetryHeader_t CFE_SB_TlmHdr_t;

#define CFE_SB_CMD_HDR_SIZE (sizeof(CFE_MSG_CommandHeader_t)) /**< \brief Size of command header */
#define CFE_SB_TLM_HDR_SIZE (sizeof(CFE_MSG_TelemetryHeader_t)) /**< \brief Size of telemetry header */

/** \brief Pointer to an SB Message */
typedef CFE_MSG_Message_t *CFE_SB_MsgPtr_t;

/** \brief CFE_SB_MsgPayloadPtr_t defined as an opaque pointer to a message Payload portion */
typedef uint8 *CFE_SB_MsgPayloadPtr_t;

#define CFE_SB_Default_Qos CFE_SB_DEFAULT_QOS /**< \deprecated use CFE_SB_DEFAULT_QOS */

#define CFE_SB_CMD_HDR_SIZE (sizeof(CFE_MSG_CommandHeader_t)) /**< \brief Size of command header */
#define CFE_SB_TLM_HDR_SIZE (sizeof(CFE_MSG_TelemetryHeader_t)) /**< \brief Size of telemetry header */

#endif /* CFE_OMIT_DEPRECATED_6_8 */

#endif /* CFE_SB_API_TYPEDEFS_H */
88 changes: 88 additions & 0 deletions modules/core_api/fsw/inc/cfe_sb_core_internal.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/*
** 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.
*/

/**
* @file
*
* Purpose:
* This header file contains all definitions for the cFE Software Bus
* Application Programmer's Interface.
*
* Author: R.McGraw/SSI
*
*/

#ifndef CFE_SB_CORE_INTERNAL_H
#define CFE_SB_CORE_INTERNAL_H

#include "common_types.h"
#include "cfe_es_extern_typedefs.h"

/*
* The internal APIs prototyped within this block are only intended to be invoked from
* other CFE core apps. They still need to be prototyped in the shared header such that
* they can be called from other core modules, but applications should not call these.
*/

/** @defgroup CFEAPISBCoreInternal cFE Internal Software Bus APIs, internal to CFE core
* @{
*/

/*****************************************************************************/
/**
** \brief Entry Point for cFE Core Application
**
** \par Description
** This is the entry point to the cFE SB Core Application.
**
** \par Assumptions, External Events, and Notes:
** None
**
******************************************************************************/
extern void CFE_SB_TaskMain(void);

/*****************************************************************************/
/**
** \brief Initializes the cFE core module API Library
**
** \par Description
** Initializes the cFE core module API Library
**
** \par Assumptions, External Events, and Notes:
** -# This function MUST be called before any module API's are called.
**
******************************************************************************/
extern int32 CFE_SB_EarlyInit(void);

/*****************************************************************************/
/**
** \brief Removes SB resources associated with specified Application
**
** \par Description
** This function is called by cFE Executive Services to cleanup after
** an Application has been terminated. It frees resources
** that have been allocated to the specified Application.
**
******************************************************************************/
extern int32 CFE_SB_CleanUpApp(CFE_ES_AppId_t AppId);

/**@}*/

#endif /* CFE_SB_CORE_INTERNAL_H */
141 changes: 141 additions & 0 deletions modules/core_api/fsw/inc/cfe_sb_extern_typedefs.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
/*
** 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.
*/

/**
* @file
*
* Declarations and prototypes for cfe_sb_extern_typedefs module
*/

#ifndef CFE_SB_EXTERN_TYPEDEFS_H
#define CFE_SB_EXTERN_TYPEDEFS_H

/* This header may be generated from an EDS file,
* tools are available and the feature is enabled */
#ifdef CFE_EDS_ENABLED_BUILD

/* Use the EDS generated version of these types */
#include "cfe_sb_eds_typedefs.h"

#else
/* Use the local definitions of these types */

#include "common_types.h"
#include "cfe_mission_cfg.h"
#include "cfe_resourceid_typedef.h"

#define CFE_SB_SUB_ENTRIES_PER_PKT 20 /**< \brief Configuration parameter used by SBN App */

/**
* @brief Label definitions associated with CFE_SB_QosPriority_Enum_t
*/
enum CFE_SB_QosPriority
{

/**
* @brief Normal priority level
*/
CFE_SB_QosPriority_LOW = 0,

/**
* @brief High priority
*/
CFE_SB_QosPriority_HIGH = 1
};

/**
* @brief Selects the priorty level for message routing
*
* @sa enum CFE_SB_QosPriority
*/
typedef uint8 CFE_SB_QosPriority_Enum_t;

/**
* @brief Label definitions associated with CFE_SB_QosReliability_Enum_t
*/
enum CFE_SB_QosReliability
{

/**
* @brief Normal (best-effort) reliability
*/
CFE_SB_QosReliability_LOW = 0,

/**
* @brief High reliability
*/
CFE_SB_QosReliability_HIGH = 1
};

/**
* @brief Selects the reliability level for message routing
*
* @sa enum CFE_SB_QosReliability
*/
typedef uint8 CFE_SB_QosReliability_Enum_t;

/**
* @brief An integer type that should be used for indexing into the Routing Table
*/
typedef uint16 CFE_SB_RouteId_Atom_t;

/**
* @brief CFE_SB_MsgId_Atom_t primitive type definition
*
* This is an integer type capable of holding any Message ID value
* Note: This value is limited via #CFE_PLATFORM_SB_HIGHEST_VALID_MSGID
*/
typedef uint32 CFE_SB_MsgId_Atom_t;

/**
* @brief CFE_SB_MsgId_t type definition
*
* Software Bus message identifier used in many SB APIs
*
* Currently this is directly mapped to the underlying holding type (not wrapped) for
* compatibility with existing usage semantics in apps (mainly switch/case statements)
*
* @note In a future version it could become a type-safe wrapper similar to the route index,
* to avoid message IDs getting mixed between other integer values.
*/
typedef CFE_SB_MsgId_Atom_t CFE_SB_MsgId_t;

/** \brief CFE_SB_PipeId_t to primitive type definition
*
* Software Bus pipe identifier used in many SB APIs, as well as SB Telemetry messages
* and data files.
*/
typedef CFE_RESOURCEID_BASE_TYPE CFE_SB_PipeId_t;

/** \brief Quality Of Service Type Definition
**
** Currently an unused parameter in #CFE_SB_SubscribeEx
** Intended to be used for interprocessor communication only
**/
typedef struct
{
uint8 Priority; /**< \brief Specify high(1) or low(0) message priority for off-board routing, currently unused */
uint8 Reliability; /**< \brief Specify high(1) or low(0) message transfer reliability for off-board routing,
currently unused */
} CFE_SB_Qos_t;

#endif /* CFE_EDS_ENABLED_BUILD */

#endif /* CFE_SB_EXTERN_TYPEDEFS_H */
Loading

0 comments on commit f394953

Please sign in to comment.