Skip to content

Commit

Permalink
Merge pull request #2474 from jphickey:fix-2473-topicid
Browse files Browse the repository at this point in the history
Fix #2473, 2475, document and use topicid numbers for cfe
  • Loading branch information
dzbaker committed Dec 12, 2023
2 parents 7ae394d + 1d6a761 commit 780e377
Show file tree
Hide file tree
Showing 37 changed files with 453 additions and 201 deletions.
79 changes: 78 additions & 1 deletion cmake/arch_build.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,81 @@ function(cfs_app_check_intf MODULE_NAME)
endfunction(cfs_app_check_intf)


##################################################################
#
# FUNCTION: setup_platform_msgids
#
# This is intended to support cases where MsgIDs for all apps
# and modules are assigned in a single/unified header file
#
function(setup_platform_msgids)

set(PLATFORM_MSGID_HEADERFILE)

# In an EDS build, the msg IDs always come from EDS, there should not be a local msgids.h file
if (NOT CFE_EDS_ENABLED_BUILD)

# Check for the presence of a platform-specific msgid file
# This uses cfe_locate_implementation_file() as this returns whether or not it found one
cfe_locate_implementation_file(PLATFORM_MSGID_HEADERFILE "msgids.h"
PREFIX ${BUILD_CONFIG} cfs
SUBDIR config
)

# If a top level file was found, then create a wrapper around it called "cfs_msgids.h"
# Note that at this point it could be a list
if (PLATFORM_MSGID_HEADERFILE)

set(TEMP_WRAPPER_FILE_CONTENT)
foreach(SELECTED_FILE ${PLATFORM_MSGID_HEADERFILE})
file(TO_NATIVE_PATH "${SELECTED_FILE}" SRC_NATIVE_PATH)
list(APPEND TEMP_WRAPPER_FILE_CONTENT "#include \"${SRC_NATIVE_PATH}\"\n")
endforeach()

# Generate a header file
generate_c_headerfile("${CMAKE_BINARY_DIR}/inc/cfs_msgids.h" ${TEMP_WRAPPER_FILE_CONTENT})
unset(TEMP_WRAPPER_FILE_CONTENT)

# From here on use the wrapper file
set(PLATFORM_MSGID_HEADERFILE "cfs_msgids.h")

endif(PLATFORM_MSGID_HEADERFILE)

endif(NOT CFE_EDS_ENABLED_BUILD)

# Finally, export a CFGFILE_SRC variable for each of the deps
# This should make each respective "mission_build" create a wrapper
# that points directly at this global file, ignoring the default
if (PLATFORM_MSGID_HEADERFILE)

# Historically there has been a cfe_msgids.h defined at the core api level
# be sure to include this in the export list
set (OUTPUT_VAR_LIST
CORE_API_CFGFILE_SRC_cfe_msgids
)

# Slight inconsistency: for CFE core components, the cfe_ prefix is omitted in DEP_NAME
# To make this work without major impact, add it back in here
foreach(DEP_NAME ${MISSION_CORE_MODULES})
string(TOUPPER "${DEP_NAME}_CFGFILE_SRC" CFGSRC)
list(APPEND OUTPUT_VAR_LIST ${CFGSRC}_cfe_${DEP_NAME}_msgids)
endforeach(DEP_NAME ${MISSION_CORE_MODULES})

foreach(DEP_NAME ${TGTSYS_${SYSVAR}_APPS} ${TGTSYS_${SYSVAR}_STATICAPPS})
string(TOUPPER "${DEP_NAME}_CFGFILE_SRC" CFGSRC)
list(APPEND OUTPUT_VAR_LIST ${CFGSRC}_${DEP_NAME}_msgids)
endforeach(DEP_NAME ${MISSION_APPS})

# This is the actual export to parent scope
foreach(VAR_NAME ${OUTPUT_VAR_LIST})
message("${VAR_NAME}=${PLATFORM_MSGID_HEADERFILE}")
set(${VAR_NAME} ${PLATFORM_MSGID_HEADERFILE} PARENT_SCOPE)
endforeach(VAR_NAME ${OUTPUT_VAR_LIST})

endif (PLATFORM_MSGID_HEADERFILE)

endfunction(setup_platform_msgids)



##################################################################
Expand Down Expand Up @@ -658,6 +733,9 @@ function(prepare)
list(REMOVE_AT BUILD_CONFIG 0)
set(BUILD_CONFIG ${BUILD_CONFIG} PARENT_SCOPE)

# Check if the user has provided a platform-specific "msgids.h" file and set up a wrapper to it
setup_platform_msgids()

# Pull in any application-specific platform-scope configuration
# This may include user configuration files such as cfe_platform_cfg.h,
# or any other configuration/preparation that needs to happen at
Expand Down Expand Up @@ -746,7 +824,6 @@ function(process_arch SYSVAR)
endif()
endforeach()


# Add all core modules
# The osal is handled explicitly (above) since this has special extra config
foreach(DEP ${MISSION_CORE_INTERFACES} ${MISSION_CORE_MODULES})
Expand Down
75 changes: 75 additions & 0 deletions cmake/mission_build.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,78 @@ function(generate_build_version_templates)

endfunction(generate_build_version_templates)

##################################################################
#
# FUNCTION: setup_global_topicids
#
# This is intended to support cases where topic IDs for all apps
# and modules are assigned in a single/unified header file
#
function(setup_global_topicids)

if (CFE_EDS_ENABLED_BUILD)

# In an EDS build, the topic IDs always come from EDS
set(MISSION_GLOBAL_TOPICID_HEADERFILE "cfe_mission_eds_designparameters.h")

else(CFE_EDS_ENABLED_BUILD)

# Check for the presence of a mission-wide/global topic ID file
# This uses cfe_locate_implementation_file() as this returns whether or not it found one
cfe_locate_implementation_file(MISSION_GLOBAL_TOPICID_HEADERFILE "global_topicids.h"
PREFIX ${MISSIONCONFIG} cfs
SUBDIR config
)

# If a top level file was found, then create a wrapper around it called "cfs_global_topicids.h"
# Note that at this point it could be a list
if (MISSION_GLOBAL_TOPICID_HEADERFILE)

set(TEMP_WRAPPER_FILE_CONTENT)
foreach(SELECTED_FILE ${MISSION_GLOBAL_TOPICID_HEADERFILE})
file(TO_NATIVE_PATH "${SELECTED_FILE}" SRC_NATIVE_PATH)
list(APPEND TEMP_WRAPPER_FILE_CONTENT "#include \"${SRC_NATIVE_PATH}\"\n")
endforeach()

# Generate a header file
generate_c_headerfile("${CMAKE_BINARY_DIR}/inc/cfs_global_topicids.h" ${TEMP_WRAPPER_FILE_CONTENT})
unset(TEMP_WRAPPER_FILE_CONTENT)

# From here on use the wrapper file
set(MISSION_GLOBAL_TOPICID_HEADERFILE "cfs_global_topicids.h")

endif(MISSION_GLOBAL_TOPICID_HEADERFILE)

endif(CFE_EDS_ENABLED_BUILD)

# Finally, export a CFGFILE_SRC variable for each of the deps
# This should make each respective "mission_build" create a wrapper
# that points directly at this global file, ignoring the default
if (MISSION_GLOBAL_TOPICID_HEADERFILE)

set (OUTPUT_VAR_LIST)

# Slight inconsistency: for CFE core components, the cfe_ prefix is omitted in DEP_NAME
# To make this work without major impact, add it back in here
foreach(DEP_NAME ${MISSION_CORE_MODULES})
string(TOUPPER "${DEP_NAME}_CFGFILE_SRC" CFGSRC)
list(APPEND OUTPUT_VAR_LIST ${CFGSRC}_cfe_${DEP_NAME}_topicids)
endforeach(DEP_NAME ${MISSION_CORE_MODULES})

foreach(DEP_NAME ${MISSION_APPS})
string(TOUPPER "${DEP_NAME}_CFGFILE_SRC" CFGSRC)
list(APPEND OUTPUT_VAR_LIST ${CFGSRC}_${DEP_NAME}_topicids)
endforeach(DEP_NAME ${MISSION_APPS})

# This is the actual export to parent scope
foreach(VAR_NAME ${OUTPUT_VAR_LIST})
set(${VAR_NAME} ${MISSION_GLOBAL_TOPICID_HEADERFILE} PARENT_SCOPE)
endforeach(VAR_NAME ${OUTPUT_VAR_LIST})

endif (MISSION_GLOBAL_TOPICID_HEADERFILE)

endfunction(setup_global_topicids)

##################################################################
#
# FUNCTION: prepare
Expand Down Expand Up @@ -348,6 +420,9 @@ function(prepare)
add_dependencies(cfe-usersguide doc-prebuild)
add_dependencies(mission-doc doc-prebuild)

# Set up the global topicid header file, if present
setup_global_topicids()

# Pull in any application-specific mission-scope configuration
# This may include user configuration files such as cfe_mission_cfg.h,
# msgid definitions, or any other configuration/preparation that needs to
Expand Down
20 changes: 9 additions & 11 deletions cmake/sample_defs/example_platform_cfg.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,26 @@
* limitations under the License.
************************************************************************/

/**
/**
* @file
*
* This header file contains the internal configuration parameters and
* typedefs with platform scope.
*
*
* This provides default values for configurable items that do NOT affect
* the interface(s) of this module. This includes internal parameters,
* path names, and limit value(s) that are relevant for a specific platform.
*
*
* @note It is no longer necessary to provide this file directly in the defs
* directory, but if present, this file is still supported/usable for backward
* directory, but if present, this file is still supported/usable for backward
* compatibility. To use this file, is should be called "cfe_platform_cfg.h".
*
*
* Going forward, more fine-grained (module/purposes-specific) header files are
* included with each submodule. These may be overridden as necessary, but only
* if a definition within that file needs to be changed from the default. This
* approach will reduce the amount of duplicate/cloned definitions and better
* approach will reduce the amount of duplicate/cloned definitions and better
* support alternative build configurations in the future.
*
*
* Note that if this file is present, the fine-grained header files noted above
* will _not_ be used.
*/
Expand Down Expand Up @@ -83,7 +83,6 @@
*/
#define CFE_PLATFORM_CORE_MAX_STARTUP_MSEC 30000


/*******************************************************************************/
/*
* CFE Executive Services (CFE_ES) Application Private Config Definitions
Expand Down Expand Up @@ -1726,7 +1725,7 @@
*/
#define CFE_PLATFORM_TIME_START_TASK_PRIORITY 60
#define CFE_PLATFORM_TIME_TONE_TASK_PRIORITY 25
#define CFE_PLATFORM_TIME_1HZ_TASK_PRIORITY 25
#define CFE_PLATFORM_TIME_ONEHZ_TASK_PRIORITY 25

/**
** \cfetimecfg Define TIME Task Stack Sizes
Expand All @@ -1745,7 +1744,6 @@
*/
#define CFE_PLATFORM_TIME_START_TASK_STACK_SIZE CFE_PLATFORM_ES_DEFAULT_STACK_SIZE
#define CFE_PLATFORM_TIME_TONE_TASK_STACK_SIZE 4096
#define CFE_PLATFORM_TIME_1HZ_TASK_STACK_SIZE 8192
#define CFE_PLATFORM_TIME_ONEHZ_TASK_STACK_SIZE 8192

#endif /* EXAMPLE_PLATFORM_CFG_H */

4 changes: 2 additions & 2 deletions docs/src/cfe_time.dox
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@
TIME provides the ability to command a one time adjustment
(#CFE_TIME_ADD_ADJUST_CC and #CFE_TIME_SUB_ADJUST_CC)
to the current STCF. In addition there is a 1Hz adjustment
(#CFE_TIME_ADD_1HZ_ADJUSTMENT_CC and #CFE_TIME_SUB_1HZ_ADJUSTMENT_CC)
(#CFE_TIME_ADD_ONEHZ_ADJUSTMENT_CC and #CFE_TIME_SUB_ONEHZ_ADJUSTMENT_CC)
that can be made to the STCF to compensate for oscillator drift.
Mission specific ground correlation should be used to assist in
determining the proper values to use. The Leap Seconds should be
Expand All @@ -671,7 +671,7 @@
to by the other systems.

\sa #CFE_TIME_ADD_ADJUST_CC, #CFE_TIME_SUB_ADJUST_CC, #CFE_TIME_SET_STCF_CC,
#CFE_TIME_ADD_1HZ_ADJUSTMENT_CC, #CFE_TIME_SUB_1HZ_ADJUSTMENT_CC, #CFE_TIME_SET_LEAP_SECONDS_CC
#CFE_TIME_ADD_ONEHZ_ADJUSTMENT_CC, #CFE_TIME_SUB_ONEHZ_ADJUSTMENT_CC, #CFE_TIME_SET_LEAP_SECONDS_CC
**/


Expand Down
4 changes: 2 additions & 2 deletions modules/cfe_testcase/config/default_cfe_test_msgids.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@
/*
** cFE Command Message Id's
*/
#define CFE_TEST_CMD_MID CFE_PLATFORM_CMD_MID_BASE + CFE_MISSION_TEST_CMD_MSG /* 0x1802 */
#define CFE_TEST_CMD_MID CFE_PLATFORM_CMD_TOPICID_TO_MIDV(CFE_MISSION_TEST_CMD_TOPICID) /* 0x1802 */

/*
** CFE Telemetry Message Id's
*/
#define CFE_TEST_HK_TLM_MID CFE_PLATFORM_TLM_MID_BASE + CFE_MISSION_TEST_HK_TLM_MSG /* 0x0802 */
#define CFE_TEST_HK_TLM_MID CFE_PLATFORM_TLM_TOPICID_TO_MIDV(CFE_MISSION_TEST_HK_TLM_TOPICID) /* 0x0802 */

#endif
4 changes: 2 additions & 2 deletions modules/cfe_testcase/config/default_cfe_test_topicids.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
** \par Limits
** Not Applicable
*/
#define CFE_MISSION_TEST_CMD_MSG 2
#define CFE_MISSION_TEST_CMD_TOPICID 2

/**
** \cfemissioncfg cFE Portable Message Numbers for Telemetry
Expand All @@ -43,6 +43,6 @@
** \par Limits
** Not Applicable
*/
#define CFE_MISSION_TEST_HK_TLM_MSG 2
#define CFE_MISSION_TEST_HK_TLM_TOPICID 2

#endif
2 changes: 1 addition & 1 deletion modules/cfe_testcase/src/sb_subscription_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ void TestSBMaxSubscriptions(void)
while (NumSubs <= CFE_PLATFORM_SB_MAX_MSG_IDS)
{
/* fabricate a msgid to subscribe to (this may overlap real msgids) */
TestMsgId = CFE_SB_ValueToMsgId(CFE_PLATFORM_CMD_MID_BASE + NumSubs);
TestMsgId = CFE_SB_ValueToMsgId(1 + NumSubs);

Status = CFE_SB_Subscribe(TestMsgId, PipeId);
if (Status != CFE_SUCCESS)
Expand Down
32 changes: 21 additions & 11 deletions modules/core_api/arch_build.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,27 @@
###########################################################

# Generate the "cfe_platform_cfg.h" and "cfe_msgids.h" header files
# these must come from mission config
# these usually come from user config, but CFE provides defaults

generate_config_includefile(
FILE_NAME "cfe_msgids.h"
MATCH_SUFFIX "msgids.h"
FALLBACK_FILE "${CMAKE_CURRENT_LIST_DIR}/config/default_cfe_msgids.h"
PREFIXES ${BUILD_CONFIG} cfe
set(CORE_API_PLATFORM_CONFIG_FILE_LIST
cfe_core_api_base_msgids.h
cfe_msgids.h
)

generate_config_includefile(
FILE_NAME "cfe_core_api_base_msgids.h"
FALLBACK_FILE "${CMAKE_CURRENT_LIST_DIR}/config/default_cfe_core_api_base_msgids.h"
PREFIXES ${BUILD_CONFIG}
)
# Create wrappers around the all the config header files
# This makes them individually overridable by the missions, without modifying
# the distribution default copies
foreach(CORE_API_CFGFILE ${CORE_API_PLATFORM_CONFIG_FILE_LIST})
get_filename_component(CFGKEY "${CORE_API_CFGFILE}" NAME_WE)
if (DEFINED CORE_API_CFGFILE_SRC_${CFGKEY})
set(DEFAULT_SOURCE GENERATED_FILE "${CORE_API_CFGFILE_SRC_${CFGKEY}}")
else()
set(DEFAULT_SOURCE FALLBACK_FILE "${CMAKE_CURRENT_LIST_DIR}/config/default_${CORE_API_CFGFILE}")
endif()

generate_config_includefile(
FILE_NAME "${CORE_API_CFGFILE}"
PREFIXES ${BUILD_CONFIG} cfe
${DEFAULT_SOURCE}
)
endforeach()
Loading

0 comments on commit 780e377

Please sign in to comment.