├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md └── pull_request_template.md ├── LICENSE.txt ├── README.md ├── cfecfs ├── CMakeLists.txt ├── eds2cfetbl │ ├── CMakeLists.txt │ ├── eds2cfetbl.c │ └── scripts │ │ ├── add_cfe_tables_impl.cmake │ │ ├── eds2cfetbl_rules.mk │ │ ├── eds_tbltool_filedef.h │ │ ├── extract_filedef.awk │ │ ├── extract_object.awk │ │ ├── extract_varname.m4 │ │ ├── generate_eds_table_rules.cmake │ │ ├── table_rule_template.d.in │ │ └── tabletool_rule.mk ├── edsmsg │ ├── CMakeLists.txt │ ├── eds │ │ ├── ccsds_spacepacket.xml │ │ └── cfe_hdr.xml │ ├── fsw │ │ ├── inc │ │ │ └── cfe_msg_hdr_eds.h │ │ └── src │ │ │ ├── cfe_msg_commonhdr.c │ │ │ ├── cfe_msg_dispatcher.c │ │ │ ├── cfe_msg_init.c │ │ │ ├── cfe_msg_integrity.c │ │ │ ├── cfe_msg_msgid.c │ │ │ ├── cfe_msg_sechdr_cmd.c │ │ │ └── cfe_msg_sechdr_tlm.c │ └── mission_build.cmake ├── missionlib │ ├── CMakeLists.txt │ ├── arch_build.cmake │ ├── cmake │ │ ├── cfe_mission_eds_interface_parameters.h.in │ │ ├── cfe_mission_eds_parameters.h.in │ │ ├── edstool-buildenv.d.in │ │ ├── edstool-execute-arch.mk │ │ ├── edstool-execute-mission.mk │ │ └── edstool-sources.d.in │ ├── eds │ │ ├── 70-cfe_sb_parameter_map.lua │ │ ├── 74-cfe_sb_msg_topic_ids.lua │ │ ├── 75-cfe_sb_dispatch_tables.lua │ │ ├── 76-cfe_sb_interfacedb_global.lua │ │ ├── 80-build_cfe_sb_interfacedb.lua │ │ ├── 85-write_commandcode_headers.lua │ │ ├── 90-write_ccdd_json.lua │ │ ├── 90-write_intf_hierarchy.lua │ │ ├── 91-write_cosmos_txt.lua │ │ └── instance-rules.xml │ ├── fsw │ │ ├── CMakeLists.txt │ │ ├── inc │ │ │ ├── cfe_missionlib_api.h │ │ │ └── cfe_missionlib_runtime.h │ │ ├── src │ │ │ ├── cfe_missionlib_api.c │ │ │ ├── cfe_missionlib_database_types.h │ │ │ └── cfe_missionlib_runtime_default.c │ │ └── ut-stubs │ │ │ ├── CMakeLists.txt │ │ │ ├── cfe_missionlib_api_handlers.c │ │ │ ├── cfe_missionlib_api_stubs.c │ │ │ ├── cfe_missionlib_runtime_handlers.c │ │ │ ├── cfe_missionlib_runtime_stubs.c │ │ │ ├── cfe_missionlib_stub_helpers.c │ │ │ └── cfe_missionlib_stub_helpers.h │ ├── lua │ │ ├── CMakeLists.txt │ │ ├── inc │ │ │ └── cfe_missionlib_lua_softwarebus.h │ │ └── src │ │ │ └── cfe_missionlib_lua_softwarebus.c │ ├── mission_build.cmake │ └── python │ │ ├── CMakeLists.txt │ │ ├── inc │ │ └── cfe_missionlib_python.h │ │ └── src │ │ ├── cfe_missionlib_python_database.c │ │ ├── cfe_missionlib_python_interface.c │ │ ├── cfe_missionlib_python_internal.h │ │ ├── cfe_missionlib_python_module.c │ │ ├── cfe_missionlib_python_setup.c │ │ └── cfe_missionlib_python_topic.c ├── scriptengine │ ├── CMakeLists.txt │ ├── fsw │ │ ├── inc │ │ │ └── scriptengine.h │ │ └── src │ │ │ ├── scriptengine.c │ │ │ └── scriptengine_internal.h │ ├── scripts │ │ └── testscript.lua │ └── ut-stubs │ │ ├── CMakeLists.txt │ │ └── scriptengine_stubs.c ├── testexecutive │ ├── CMakeLists.txt │ ├── inc │ │ └── testexec.h │ ├── modules │ │ ├── ci_to_lab_interface.c │ │ └── remote_interface.c │ └── src │ │ ├── test_interface.c │ │ ├── testctrl.c │ │ └── testexec.c └── util │ ├── CMakeLists.txt │ ├── cmdUtil.c │ └── tlm_decode.c ├── doc ├── .gitignore ├── Makefile ├── eds-dom-reference.md ├── seds-dom-example.png └── seds-dom-interfaces.png ├── edslib ├── CMakeLists.txt ├── Doxyfile ├── cmake │ └── dbobj_patternrules.mk ├── configtest │ └── edslib_longdouble.c ├── doc │ ├── .gitignore │ └── images │ │ ├── compilation.png │ │ ├── overview.png │ │ ├── prebuild.png │ │ └── verification.png ├── eds │ ├── 40-seds_write_headers.lua │ ├── 45-seds_write_datatypedb_objects.lua │ ├── 50-seds_write_displaydb_objects.lua │ └── 55-write_edsdb_makefiles.lua ├── fsw │ ├── CMakeLists.txt │ ├── edsfsw.dox │ ├── inc │ │ ├── edslib_api_types.h │ │ ├── edslib_binding_objects.h │ │ ├── edslib_database_types.h │ │ ├── edslib_datatypedb.h │ │ ├── edslib_displaydb.h │ │ ├── edslib_id.h │ │ └── edslib_init.h │ ├── src │ │ ├── edslib_binding_objects.c │ │ ├── edslib_datatypedb_api.c │ │ ├── edslib_datatypedb_constraints.c │ │ ├── edslib_datatypedb_errorcontrol.c │ │ ├── edslib_datatypedb_iterator.c │ │ ├── edslib_datatypedb_load_store.c │ │ ├── edslib_datatypedb_lookup.c │ │ ├── edslib_datatypedb_pack_unpack.c │ │ ├── edslib_displaydb_api.c │ │ ├── edslib_displaydb_base64.c │ │ ├── edslib_displaydb_iterator.c │ │ ├── edslib_displaydb_locate.c │ │ ├── edslib_displaydb_lookup.c │ │ ├── edslib_displaydb_stringconv.c │ │ ├── edslib_init.c │ │ ├── edslib_internal.h │ │ └── edslib_msgid_api.c │ └── ut-stubs │ │ ├── CMakeLists.txt │ │ ├── edslib_binding_objects_stubs.c │ │ ├── edslib_datatypedb_stubs.c │ │ ├── edslib_displaydb_stubs.c │ │ └── edslib_init_stubs.c ├── json │ ├── CMakeLists.txt │ ├── inc │ │ └── edslib_json_objects.h │ └── src │ │ └── edslib_json_objects.c ├── lua │ ├── CMakeLists.txt │ ├── inc │ │ ├── edslib_lua51_compatibility.h │ │ └── edslib_lua_objects.h │ └── src │ │ └── edslib_lua_objects.c ├── mainpage.dox ├── python │ ├── CMakeLists.txt │ ├── inc │ │ └── edslib_python.h │ └── src │ │ ├── edslib_python_accessor.c │ │ ├── edslib_python_array.c │ │ ├── edslib_python_base.c │ │ ├── edslib_python_buffer.c │ │ ├── edslib_python_container.c │ │ ├── edslib_python_conversions.c │ │ ├── edslib_python_database.c │ │ ├── edslib_python_databaseentry.c │ │ ├── edslib_python_dynamicarray.c │ │ ├── edslib_python_internal.h │ │ ├── edslib_python_module.c │ │ ├── edslib_python_number.c │ │ ├── edslib_python_packedobject.c │ │ ├── edslib_python_scalar.c │ │ └── edslib_python_setup.c └── unit-test │ ├── CMakeLists.txt │ ├── eds │ ├── UT1.xml │ ├── UTHDR.xml │ └── ut-base-types.xml │ ├── edslib_basic_test.c │ ├── edslib_full_test.c │ └── edslib_test.c └── tool ├── CMakeLists.txt ├── edsbuild.dox ├── scripts ├── 05-seds_parse_defines.lua ├── 10-seds_resolve_refs.lua ├── 15-seds_create_implicit_scalars.lua ├── 20-seds_resolve_sizes.lua ├── 25-seds_resolve_constraints.lua ├── 30-seds_resolve_components.lua └── 85-seds_write_resolved_xml.lua └── src ├── seds_checksum.c ├── seds_checksum.h ├── seds_generic_props.c ├── seds_generic_props.h ├── seds_global.h ├── seds_instance_methods.lua ├── seds_instance_node.c ├── seds_instance_node.h ├── seds_memreq.c ├── seds_memreq.h ├── seds_outputfile.c ├── seds_outputfile.h ├── seds_plugin.c ├── seds_plugin.h ├── seds_preprocess.c ├── seds_preprocess.h ├── seds_runtime.lua ├── seds_tool_main.c ├── seds_tree_methods.lua ├── seds_tree_node.c ├── seds_tree_node.h ├── seds_user_message.c ├── seds_user_message.h ├── seds_xmlparser.c └── seds_xmlparser.h /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Code snips** 24 | If applicable, add references to the software. 25 | 26 | **System observed on:** 27 | - Hardware 28 | - OS: [e.g. Linux 4.4] 29 | - Versions [e.g. cFE 6.6, OSAL 4.2, PSP 1.3 for mcp750, any related apps] 30 | 31 | **Additional context** 32 | Add any other context about the problem here. 33 | 34 | **Reporter Info** 35 | Full name and company/organization if applicable 36 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context about the feature request here. 21 | 22 | **Requester Info** 23 | Full name and company/organization if applicable 24 | -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | **Describe the contribution** 2 | A clear and concise description of what the contribution is. 3 | - Include explicitly what issue it addresses [e.g. Fixes #X] 4 | 5 | **Testing performed** 6 | Steps taken to test the contribution: 7 | 1. Build steps '...' 8 | 1. Execution steps '...' 9 | 10 | **Expected behavior changes** 11 | A clear and concise description of how this contribution will change behavior and level of impact. 12 | - API Change: xxx (if applicable) 13 | - Behavior Change: xxx (if applicable) 14 | - Or no impact to behavior 15 | 16 | **System(s) tested on** 17 | - Hardware: [e.g. PC, SP0, MCP750] 18 | - OS: [e.g. Ubuntu 18.04, RTEMS 4.11, VxWorks 6.9] 19 | - Versions: [e.g. cFE 6.6, OSAL 4.2, PSP 1.3 for mcp750, any related apps or tools] 20 | 21 | **Additional context** 22 | Add any other context about the contribution here. 23 | 24 | **Third party code** 25 | If included, identify any third party code and provide text file of license 26 | 27 | **Contributor Info - All information REQUIRED for consideration of pull request** 28 | Full name and company/organization/center of all contributors ("Personal" if individual work) 29 | - If NASA Civil Servant Employee or GSFC Contractor on SES III 30 | - Address/email/phone and contract/task information (if applicable) must be on file 31 | - Else if Company 32 | - **HAND SIGNED** Company CLA must be on file (once per release): [Company CLA](https://github.com/nasa/bplib/blob/main/doc/GSC_18318_Corp_CLA_form_1219.pdf) 33 | - Else if Individual 34 | - **HAND SIGNED** Individual CLA must be on file (once per release): [Individual CLA](https://github.com/nasa/bplib/blob/main/doc/GSC_18318_Ind_CLA_form_1219.pdf) 35 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CCSDS SOIS Electronic Data Sheet Tool and Library 2 | 3 | This repository contains an implementation of a tool and runtime library 4 | for embedded software to create and interpret data structures defined 5 | using Electronic Data Sheets per CCSDS book 876.0. 6 | 7 | The full specification for Electronic Data Sheets is available here: 8 | 9 | [CCSDS 876.0-B-1](https://public.ccsds.org/Pubs/876x0b1.pdf) 10 | 11 | This repository contains the basic tool to process EDS files, a 12 | runtime library (EdsLib) for embedded software, and libraries 13 | to interoperate with JSON, Lua, and Python. 14 | 15 | This software is also intended to work with the Core Flight System: 16 | 17 | [cFS](https://github.com/nasa/cFS) 18 | 19 | A set of patches to CFS to enable EDS features is also available. 20 | 21 | ## General Overview 22 | 23 | The tool reads all EDS files and generates an in-memory document object model (DOM) 24 | structure which can then be queried by scripts which can in turn generate derived outputs 25 | based on the EDS information. 26 | 27 | This DOM is conceptually similar to the Javascript DOM of HTML documents in a web browser, 28 | but very different in terms of usage and implementation as it represents a very different 29 | type of document. 30 | 31 | Scripts currently exist for generating C header files and runtime data structures to work 32 | with the accompanying EdsLib runtime library. However, applications can supply additional 33 | scripts and generate custom outputs from the same DOM. 34 | 35 | ## Components 36 | 37 | The following subdirectories are contained within this source tree: 38 | 39 | - `tool` contains the build tool to read EDS files, generate the DOM tree, and run scripts 40 | - `edslib` contains the runtime C library for dealing with EDS-defined objects 41 | - `doc` contains additional information about the DOM structure 42 | - `cfecfs` contains additional bindings/libraries for use with Core Flight System 43 | 44 | A separate CMake script is included in each subdirectory for building each component. 45 | 46 | ## Execution 47 | 48 | Once built, the tool is executed by supplying a set of XML files and processing 49 | scripts on the command line, such as: 50 | 51 | ``` 52 | $ sedstool MyEDSFile1.xml MyEDSFile2.xml MyScript1.lua MyScript2.lua ... 53 | ``` 54 | 55 | A few command line options are recognized: 56 | 57 | - `-v` : Increase verbosity level. Use twice for full debug trace. 58 | - `-D NAME=VALUE` : Sets the symbolic NAME to VALUE for preprocessor substitutions 59 | 60 | 61 | However, this tool is generally _not_ intended to be executed manually in a standalone 62 | installation, but built and executed as part of a larger application build system, such 63 | as Core Flight System (cFS). 64 | 65 | The tool will first read _all_ the supplied XML files and build a DOM tree, and then it 66 | will invoke each Lua script _in alphanumeric order_ of filename. Ordering is 67 | very important, as each script can build upon the results of the prior scripts. To preserve 68 | the intended order of operations, each script supplied with this tool contains a two digit 69 | numeric prefix, which indicates the correct position in the set. This way, when scripts are 70 | executed in a simple alphanumeric order, and this will always produce the correct result. 71 | Furthermore, additional scripts can be added into the sequence simply by choosing an appropriate 72 | prefix number, without needing to specify explicit dependencies or complicated rules. 73 | -------------------------------------------------------------------------------- /cfecfs/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # LEW-19710-1, CCSDS SOIS Electronic Data Sheet Implementation 3 | # 4 | # Copyright (c) 2020 United States Government as represented by 5 | # the Administrator of the National Aeronautics and Space Administration. 6 | # All Rights Reserved. 7 | # 8 | # Licensed under the Apache License, Version 2.0 (the "License"); 9 | # you may not use this file except in compliance with the License. 10 | # You may obtain a copy of the License at 11 | # 12 | # http://www.apache.org/licenses/LICENSE-2.0 13 | # 14 | # Unless required by applicable law or agreed to in writing, software 15 | # distributed under the License is distributed on an "AS IS" BASIS, 16 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | # See the License for the specific language governing permissions and 18 | # limitations under the License. 19 | # 20 | 21 | # EDS CFE/CFS top level makefile 22 | # There are no targets here directly, they are all in subdirectories 23 | 24 | add_subdirectory(missionlib) 25 | add_subdirectory(eds2cfetbl) 26 | add_subdirectory(util) 27 | 28 | # the test executive is an optional component to provide a black-box 29 | # style test framework. It is built using OSAL and UT-Assert. 30 | if (ENABLE_EDS_TESTEXEC) 31 | add_subdirectory(testexecutive) 32 | endif (ENABLE_EDS_TESTEXEC) 33 | -------------------------------------------------------------------------------- /cfecfs/eds2cfetbl/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # LEW-19710-1, CCSDS SOIS Electronic Data Sheet Implementation 3 | # 4 | # Copyright (c) 2020 United States Government as represented by 5 | # the Administrator of the National Aeronautics and Space Administration. 6 | # All Rights Reserved. 7 | # 8 | # Licensed under the Apache License, Version 2.0 (the "License"); 9 | # you may not use this file except in compliance with the License. 10 | # You may obtain a copy of the License at 11 | # 12 | # http://www.apache.org/licenses/LICENSE-2.0 13 | # 14 | # Unless required by applicable law or agreed to in writing, software 15 | # distributed under the License is distributed on an "AS IS" BASIS, 16 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | # See the License for the specific language governing permissions and 18 | # limitations under the License. 19 | # 20 | 21 | # This utility implements a tool to generate a CFE/CFS table 22 | # data file from an EDS-based table definition 23 | project(EDS2CFETBL C) 24 | 25 | include_directories(${LUALIB_INCLUDE_DIRS}) 26 | include_directories(${EDSLIB_FSW_SOURCE_DIR}/inc) 27 | include_directories(${EDSLIB_LUABINDINGS_SOURCE_DIR}/inc) 28 | include_directories(${EDS_CFECFS_MISSIONLIB_FSW_SOURCE_DIR}/inc) 29 | include_directories(${EDS_CFECFS_MISSIONLIB_LUABINDINGS_SOURCE_DIR}/inc) 30 | 31 | add_executable(eds2cfetbl eds2cfetbl.c) 32 | add_dependencies(eds2cfetbl edstool-execute) 33 | target_link_libraries(eds2cfetbl 34 | edslib_lua 35 | cfe_missionlib_lua_softwarebus 36 | edslib_runtime_static 37 | cfe_missionlib_interfacedb_static 38 | cfe_edsdb_static 39 | dl 40 | ) 41 | set_target_properties(eds2cfetbl PROPERTIES ENABLE_EXPORTS TRUE) 42 | 43 | # Export relevant information so the parent script can invoke the tool 44 | set(CFS_TABLETOOL_SCRIPT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/scripts" CACHE INTERNAL "CFS table tool script directory") 45 | 46 | add_custom_target(tabletool-execute 47 | COMMAND $(MAKE) 48 | CC="${CMAKE_C_COMPILER}" 49 | CFLAGS="${CMAKE_C_FLAGS}" 50 | AR="${CMAKE_AR}" 51 | TBLTOOL="$" 52 | cfetables 53 | WORKING_DIRECTORY 54 | "${MISSION_BINARY_DIR}/tables" 55 | DEPENDS 56 | mission-cfetables 57 | eds2cfetbl 58 | ) 59 | 60 | add_dependencies(mission-all tabletool-execute) 61 | add_dependencies(mission-install tabletool-execute) 62 | add_dependencies(mission-prebuild eds2cfetbl) 63 | 64 | install(DIRECTORY ${CMAKE_BINARY_DIR}/tables/staging/ DESTINATION .) 65 | -------------------------------------------------------------------------------- /cfecfs/eds2cfetbl/scripts/eds2cfetbl_rules.mk: -------------------------------------------------------------------------------- 1 | # Rules for EDS-based CFE table generation 2 | 3 | # the basic set of flags to pass to the table tool 4 | TBLTOOL_FLAGS += -e MISSION_DEFS=\"$(MISSION_DEFS)\" 5 | TBLTOOL_FLAGS += -e CPUNAME=\"$(CFE_TABLE_CPUNAME)\" 6 | TBLTOOL_FLAGS += -e APPNAME=\"$(CFE_TABLE_APPNAME)\" 7 | TBLTOOL_FLAGS += -e TABLENAME=\"$(CFE_TABLE_BASENAME)\" 8 | 9 | LOCAL_CFLAGS += $(addprefix -D,$(C_COMPILE_DEFS)) 10 | LOCAL_CFLAGS += $(addprefix -I,$(C_INCLUDE_DIRS)) 11 | LOCAL_CFLAGS += -DCFE_TABLE_NAME="$(CFE_TABLE_BASENAME)" 12 | 13 | AWK ?= /usr/bin/awk 14 | M4 ?= /usr/bin/m4 15 | 16 | .PRECIOUS: eds/%.c 17 | 18 | # This needs to strip comments from the original C file - 19 | # the best way to do that is to send it through the C preprocessor (-E switch) 20 | # NOTE: by defining CFE_TBL_FILEDEF_H here, we effectively squelch the normal CFE definition of the macro. 21 | # this way we can use our own macro definition instead, and actually evaluate it several different ways. 22 | eds/%.source: 23 | @mkdir -pv $(dir $(@)) 24 | echo "$(<)" > "$(@)" 25 | 26 | eds/%.filedef: SRC=$(shell cat $(@:.filedef=.source)) 27 | eds/%.filedef: eds/%.source $(TABLETOOL_SCRIPT_DIR)/extract_filedef.awk 28 | $(CC) -E -MMD -MF "$(notdir $(@)).d" -MT "$(@)" -DCFE_TBL_FILEDEF_H $(CFLAGS) $(LOCAL_CFLAGS) -o "$(@).tmp" "$(SRC)" 29 | $(AWK) -v SRC="$(SRC)" -f "$(TABLETOOL_SCRIPT_DIR)/extract_filedef.awk" "$(@).tmp" > "$(@).out" 30 | mv "$(@).out" "$(@)" 31 | rm -f "$(@).tmp" 32 | 33 | eds/%.objname: eds/%.filedef $(TABLETOOL_SCRIPT_DIR)/extract_varname.m4 34 | $(M4) -P "$(TABLETOOL_SCRIPT_DIR)/extract_varname.m4" "$(<)" > "$(@)" 35 | 36 | eds/%.c: SRC=$(shell cat $(@:.c=.source)) 37 | eds/%.c: OBJNAME=$(shell cat $(@:.c=.objname)) 38 | eds/%.c: eds/%.objname $(TABLETOOL_SCRIPT_DIR)/extract_object.awk 39 | $(AWK) -v SRC="$(SRC)" -v OBJNAME="$(OBJNAME)" -f "$(TABLETOOL_SCRIPT_DIR)/extract_object.awk" "$(SRC)" > "$(@).out" 40 | mv "$(@).out" "$(@)" 41 | 42 | eds/%.o: eds/%.c $(TABLETOOL_SCRIPT_DIR)/eds_tbltool_filedef.h 43 | $(CC) -Wall -Werror -fPIC -g $(CFLAGS) $(LOCAL_CFLAGS) -include "$(TABLETOOL_SCRIPT_DIR)/eds_tbltool_filedef.h" -o "$(@)" -c "$(<)" 44 | 45 | %.so: %.o 46 | $(CC) $(CFLAGS) -shared -o $(@) $(<) 47 | -------------------------------------------------------------------------------- /cfecfs/eds2cfetbl/scripts/eds_tbltool_filedef.h: -------------------------------------------------------------------------------- 1 | #ifndef EDS_TBLTOOL_FILEDEF_H 2 | #define EDS_TBLTOOL_FILEDEF_H 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | EdsDataType_CFE_SB_MsgIdValue_t CFE_SB_CmdTopicIdToMsgId(uint16_t TopicId, uint16_t InstanceNum); 10 | EdsDataType_CFE_SB_MsgIdValue_t CFE_SB_TlmTopicIdToMsgId(uint16_t TopicId, uint16_t InstanceNum); 11 | 12 | uint16_t EdsTableTool_GetProcessorId(void); 13 | void EdsTableTool_DoExport(void *arg, const void *filedefptr, const void *obj, size_t sz); 14 | 15 | 16 | static inline EdsDataType_CFE_SB_MsgIdValue_t CFE_SB_GlobalCmdTopicIdToMsgId(uint16_t TopicId) 17 | { 18 | /* Instance number 0 is used for globals */ 19 | return CFE_SB_CmdTopicIdToMsgId(TopicId, 0); 20 | } 21 | 22 | static inline EdsDataType_CFE_SB_MsgIdValue_t CFE_SB_GlobalTlmTopicIdToMsgId(uint16_t TopicId) 23 | { 24 | /* Instance number 0 is used for globals */ 25 | return CFE_SB_TlmTopicIdToMsgId(TopicId, 0); 26 | } 27 | 28 | static inline EdsDataType_CFE_SB_MsgIdValue_t CFE_SB_LocalCmdTopicIdToMsgId(uint16_t TopicId) 29 | { 30 | /* PSP-reported Instance number is used for locals */ 31 | return CFE_SB_CmdTopicIdToMsgId(TopicId, EdsTableTool_GetProcessorId()); 32 | } 33 | 34 | static inline EdsDataType_CFE_SB_MsgIdValue_t CFE_SB_LocalTlmTopicIdToMsgId(uint16_t TopicId) 35 | { 36 | /* PSP-reported Instance number is used for locals */ 37 | return CFE_SB_TlmTopicIdToMsgId(TopicId, EdsTableTool_GetProcessorId()); 38 | } 39 | 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /cfecfs/eds2cfetbl/scripts/extract_filedef.awk: -------------------------------------------------------------------------------- 1 | #!/usr/bin/awk -f 2 | 3 | BEGIN { 4 | RS="\n"; 5 | ORS="\n"; 6 | FS=" "; 7 | IS_FILEDEF_MACRO=0; # set nonzero if the CFE_TBL_FILEDEF macro is found 8 | IS_FILEDEF_DIRECT=0; # set nonzero if the CFE_TBL_FileDef_t is instantiated directly (discouraged) 9 | DIRECT_CONTENT=""; 10 | } 11 | 12 | END { 13 | if (IS_FILEDEF_MACRO >= 0) { 14 | print "\nERROR: Unable to extract CFE_TBL_FILEDEF macro from: " SRC "\n" > "/dev/stderr" 15 | exit 1 16 | } 17 | } 18 | 19 | # The C preprocessor outputs lines starting with # that indicate which file it came from 20 | # We are only interested in content that was _directly_ in the table file here. 21 | /^#/ { 22 | LINE=$2; 23 | FILE=$3; 24 | next; 25 | } 26 | 27 | # Ignore anything that is not in the original source file 28 | FILE!="\"" SRC "\"" { 29 | next; 30 | } 31 | 32 | # Filedef starts at the CFE_TBL_FILEDEF macro 33 | IS_FILEDEF_MACRO==0 && /\/ { 34 | IS_FILEDEF_MACRO=1 35 | IS_FILEDEF_DIRECT=-1 36 | } 37 | 38 | IS_FILEDEF_DIRECT==0 { 39 | if ($1 == "CFE_TBL_FileDef_t") { 40 | IS_FILEDEF_DIRECT=1 41 | IS_FILEDEF_MACRO=-1 42 | } 43 | } 44 | 45 | IS_FILEDEF_DIRECT==1 { 46 | DIRECT_CONTENT=DIRECT_CONTENT $0 47 | if ($0 ~ /;/) { 48 | if (match(DIRECT_CONTENT, /{(.*)}/, OUT1) == 0) { 49 | print "\nERROR: Unable to extract CFE_TBL_FILEDEF info from direct instatiation: " DIRECT "\n" > "/dev/stderr" 50 | exit 1 51 | } 52 | # now that the CFE_TBL_FileDef_t content is identified, it first needs to be split at commas 53 | split(OUT1[1], OUT2, ",") 54 | # Then the first item taken out (only the first for now) 55 | match(OUT2[1], /"(.*)"/, OUT3) 56 | print "CFE_TBL_FILEDEF(" OUT3[1] ")" 57 | IS_FILEDEF_DIRECT=-1 58 | } 59 | } 60 | 61 | # send the "CFE_TBL_FILEDEF" macro content to the output 62 | IS_FILEDEF_MACRO==1 { 63 | print 64 | if ($0 ~ /\)/) 65 | IS_FILEDEF_MACRO=-1 66 | } 67 | -------------------------------------------------------------------------------- /cfecfs/eds2cfetbl/scripts/extract_object.awk: -------------------------------------------------------------------------------- 1 | #!/usr/bin/awk -f 2 | 3 | BEGIN { 4 | IS_DECL=0 5 | } 6 | 7 | END { 8 | if (DATATYPE) { 9 | print "const char " OBJNAME "_EDS_TYPEDEF_NAME[] = \"" DATATYPE "\";\n" 10 | } 11 | else { 12 | print "extract_object: Error: No instantiation of " OBJNAME " found in source file" > "/dev/stderr"; 13 | exit 1; 14 | } 15 | 16 | print "\n" 17 | print "void " OBJNAME "_GENERATOR(void *arg)" 18 | print "{\n" 19 | print "#include \"" SRC "\"\n" 20 | print "EdsTableTool_DoExport(arg, &CFE_TBL_FileDef, &" OBJNAME ", sizeof(" OBJNAME "));" 21 | print "}" 22 | } 23 | 24 | # This preserves the original "CFE_TBL_FILEDEF" info 25 | IS_DECL<0 { 26 | print 27 | } 28 | 29 | IS_DECL==0 { 30 | for (i=1; i < NF; i++) { 31 | if (match($i, "^" OBJNAME "\\>" ) != 0) { 32 | IS_DECL=i 33 | break 34 | } 35 | } 36 | 37 | if (IS_DECL) { 38 | for (i=1; i < IS_DECL; i++) { 39 | if ($i != "const") { 40 | DATATYPE=$i 41 | } 42 | } 43 | print DATATYPE 44 | print $IS_DECL 45 | } 46 | else { 47 | print $0 48 | } 49 | } 50 | 51 | IS_DECL > 0 && /;/ { 52 | IS_DECL=-1 53 | print ";" 54 | } 55 | -------------------------------------------------------------------------------- /cfecfs/eds2cfetbl/scripts/extract_varname.m4: -------------------------------------------------------------------------------- 1 | m4_define(CFE_TBL_FILEDEF,$1)m4_dnl 2 | -------------------------------------------------------------------------------- /cfecfs/eds2cfetbl/scripts/generate_eds_table_rules.cmake: -------------------------------------------------------------------------------- 1 | ################################################################## 2 | # 3 | # Sub-script to capture the table compile/generation environment 4 | # 5 | # This small script runs at build time (as opposed to prep time) 6 | # which captures a set of environment metadata 7 | # 8 | # It must be done this way such that generator expressions will 9 | # be evaluated now, during the arch build process, rather than 10 | # deferring the evaluation to the parent build where they may 11 | # have different values. 12 | # 13 | ################################################################## 14 | 15 | set(STAGING_DIR staging ${TARGET_NAME} ${INSTALL_SUBDIR}) 16 | string(REPLACE ";" "/" STAGING_DIR "${STAGING_DIR}") 17 | 18 | # In case the INCLUDE_DIRS is a CMake list, convert to a space-separated list 19 | list(REMOVE_DUPLICATES INCLUDE_DIRS) 20 | string(REPLACE ";" " " INCLUDE_DIRS "${INCLUDE_DIRS}") 21 | 22 | list(REMOVE_DUPLICATES COMPILE_DEFS) 23 | string(REPLACE ";" " " COMPILE_DEFS "${COMPILE_DEFS}") 24 | 25 | set(TABLE_BINARY "${STAGING_DIR}/${TABLE_NAME}.tbl") 26 | set(TMP_DIR "eds/${TARGET_NAME}") 27 | set(TABLE_RULES) 28 | 29 | foreach(TBL_SRC ${SOURCES}) 30 | 31 | if (TBL_SRC MATCHES "\\.c$") 32 | # Legacy C source files need a compile step before they can be used 33 | set(TABLE_LEGACY_FILE "${TMP_DIR}/${APP_NAME}_${TABLE_NAME}") 34 | string(APPEND TABLE_RULES 35 | "${TABLE_LEGACY_FILE}.o: C_INCLUDE_DIRS += ${INCLUDE_DIRS}\n" 36 | "${TABLE_LEGACY_FILE}.o: C_COMPILE_DEFS += ${COMPILE_DEFS}\n" 37 | "${TABLE_LEGACY_FILE}.source: ${TBL_SRC}\n" 38 | "\n") 39 | set(DEP_FILE "${TABLE_LEGACY_FILE}.so") 40 | else() 41 | # Other source files (e.g. Lua) can be used directly by the tool 42 | set(DEP_FILE "${TBL_SRC}") 43 | endif() 44 | 45 | string(APPEND TABLE_RULES 46 | "${TABLE_BINARY}: ${DEP_FILE}\n" 47 | "\n" 48 | ) 49 | 50 | endforeach() 51 | 52 | configure_file(${TEMPLATE_FILE} ${OUTPUT_FILE}) 53 | -------------------------------------------------------------------------------- /cfecfs/eds2cfetbl/scripts/table_rule_template.d.in: -------------------------------------------------------------------------------- 1 | # Template for table configuration 2 | 3 | cfetables: ${TABLE_BINARY} 4 | 5 | ${TABLE_BINARY}: CFE_TABLE_CPUNAME := ${TARGET_NAME} 6 | ${TABLE_BINARY}: CFE_TABLE_APPNAME := ${APP_NAME} 7 | ${TABLE_BINARY}: CFE_TABLE_BASENAME := ${TABLE_NAME} 8 | 9 | # Rules to build ${TABLE_BINARY} 10 | ${TABLE_RULES} 11 | -------------------------------------------------------------------------------- /cfecfs/eds2cfetbl/scripts/tabletool_rule.mk: -------------------------------------------------------------------------------- 1 | # Makefile for EDS-based CFE table generation 2 | 3 | C_INCLUDE_DIRS += $(MISSION_BINARY_DIR)/inc 4 | 5 | .PHONY: cfetables 6 | 7 | cfetables: 8 | @echo "Table build completed" 9 | 10 | # The dependency of this rule should always be a relative path starting with elf/, 11 | # at least with the current rule generator script, so it matches the elf/% pattern rule. 12 | # But because elf2cfetbl only writes its output to the current working dir, it has to be run 13 | # after changing dirs into the staging area. Thus the path to the elf file needs to be adjusted. 14 | # Ideally this chould be done with the $(abspath f...) function but this doesn't exist in older versions. 15 | # As a workaround, $CURDIR is used. 16 | staging/%.tbl: 17 | @mkdir -pv "$(dir $(@))" 18 | cd "$(dir $(@))" && $(TBLTOOL) $(TBLTOOL_FLAGS) "$(CURDIR)/$(<)" 19 | -------------------------------------------------------------------------------- /cfecfs/edsmsg/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ################################################################## 2 | # 3 | # cFE message module CMake build recipe 4 | # 5 | # This CMakeLists.txt adds source files for 6 | # message module included in the cFE distribution. Selected 7 | # files are built into a static library that in turn 8 | # is linked into the final executable. 9 | # 10 | # Note this is different than applications which are dynamically 11 | # linked to support runtime loading. The core applications all 12 | # use static linkage. 13 | # 14 | ################################################################## 15 | 16 | # Module library 17 | add_library(${DEP} STATIC 18 | fsw/src/cfe_msg_init.c 19 | fsw/src/cfe_msg_integrity.c 20 | fsw/src/cfe_msg_msgid.c 21 | fsw/src/cfe_msg_commonhdr.c 22 | 23 | fsw/src/cfe_msg_sechdr_cmd.c 24 | fsw/src/cfe_msg_sechdr_tlm.c 25 | 26 | fsw/src/cfe_msg_dispatcher.c 27 | ) 28 | 29 | target_include_directories(${DEP} PUBLIC fsw/inc) 30 | target_link_libraries(${DEP} PRIVATE core_private) 31 | -------------------------------------------------------------------------------- /cfecfs/edsmsg/eds/cfe_hdr.xml: -------------------------------------------------------------------------------- 1 | 2 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | Command codes in CFE range are 7 bits (0-127). The most significant bit (codes 128-255) are reserved. 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | The secondary message header that is present in all cFE command messages 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | The secondary message header that is present in all cFE telemetry messages 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | --> 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | --> 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | -------------------------------------------------------------------------------- /cfecfs/edsmsg/fsw/src/cfe_msg_init.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** GSC-18128-1, "Core Flight Executive Version 6.7" 3 | ** 4 | ** Copyright (c) 2006-2019 United States Government as represented by 5 | ** the Administrator of the National Aeronautics and Space Administration. 6 | ** All Rights Reserved. 7 | ** 8 | ** Licensed under the Apache License, Version 2.0 (the "License"); 9 | ** you may not use this file except in compliance with the License. 10 | ** You may obtain a copy of the License at 11 | ** 12 | ** http://www.apache.org/licenses/LICENSE-2.0 13 | ** 14 | ** Unless required by applicable law or agreed to in writing, software 15 | ** distributed under the License is distributed on an "AS IS" BASIS, 16 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | ** See the License for the specific language governing permissions and 18 | ** limitations under the License. 19 | */ 20 | 21 | #include 22 | #include 23 | 24 | /****************************************************************************** 25 | * Message initialization 26 | */ 27 | #include "cfe_msg.h" 28 | #include "cfe_time.h" 29 | #include "cfe_missionlib_runtime.h" 30 | 31 | #include "ccsds_spacepacket_eds_datatypes.h" 32 | #include "cfe_hdr_eds_datatypes.h" 33 | 34 | /*---------------------------------------------------------------- 35 | * 36 | * Function: CFE_MSG_Init 37 | * 38 | * Implemented per public API 39 | * See description in header file for argument/return detail 40 | * 41 | *-----------------------------------------------------------------*/ 42 | CFE_Status_t CFE_MSG_Init(CFE_MSG_Message_t *MsgPtr, CFE_SB_MsgId_t MsgId, CFE_MSG_Size_t Size) 43 | { 44 | EdsDataType_CCSDS_CommonHdr_t *CommonHdr; 45 | CFE_Status_t Status; 46 | 47 | if (MsgPtr == NULL || Size < sizeof(EdsDataType_CCSDS_CommonHdr_t)) 48 | { 49 | return CFE_MSG_BAD_ARGUMENT; 50 | } 51 | 52 | /* Clear and set defaults */ 53 | memset(MsgPtr, 0, Size); 54 | 55 | /* Set various fields in the MsgPtr Metadata object from the bits in MsgId */ 56 | Status = CFE_MSG_SetMsgId(MsgPtr, MsgId); 57 | if (Status == CFE_SUCCESS) 58 | { 59 | CommonHdr = (EdsDataType_CCSDS_CommonHdr_t *)MsgPtr; 60 | 61 | /* Default to complete packets */ 62 | CommonHdr->SeqFlag = 3; /* jphfix: enum? */ 63 | 64 | /* Set the standard size field */ 65 | CommonHdr->Length = Size - 7; 66 | } 67 | 68 | return Status; 69 | } 70 | -------------------------------------------------------------------------------- /cfecfs/edsmsg/fsw/src/cfe_msg_integrity.c: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes” 3 | * 4 | * Copyright (c) 2020 United States Government as represented by the 5 | * Administrator of the National Aeronautics and Space Administration. 6 | * All Rights Reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 9 | * not use this file except in compliance with the License. You may obtain 10 | * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | ************************************************************************/ 18 | 19 | #include "cfe_msg.h" 20 | #include "cfe_time.h" 21 | 22 | /*---------------------------------------------------------------- 23 | * 24 | * Implemented per public API 25 | * See description in header file for argument/return detail 26 | * 27 | *-----------------------------------------------------------------*/ 28 | CFE_Status_t CFE_MSG_OriginationAction(CFE_MSG_Message_t *MsgPtr, size_t BufferSize, bool *IsAcceptable) 29 | { 30 | if (MsgPtr == NULL || IsAcceptable == NULL) 31 | { 32 | return CFE_MSG_BAD_ARGUMENT; 33 | } 34 | 35 | /* 36 | * TLM packets have a timestamp in the secondary header. 37 | * This may fail if this is not a TLM packet (that is OK) 38 | */ 39 | CFE_MSG_SetMsgTime(MsgPtr, CFE_TIME_GetTime()); 40 | 41 | /* 42 | * CMD packets have a checksum in the secondary header. 43 | * This may fail if this is not a CMD packet (that is OK) 44 | */ 45 | CFE_MSG_GenerateChecksum(MsgPtr); 46 | 47 | /* This implementation permits all outgoing messages */ 48 | *IsAcceptable = true; 49 | 50 | return CFE_SUCCESS; 51 | } 52 | /*---------------------------------------------------------------- 53 | * 54 | * Implemented per public API 55 | * See description in header file for argument/return detail 56 | * 57 | *-----------------------------------------------------------------*/ 58 | CFE_Status_t CFE_MSG_VerificationAction(const CFE_MSG_Message_t *MsgPtr, size_t BufferSize, bool *IsAcceptable) 59 | { 60 | if (MsgPtr == NULL || IsAcceptable == NULL) 61 | { 62 | return CFE_MSG_BAD_ARGUMENT; 63 | } 64 | 65 | /* 66 | * In the default implementation, there is not anything to check here. 67 | * 68 | * This is mainly a hook for user expansion, in case a custom implementation 69 | * has message verification capability. 70 | */ 71 | *IsAcceptable = true; 72 | 73 | return CFE_SUCCESS; 74 | } -------------------------------------------------------------------------------- /cfecfs/edsmsg/fsw/src/cfe_msg_msgid.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** GSC-18128-1, "Core Flight Executive Version 6.7" 3 | ** 4 | ** Copyright (c) 2006-2019 United States Government as represented by 5 | ** the Administrator of the National Aeronautics and Space Administration. 6 | ** All Rights Reserved. 7 | ** 8 | ** Licensed under the Apache License, Version 2.0 (the "License"); 9 | ** you may not use this file except in compliance with the License. 10 | ** You may obtain a copy of the License at 11 | ** 12 | ** http://www.apache.org/licenses/LICENSE-2.0 13 | ** 14 | ** Unless required by applicable law or agreed to in writing, software 15 | ** distributed under the License is distributed on an "AS IS" BASIS, 16 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | ** See the License for the specific language governing permissions and 18 | ** limitations under the License. 19 | */ 20 | 21 | /****************************************************************************** 22 | * Message id access functions, shared cFS implementation 23 | */ 24 | #include "cfe_platform_cfg.h" 25 | #include "cfe_msg.h" 26 | #include "cfe_sb.h" 27 | #include "cfe_error.h" 28 | 29 | #include "ccsds_spacepacket_eds_datatypes.h" 30 | #include "cfe_sb_eds_datatypes.h" 31 | #include "cfe_mission_eds_parameters.h" 32 | #include "cfe_missionlib_runtime.h" 33 | 34 | /*---------------------------------------------------------------- 35 | * 36 | * Function: CFE_MSG_GetTypeFromMsgId 37 | * 38 | * Implemented per public API 39 | * See description in header file for argument/return detail 40 | * 41 | *-----------------------------------------------------------------*/ 42 | CFE_Status_t CFE_MSG_GetTypeFromMsgId(CFE_SB_MsgId_t MsgId, CFE_MSG_Type_t *Type) 43 | { 44 | CFE_Status_t Status; 45 | EdsInterface_CFE_SB_SoftwareBus_PubSub_t Params; 46 | 47 | if (Type == NULL) 48 | { 49 | Status = CFE_MSG_BAD_ARGUMENT; 50 | } 51 | else 52 | { 53 | Params.MsgId = MsgId; 54 | if (CFE_MissionLib_PubSub_IsListenerComponent(&Params)) 55 | { 56 | *Type = CFE_MSG_Type_Cmd; 57 | Status = CFE_SUCCESS; 58 | } 59 | else if (CFE_MissionLib_PubSub_IsPublisherComponent(&Params)) 60 | { 61 | *Type = CFE_MSG_Type_Tlm; 62 | Status = CFE_SUCCESS; 63 | } 64 | else 65 | { 66 | *Type = CFE_MSG_Type_Invalid; 67 | Status = CFE_MSG_BAD_ARGUMENT; 68 | } 69 | } 70 | 71 | return Status; 72 | } 73 | 74 | CFE_Status_t CFE_MSG_GetMsgId(const CFE_MSG_Message_t *MsgPtr, CFE_SB_MsgId_t *MsgId) 75 | { 76 | EdsInterface_CFE_SB_SoftwareBus_PubSub_t Params; 77 | 78 | if (MsgPtr == NULL || MsgId == NULL) 79 | { 80 | return CFE_MSG_BAD_ARGUMENT; 81 | } 82 | 83 | CFE_MissionLib_Get_PubSub_Parameters(&Params, &MsgPtr->BaseMsg); 84 | 85 | *MsgId = Params.MsgId; 86 | 87 | return CFE_SUCCESS; 88 | } 89 | 90 | CFE_Status_t CFE_MSG_SetMsgId(CFE_MSG_Message_t *MsgPtr, CFE_SB_MsgId_t MsgId) 91 | { 92 | EdsInterface_CFE_SB_SoftwareBus_PubSub_t Params; 93 | 94 | /* 95 | * NOTE: in reality the EDS may map any bits of the MsgId to the message, there is 96 | * not really a concept of a "highest" msg ID at all. However, for historical/backward 97 | * compatibility reasons, this symbol is still defined in SB. 98 | */ 99 | if (MsgPtr == NULL || !CFE_SB_IsValidMsgId(MsgId)) 100 | { 101 | return CFE_MSG_BAD_ARGUMENT; 102 | } 103 | 104 | Params.MsgId = MsgId; 105 | CFE_MissionLib_Set_PubSub_Parameters(&MsgPtr->BaseMsg, &Params); 106 | 107 | return CFE_SUCCESS; 108 | } 109 | -------------------------------------------------------------------------------- /cfecfs/edsmsg/fsw/src/cfe_msg_sechdr_cmd.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** GSC-18128-1, "Core Flight Executive Version 6.7" 3 | ** 4 | ** Copyright (c) 2006-2019 United States Government as represented by 5 | ** the Administrator of the National Aeronautics and Space Administration. 6 | ** All Rights Reserved. 7 | ** 8 | ** Licensed under the Apache License, Version 2.0 (the "License"); 9 | ** you may not use this file except in compliance with the License. 10 | ** You may obtain a copy of the License at 11 | ** 12 | ** http://www.apache.org/licenses/LICENSE-2.0 13 | ** 14 | ** Unless required by applicable law or agreed to in writing, software 15 | ** distributed under the License is distributed on an "AS IS" BASIS, 16 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | ** See the License for the specific language governing permissions and 18 | ** limitations under the License. 19 | */ 20 | 21 | /****************************************************************************** 22 | * Function code field access functions 23 | */ 24 | #include "cfe_msg.h" 25 | 26 | #include "ccsds_spacepacket_eds_datatypes.h" 27 | #include "cfe_hdr_eds_datatypes.h" 28 | 29 | /*---------------------------------------------------------------- 30 | * 31 | * Function: CFE_MSG_GetFcnCode 32 | * 33 | * Implemented per public API 34 | * See description in header file for argument/return detail 35 | * 36 | *-----------------------------------------------------------------*/ 37 | CFE_Status_t CFE_MSG_GetFcnCode(const CFE_MSG_Message_t *MsgPtr, CFE_MSG_FcnCode_t *FcnCode) 38 | { 39 | const EdsDataType_CFE_HDR_CommandHeader_t *CmdPtr; 40 | const EdsDataType_CCSDS_CommonHdr_t * CommonHdr; 41 | 42 | if (MsgPtr == NULL || FcnCode == NULL) 43 | { 44 | return CFE_MSG_BAD_ARGUMENT; 45 | } 46 | 47 | CommonHdr = (const EdsDataType_CCSDS_CommonHdr_t *)MsgPtr; 48 | 49 | /* This confirms if it is OK to access the pointer as a "CommandHeader" type */ 50 | if (CommonHdr->SecHdrFlags != CCSDS_SecHdrFlags_Cmd) 51 | { 52 | return CFE_MSG_WRONG_MSG_TYPE; 53 | } 54 | 55 | CmdPtr = (const EdsDataType_CFE_HDR_CommandHeader_t *)(const void *)MsgPtr; 56 | 57 | *FcnCode = CmdPtr->Sec.FunctionCode; 58 | 59 | return CFE_SUCCESS; 60 | } 61 | 62 | /*---------------------------------------------------------------- 63 | * 64 | * Function: CFE_MSG_SetFcnCode 65 | * 66 | * Implemented per public API 67 | * See description in header file for argument/return detail 68 | * 69 | *-----------------------------------------------------------------*/ 70 | CFE_Status_t CFE_MSG_SetFcnCode(CFE_MSG_Message_t *MsgPtr, CFE_MSG_FcnCode_t FcnCode) 71 | { 72 | EdsDataType_CFE_HDR_CommandHeader_t *CmdPtr; 73 | const EdsDataType_CCSDS_CommonHdr_t *CommonHdr; 74 | 75 | if (MsgPtr == NULL) 76 | { 77 | return CFE_MSG_BAD_ARGUMENT; 78 | } 79 | 80 | CommonHdr = (const EdsDataType_CCSDS_CommonHdr_t *)MsgPtr; 81 | 82 | /* This confirms if it is OK to access the pointer as a "CommandHeader" type */ 83 | if (CommonHdr->SecHdrFlags != CCSDS_SecHdrFlags_Cmd) 84 | { 85 | return CFE_MSG_WRONG_MSG_TYPE; 86 | } 87 | 88 | CmdPtr = (EdsDataType_CFE_HDR_CommandHeader_t *)(void *)MsgPtr; 89 | 90 | CmdPtr->Sec.FunctionCode = FcnCode; 91 | 92 | return CFE_SUCCESS; 93 | } 94 | 95 | /* 96 | * NOTE on the checksum computations, this is done by EdsLib at the time the packet goes 97 | * to/from the network or external consumer. Applications should not be dealing directly 98 | * with checksum field in commands. 99 | * 100 | * The checksum field definitely _is_ implemented, it is just not implemented here. 101 | */ 102 | 103 | /*---------------------------------------------------------------- 104 | * 105 | * Function: CFE_MSG_GenerateChecksum 106 | * 107 | * Implemented per public API 108 | * See description in header file for argument/return detail 109 | * 110 | *-----------------------------------------------------------------*/ 111 | CFE_Status_t CFE_MSG_GenerateChecksum(CFE_MSG_Message_t *MsgPtr) 112 | { 113 | return CFE_MSG_NOT_IMPLEMENTED; 114 | } 115 | 116 | /*---------------------------------------------------------------- 117 | * 118 | * Function: CFE_MSG_ValidateChecksum 119 | * 120 | * Implemented per public API 121 | * See description in header file for argument/return detail 122 | * 123 | *-----------------------------------------------------------------*/ 124 | CFE_Status_t CFE_MSG_ValidateChecksum(const CFE_MSG_Message_t *MsgPtr, bool *IsValid) 125 | { 126 | return CFE_MSG_NOT_IMPLEMENTED; 127 | } 128 | -------------------------------------------------------------------------------- /cfecfs/edsmsg/fsw/src/cfe_msg_sechdr_tlm.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** GSC-18128-1, "Core Flight Executive Version 6.7" 3 | ** 4 | ** Copyright (c) 2006-2019 United States Government as represented by 5 | ** the Administrator of the National Aeronautics and Space Administration. 6 | ** All Rights Reserved. 7 | ** 8 | ** Licensed under the Apache License, Version 2.0 (the "License"); 9 | ** you may not use this file except in compliance with the License. 10 | ** You may obtain a copy of the License at 11 | ** 12 | ** http://www.apache.org/licenses/LICENSE-2.0 13 | ** 14 | ** Unless required by applicable law or agreed to in writing, software 15 | ** distributed under the License is distributed on an "AS IS" BASIS, 16 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | ** See the License for the specific language governing permissions and 18 | ** limitations under the License. 19 | */ 20 | 21 | #include "cfe_msg.h" 22 | #include "cfe_error.h" 23 | 24 | #include "ccsds_spacepacket_eds_datatypes.h" 25 | #include "cfe_hdr_eds_datatypes.h" 26 | 27 | /*---------------------------------------------------------------- 28 | * 29 | * Function: CFE_MSG_SetMsgTime 30 | * 31 | * Implemented per public API 32 | * See description in header file for argument/return detail 33 | * 34 | *-----------------------------------------------------------------*/ 35 | CFE_Status_t CFE_MSG_SetMsgTime(CFE_MSG_Message_t *MsgPtr, CFE_TIME_SysTime_t NewTime) 36 | { 37 | EdsDataType_CFE_HDR_TelemetryHeader_t *TlmPtr; 38 | const EdsDataType_CCSDS_CommonHdr_t * CommonHdr; 39 | 40 | if (MsgPtr == NULL) 41 | { 42 | return CFE_MSG_BAD_ARGUMENT; 43 | } 44 | 45 | CommonHdr = (const EdsDataType_CCSDS_CommonHdr_t *)MsgPtr; 46 | 47 | /* This confirms if it is OK to access the pointer as a "TelemetryHeader" type */ 48 | if (CommonHdr->SecHdrFlags != CCSDS_SecHdrFlags_Tlm) 49 | { 50 | return CFE_MSG_WRONG_MSG_TYPE; 51 | } 52 | 53 | TlmPtr = (EdsDataType_CFE_HDR_TelemetryHeader_t *)(void *)MsgPtr; 54 | 55 | TlmPtr->Sec.Seconds = NewTime.Seconds; 56 | 57 | /* For 16-bit subseconds, just use the 16 MSBs of the CFE_TIME value */ 58 | if (sizeof(TlmPtr->Sec.Subseconds) == sizeof(uint16)) 59 | { 60 | TlmPtr->Sec.Subseconds = (NewTime.Subseconds >> 16) & 0xFFFF; 61 | } 62 | else 63 | { 64 | TlmPtr->Sec.Subseconds = NewTime.Subseconds; 65 | } 66 | 67 | return CFE_SUCCESS; 68 | } 69 | 70 | /*---------------------------------------------------------------- 71 | * 72 | * Function: CFE_MSG_GetMsgTime 73 | * 74 | * Implemented per public API 75 | * See description in header file for argument/return detail 76 | * 77 | *-----------------------------------------------------------------*/ 78 | CFE_Status_t CFE_MSG_GetMsgTime(const CFE_MSG_Message_t *MsgPtr, CFE_TIME_SysTime_t *Time) 79 | { 80 | const EdsDataType_CFE_HDR_TelemetryHeader_t *TlmPtr; 81 | const EdsDataType_CCSDS_CommonHdr_t * CommonHdr; 82 | 83 | if (MsgPtr == NULL || Time == NULL) 84 | { 85 | return CFE_MSG_BAD_ARGUMENT; 86 | } 87 | 88 | CommonHdr = (const EdsDataType_CCSDS_CommonHdr_t *)MsgPtr; 89 | 90 | /* This confirms if it is OK to access the pointer as a "TelemetryHeader" type */ 91 | if (CommonHdr->SecHdrFlags != CCSDS_SecHdrFlags_Tlm) 92 | { 93 | return CFE_MSG_WRONG_MSG_TYPE; 94 | } 95 | 96 | TlmPtr = (const EdsDataType_CFE_HDR_TelemetryHeader_t *)(const void *)MsgPtr; 97 | 98 | Time->Seconds = TlmPtr->Sec.Seconds; 99 | 100 | /* For 16-bit subseconds, use the value from the msg as the 16 MSBs of the CFE_TIME value */ 101 | if (sizeof(TlmPtr->Sec.Subseconds) == sizeof(uint16)) 102 | { 103 | Time->Subseconds = TlmPtr->Sec.Subseconds << 16; 104 | } 105 | else 106 | { 107 | Time->Subseconds = TlmPtr->Sec.Subseconds; 108 | } 109 | 110 | return CFE_SUCCESS; 111 | } 112 | -------------------------------------------------------------------------------- /cfecfs/edsmsg/mission_build.cmake: -------------------------------------------------------------------------------- 1 | ########################################################### 2 | # 3 | # MSG mission build setup 4 | # 5 | # This file is evaluated as part of the "prepare" stage 6 | # and can be used to set up prerequisites for the build, 7 | # such as generating header files 8 | # 9 | ########################################################### 10 | 11 | # 12 | # This just makes it so the EDS-generated headers (plus any extra required content) 13 | # is includable from applications via a known name "cfe_msg_hdr.h" 14 | # 15 | # doing this at mission scope (rather than as a target_include_directory) should also 16 | # make it available for inclusion in tools/non-CFE code 17 | # 18 | 19 | # Generate the header definition files, use local default for this module) 20 | generate_config_includefile( 21 | FILE_NAME "cfe_msg_hdr.h" 22 | FALLBACK_FILE "${CMAKE_CURRENT_LIST_DIR}/fsw/inc/cfe_msg_hdr_eds.h" 23 | ) 24 | 25 | -------------------------------------------------------------------------------- /cfecfs/missionlib/arch_build.cmake: -------------------------------------------------------------------------------- 1 | ########################################################### 2 | # 3 | # EDS CFE platform build setup 4 | # 5 | # This file is evaluated as part of the "prepare" stage 6 | # and can be used to set up prerequisites for the build, 7 | # such as generating header files 8 | # 9 | ########################################################### 10 | 11 | # on target architecture builds, the "edstool-execute" target 12 | # will not actually run the tool again. Instead, it will just build all 13 | # the generated make targets from the parent build for this processor by 14 | # supplying the correct CC/AR tool 15 | 16 | add_custom_target(edstool-execute 17 | COMMAND "\$(MAKE)" 18 | ARCH_BINARY_DIR=${CMAKE_BINARY_DIR} 19 | -f ${missionlib_MISSION_DIR}/cmake/edstool-execute-arch.mk 20 | all 21 | WORKING_DIRECTORY 22 | ${MISSION_BINARY_DIR} 23 | DEPENDS 24 | missionlib-runtime-install 25 | ) 26 | -------------------------------------------------------------------------------- /cfecfs/missionlib/cmake/cfe_mission_eds_interface_parameters.h.in: -------------------------------------------------------------------------------- 1 | /* Generated wrapper based off the real source file location */ 2 | #include "@EDS_FILE_PREFIX@_designparameters.h" 3 | #include "@EDS_FILE_PREFIX@_interfacedb.h" 4 | 5 | #define CFE_SOFTWAREBUS_INTERFACE @EDS_SYMBOL_PREFIX@_SOFTWAREBUS_INTERFACE 6 | 7 | #define EDS_DISPATCH_TABLE_ID(x) @EDS_SYMBOL_PREFIX@_DispatchTableId_ ## x 8 | #define EDS_DISPATCH_TABLE_ID_MAX @EDS_SYMBOL_PREFIX@_DispatchTableId_MAX 9 | #define EDS_INTERFACE_ID(x) @EDS_SYMBOL_PREFIX@_InterfaceId_ ## x 10 | #define EDS_INTERFACE_ID_MAX @EDS_SYMBOL_PREFIX@_InterfaceId_MAX 11 | #define EDS_INDICATION_ID(x) @EDS_SYMBOL_PREFIX@_IndicationId_ ## x ## _VALUE 12 | #define EDS_INDICATION_ID_MAX @EDS_SYMBOL_PREFIX@_IndicationId_MAX 13 | -------------------------------------------------------------------------------- /cfecfs/missionlib/cmake/cfe_mission_eds_parameters.h.in: -------------------------------------------------------------------------------- 1 | /* Generated wrapper based off the generated source file location */ 2 | #include "@EDS_FILE_PREFIX@_designparameters.h" 3 | #include "@EDS_FILE_PREFIX@_master_index.h" 4 | 5 | #define EDS_MISSION_NAME "@MISSION_NAME@" 6 | #define EDS_INDEX(x) @EDS_SYMBOL_PREFIX@_INDEX_ ## x 7 | #define EDS_MAX_DATASHEETS @EDS_SYMBOL_PREFIX@_MAX_INDEX 8 | #define EDS_DATABASE @EDS_SYMBOL_PREFIX@_DATABASE 9 | -------------------------------------------------------------------------------- /cfecfs/missionlib/cmake/edstool-buildenv.d.in: -------------------------------------------------------------------------------- 1 | # Template for build environment variables 2 | # See also: https://cmake.org/cmake/help/latest/manual/cmake-variables.7.html 3 | 4 | # Capture critical build flags and compiler command (CC) 5 | CMAKE := ${CMAKE_COMMAND} 6 | CC := ${CMAKE_C_COMPILER} 7 | CFLAGS := ${CMAKE_C_FLAGS} 8 | AR := ${CMAKE_AR} 9 | LD := ${CMAKE_LINKER} 10 | 11 | # The link flags may be different (or empty) depending on 12 | # what type of target is being linked. 13 | EXE_LDFLAGS := ${CMAKE_EXE_LINKER_FLAGS} 14 | EXE_SUFFIX := ${CMAKE_EXECUTABLE_SUFFIX} 15 | SHARED_LDFLAGS := ${CMAKE_SHARED_LINKER_FLAGS} 16 | SHARED_SUFFIX := ${CMAKE_SHARED_LIBRARY_SUFFIX} 17 | STATIC_LDFLAGS := ${CMAKE_STATIC_LINKER_FLAGS} 18 | STATIC_SUFFIX := ${CMAKE_STATIC_LIBRARY_SUFFIX} 19 | 20 | # Capture other variables/locations 21 | MISSION_NAME := ${MISSION_NAME} 22 | MISSION_BINARY_DIR := ${MISSION_BINARY_DIR} 23 | EDS_FILE_PREFIX := ${EDS_FILE_PREFIX} 24 | EDS_SYMBOL_PREFIX := ${EDS_SYMBOL_PREFIX} 25 | OBJDIR ?= ${ARCH_BINARY_SUBDIR}/obj 26 | BUILD_TYPE ?= ${CMAKE_BUILD_TYPE} 27 | EDSLIB_SOURCE_DIR := ${EDSLIB_SOURCE_DIR} 28 | EDS_CFECFS_MISSIONLIB_SOURCE_DIR := ${EDS_CFECFS_MISSIONLIB_SOURCE_DIR} 29 | BUILD_CONFIG := ${BUILD_CONFIG_${TARGETSYSTEM}} 30 | 31 | # In general most source files compiled via this method 32 | # will require access to the EdsLib API headers. This assumes 33 | # a gnu-style compiler option (-I), but should with clang too. 34 | CFLAGS ?= -Wall -Werror -std=c99 -pedantic 35 | CFLAGS += -I$(EDSLIB_SOURCE_DIR)/fsw/inc 36 | 37 | # Export all defined variables 38 | export CMAKE 39 | export CC 40 | export CFLAGS 41 | export AR 42 | export LD 43 | export EXE_LDFLAGS 44 | export EXE_SUFFIX 45 | export SHARED_LDFLAGS 46 | export SHARED_SUFFIX 47 | export STATIC_LDFLAGS 48 | export STATIC_SUFFIX 49 | export MISSION_NAME 50 | export MISSION_BINARY_DIR 51 | export OBJDIR 52 | export BUILD_TYPE 53 | export BUILD_CONFIG 54 | export EDSLIB_SOURCE_DIR 55 | export EDS_CFECFS_MISSIONLIB_SOURCE_DIR 56 | export EDS_FILE_PREFIX 57 | export EDS_SYMBOL_PREFIX 58 | -------------------------------------------------------------------------------- /cfecfs/missionlib/cmake/edstool-execute-arch.mk: -------------------------------------------------------------------------------- 1 | # NOTE: This relies on ARCH_BINARY_DIR being passed in via command line 2 | # Specifically the edstool-buildenv.d file must be present in this dir, and 3 | # this specifies values for OBJDIR, BUILD_CONFIG, CC/AR/LD, and others. 4 | include $(wildcard $(ARCH_BINARY_DIR)/obj/*.d) 5 | 6 | ifeq ($(OBJDIR),) 7 | $(error OBJDIR is not set, confirm that edstool-buildenv.d exists under $(ARCH_BINARY_DIR)/obj) 8 | endif 9 | 10 | # The O variable in this context is localized; should not use O from the parent here. 11 | O := $(OBJDIR) 12 | EDSTOOL_ARCH := $(firstword $(subst ;, ,$(BUILD_CONFIG))) 13 | 14 | LOCAL_STAMPFILE := $(MISSION_BINARY_DIR)/edstool-complete.stamp 15 | DBOBJ_MAKEFILE := $(MISSION_BINARY_DIR)/$(EDS_FILE_PREFIX)_db_objects.mk 16 | INTFOBJ_MAKEFILE := $(MISSION_BINARY_DIR)/$(EDS_FILE_PREFIX)_interfacedb_objects.mk 17 | 18 | .PHONY: all db_objects interfacedb_objects 19 | all: db_objects interfacedb_objects 20 | @echo All target-specific EDS objects built 21 | 22 | # The stampfile dependency here should have been generated by the top-level (mission scope) 23 | # build procedures before this build was invoked. It is listed here mainly as a sanity check. 24 | db_objects interfacedb_objects: $(LOCAL_STAMPFILE) 25 | 26 | db_objects: $(addprefix $(OBJDIR)/$(EDS_FILE_PREFIX)_db,$(SHARED_SUFFIX) $(STATIC_SUFFIX)) 27 | interfacedb_objects: $(addprefix $(OBJDIR)/$(EDS_FILE_PREFIX)_interfacedb,$(SHARED_SUFFIX) $(STATIC_SUFFIX)) 28 | 29 | # These makefiles should have been generated by the top-level build 30 | include $(DBOBJ_MAKEFILE) $(INTFOBJ_MAKEFILE) 31 | -------------------------------------------------------------------------------- /cfecfs/missionlib/cmake/edstool-execute-mission.mk: -------------------------------------------------------------------------------- 1 | include edstool-buildenv.d 2 | include edstool-sources.d 3 | 4 | LOCAL_STAMPFILE := edstool-complete.stamp 5 | MISSION_PARAM_HEADER := inc/cfe_mission_eds_parameters.h 6 | INTFDB_PARAM_HEADER := inc/cfe_mission_eds_interface_parameters.h 7 | O := $(OBJDIR) 8 | 9 | 10 | # NOTE: At the mission scope, this runs the full EDS tool to generate all artifacts 11 | # As part of this, it invokes the db_objects make scripts as well, so there is noting 12 | # extra that needs to be invoked from here. 13 | 14 | .PHONY: all 15 | all: $(LOCAL_STAMPFILE) 16 | @echo All host side global EDS objects built 17 | 18 | # The file lists here came from CMake, and so they have the semicolon separator, 19 | # which needs to be changed to a space separator for interpretation here. 20 | ALL_EDS_FILES += $(subst ;, ,$(MISSION_EDS_FILELIST)) 21 | ALL_EDS_FILES += $(subst ;, ,$(MISSION_EDS_SCRIPTLIST)) 22 | 23 | $(LOCAL_STAMPFILE): $(EDSTOOL) $(MISSION_PARAM_HEADER) $(INTFDB_PARAM_HEADER) $(ALL_EDS_FILES) 24 | +$(EDSTOOL) -DMAKE_PROGRAM="$(MAKE)" -DOBJDIR=$(OBJDIR) $(ALL_EDS_FILES) 25 | $(CMAKE) -E touch "$(@)" 26 | 27 | $(MISSION_PARAM_HEADER): $(EDS_CFECFS_MISSIONLIB_SOURCE_DIR)/cmake/cfe_mission_eds_parameters.h.in obj/edstool-buildenv.d 28 | @echo "configure_file($(<) $(@))" > src/generate_eds_parameters_h.cmake 29 | $(CMAKE) -D MISSION_NAME=$(MISSION_NAME) -D EDS_FILE_PREFIX=$(EDS_FILE_PREFIX) -D EDS_SYMBOL_PREFIX=$(EDS_SYMBOL_PREFIX) -P src/generate_eds_parameters_h.cmake 30 | 31 | $(INTFDB_PARAM_HEADER): $(EDS_CFECFS_MISSIONLIB_SOURCE_DIR)/cmake/cfe_mission_eds_interface_parameters.h.in obj/edstool-buildenv.d 32 | @echo "configure_file($(<) $(@))" > src/cfe_mission_eds_interface_parameters.cmake 33 | $(CMAKE) -D MISSION_NAME=$(MISSION_NAME) -D EDS_FILE_PREFIX=$(EDS_FILE_PREFIX) -D EDS_SYMBOL_PREFIX=$(EDS_SYMBOL_PREFIX) -P src/cfe_mission_eds_interface_parameters.cmake 34 | -------------------------------------------------------------------------------- /cfecfs/missionlib/cmake/edstool-sources.d.in: -------------------------------------------------------------------------------- 1 | 2 | # Capture the complete list of EDS files and scripts in use 3 | # Note that these will be cmake style semicolon-separated, not space-separated. 4 | MISSION_EDS_FILELIST := ${MISSION_EDS_FILELIST} 5 | MISSION_EDS_SCRIPTLIST := ${MISSION_EDS_SCRIPTLIST} 6 | -------------------------------------------------------------------------------- /cfecfs/missionlib/eds/74-cfe_sb_msg_topic_ids.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- LEW-19710-1, CCSDS SOIS Electronic Data Sheet Implementation 3 | -- 4 | -- Copyright (c) 2020 United States Government as represented by 5 | -- the Administrator of the National Aeronautics and Space Administration. 6 | -- All Rights Reserved. 7 | -- 8 | -- Licensed under the Apache License, Version 2.0 (the "License"); 9 | -- you may not use this file except in compliance with the License. 10 | -- You may obtain a copy of the License at 11 | -- 12 | -- http://www.apache.org/licenses/LICENSE-2.0 13 | -- 14 | -- Unless required by applicable law or agreed to in writing, software 15 | -- distributed under the License is distributed on an "AS IS" BASIS, 16 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | -- See the License for the specific language governing permissions and 18 | -- limitations under the License. 19 | -- 20 | 21 | 22 | -- ------------------------------------------------------------------------- 23 | -- Lua implementation of the "dispatch tables" as part of the CFS/MissionLib 24 | -- 25 | -- In this area the EDS processing becomes very specific to CFE/CFS 26 | -- and how this application will actually use it. The objective is 27 | -- to generate the appropriate data structures for "dispatching" 28 | -- messages from the software bus to the local application. 29 | -- ------------------------------------------------------------------------- 30 | 31 | local mts_comp = SEDS.root:find_reference("CFE_SB/MTS", "COMPONENT") 32 | 33 | if (type(mts_comp) ~= "userdata") then 34 | SEDS.error("CFE_SB/MTS component is not defined") 35 | return 36 | end 37 | 38 | local components = {} 39 | 40 | -- ----------------------------------------------------- 41 | -- helper function to determine a complete "interface chain" 42 | -- ----------------------------------------------------- 43 | --[[ 44 | Each Software Bus routing path should involve a chain of interfaces: 45 | MTS -> PubSub -> (Telecommand|Telemetry) -> Application 46 | --]] 47 | 48 | local function get_chain(inst) 49 | 50 | local chain = { } 51 | local found_chain = false 52 | local do_get_chain 53 | 54 | do_get_chain = function(inst) 55 | if (inst) then 56 | found_chain = (inst.component == mts_comp) 57 | if (not found_chain) then 58 | for i,binding in ipairs(inst.required_links) do 59 | chain[1 + #chain] = binding 60 | do_get_chain(binding.provinst) 61 | if (found_chain) then 62 | break 63 | end 64 | chain[#chain] = nil 65 | end 66 | end 67 | end 68 | end 69 | 70 | do_get_chain(inst) 71 | return chain[1], chain[2], chain[3] 72 | end 73 | 74 | -- ----------------------------------------------------- 75 | -- Main routine starts here 76 | -- ----------------------------------------------------- 77 | --[[ 78 | First, find the chain for each entry in the SEDS.highlevel_interfaces list 79 | If it is a CFE_SB interface (pubsub) then identify the MsgId and TopicId 80 | Build a reverse-map table for MsgId and TopicId and ensure there are no duplicates 81 | 82 | Also note - this puts the topicid table at the MTS level, ensuring uniqueness of topic IDs 83 | across the entire MTS. Technically only MsgIds need to be unique at the MTS (subnetwork) level, 84 | as TopicIDs could be qualified at the access level (CMD or TLM). However it is just simpler to 85 | manage if all the topic IDs are unique too. This way, all that is needed to pass around is just 86 | strictly a topic ID alone, it does not need to be a combination of (topic ID + access intf). 87 | --]] 88 | 89 | mts_comp.msgid_table = {} 90 | mts_comp.topicid_table = {} 91 | 92 | for _,instance in ipairs(SEDS.highlevel_interfaces) do 93 | for _,binding in ipairs(instance.required_links) do 94 | local tctm, pubsub = get_chain(binding.provinst) 95 | if (pubsub) then 96 | components[instance.component] = true 97 | local chain = { 98 | binding = binding, 99 | tctm = tctm.reqinst.params[binding.provintf.name](), 100 | pubsub = pubsub.reqinst.params[tctm.provintf.name]() 101 | } 102 | local MsgId = chain.pubsub.MsgId.Value 103 | local TopicId = chain.tctm.TopicId 104 | -- Build the reverse lookup tables for Message Id and Topic Id 105 | -- Ensure that there are no conflicts between these indices 106 | if (mts_comp.msgid_table[MsgId]) then 107 | local exist_comp = mts_comp.msgid_table[MsgId].binding 108 | exist_comp.reqintf:error(string.format("MsgId Conflict on MsgId=%04x/TopicId=%d with %s",MsgId,TopicId,binding.reqintf:get_qualified_name())) 109 | else 110 | mts_comp.msgid_table[MsgId] = chain 111 | end 112 | if (mts_comp.topicid_table[TopicId]) then 113 | local exist_comp = mts_comp.topicid_table[TopicId].binding 114 | exist_comp.reqintf:error(string.format("TopicId Conflict on MsgId=%04x/TopicId=%d with %s",MsgId,TopicId,binding.reqintf:get_qualified_name())) 115 | else 116 | mts_comp.topicid_table[TopicId] = chain 117 | end 118 | end 119 | end 120 | end 121 | 122 | -- Export the findings via the SEDS global 123 | SEDS.mts_info = { 124 | mts_component = mts_comp, -- The base (low level) MTS subnetwork component 125 | component_set = components -- The keys of this table are the components that use this MTS 126 | } 127 | 128 | --SEDS.error("Stop") -------------------------------------------------------------------------------- /cfecfs/missionlib/eds/80-build_cfe_sb_interfacedb.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- LEW-19710-1, CCSDS SOIS Electronic Data Sheet Implementation 3 | -- 4 | -- Copyright (c) 2020 United States Government as represented by 5 | -- the Administrator of the National Aeronautics and Space Administration. 6 | -- All Rights Reserved. 7 | -- 8 | -- Licensed under the Apache License, Version 2.0 (the "License"); 9 | -- you may not use this file except in compliance with the License. 10 | -- You may obtain a copy of the License at 11 | -- 12 | -- http://www.apache.org/licenses/LICENSE-2.0 13 | -- 14 | -- Unless required by applicable law or agreed to in writing, software 15 | -- distributed under the License is distributed on an "AS IS" BASIS, 16 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | -- See the License for the specific language governing permissions and 18 | -- limitations under the License. 19 | -- 20 | 21 | -- ------------------------------------------------------------------------- 22 | -- Lua script to build the generated interfacedb C objects 23 | -- ------------------------------------------------------------------------- 24 | 25 | local objdir = SEDS.get_define("OBJDIR") or "obj" 26 | local libname = SEDS.to_filename("interfacedb") 27 | local makefilename = SEDS.to_filename("interfacedb_objects.mk") 28 | local libtypes = { ".a", ".so", ".obj" } 29 | 30 | local function get_objnames(n,prefix,suffix) 31 | local result = "" 32 | for _,t in ipairs(suffix) do 33 | result = result .. string.format("%s/%s%s ",prefix,n,t) 34 | end 35 | return result 36 | end 37 | 38 | -- ------------------------------------------------ 39 | -- Generate a makefile for the interfacedb library 40 | -- This is currently only one file, the "interfacedb_impl" 41 | -- ------------------------------------------------ 42 | local output = SEDS.output_open(makefilename) 43 | output:write("include $(O)/edstool-buildenv.d $(wildcard $(O)/*.d)") 44 | output:write("include $(EDSLIB_SOURCE_DIR)/cmake/dbobj_patternrules.mk") 45 | output:add_whitespace(1) 46 | output:write("# Interface DB Object") 47 | output:write(string.format("%s: $(O)/%s", 48 | get_objnames(libname,"$(O)",libtypes), 49 | SEDS.to_filename("interfacedb_impl.o"))) 50 | output:add_whitespace(1) 51 | SEDS.output_close(output) 52 | 53 | -- ------------------------------------------------ 54 | -- Execute the build tool (make) to actually build the 55 | -- interfacdb using the makefile generated above. 56 | -- ------------------------------------------------ 57 | SEDS.execute_tool("MAKE_PROGRAM", 58 | string.format("-C \"%s\" -f \"%s\" O=\"%s\" %s", 59 | SEDS.get_define("MISSION_BINARY_DIR") or ".", 60 | makefilename, 61 | objdir, 62 | get_objnames(libname,objdir,libtypes) 63 | ) 64 | ) 65 | -------------------------------------------------------------------------------- /cfecfs/missionlib/eds/85-write_commandcode_headers.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- LEW-19710-1, CCSDS SOIS Electronic Data Sheet Implementation 3 | -- 4 | -- Copyright (c) 2020 United States Government as represented by 5 | -- the Administrator of the National Aeronautics and Space Administration. 6 | -- All Rights Reserved. 7 | -- 8 | -- Licensed under the Apache License, Version 2.0 (the "License"); 9 | -- you may not use this file except in compliance with the License. 10 | -- You may obtain a copy of the License at 11 | -- 12 | -- http://www.apache.org/licenses/LICENSE-2.0 13 | -- 14 | -- Unless required by applicable law or agreed to in writing, software 15 | -- distributed under the License is distributed on an "AS IS" BASIS, 16 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | -- See the License for the specific language governing permissions and 18 | -- limitations under the License. 19 | -- 20 | 21 | 22 | -- ------------------------- 23 | -- MAIN ROUTINE 24 | -- ------------------------- 25 | 26 | for ds in SEDS.root:iterate_children(SEDS.basenode_filter) do 27 | 28 | -- Note that each interface under the component could have its own separate set of command codes, 29 | -- but most have just one. The goal is to combine all the cc's into a single header file. 30 | 31 | local ds_all_subcmds = {} 32 | local ds_cmdcode_lookup = {} 33 | 34 | for comp in ds:iterate_subtree("COMPONENT") do 35 | -- Locate all required intfs under this component that utilize subcommand/function codes 36 | for reqintf in comp:iterate_subtree("REQUIRED_INTERFACE") do 37 | for _,cmd in ipairs(reqintf.intf_commands or {}) do 38 | 39 | if (cmd.subcommand_arg) then 40 | local argtype = cmd.args[cmd.subcommand_arg].type 41 | local constraint_values = {} 42 | local constraint_argtype = {} 43 | 44 | for _,subcommand in ipairs(argtype.edslib_derivtable_list) do 45 | -- Note that this list is not in value-order, the index relates to the lookup table, not the actual cmdcode value 46 | -- To get the command code value, need to drill down into the constraint set. This assumes a single value constraint. 47 | local cmdname = subcommand:get_flattened_name() 48 | local constraint = subcommand:find_first("CONSTRAINT_SET") 49 | if (constraint) then 50 | constraint = constraint:find_first("VALUE_CONSTRAINT") 51 | end 52 | if (constraint) then 53 | constraint = constraint.attributes["value"] 54 | end 55 | if (constraint) then 56 | constraint_values[1 + #constraint_values] = constraint 57 | constraint_argtype[constraint] = subcommand 58 | end 59 | end 60 | 61 | table.sort(constraint_values) 62 | cmd.cc_list = {} 63 | for i,constraint in ipairs(constraint_values) do 64 | local subcommand = constraint_argtype[constraint] 65 | local macroname = SEDS.to_macro_name(subcommand:get_flattened_name()) 66 | -- If the command name ends in "_CMD" then lop it off 67 | if (string.sub(macroname, -4, -1) == "_CMD") then 68 | macroname = string.sub(macroname, 1, -5) 69 | end 70 | macroname = macroname .. "_CC" 71 | cmd.cc_list[i] = { value = constraint, argtype = subcommand, macroname = macroname } 72 | end 73 | 74 | ds_all_subcmds[1 + #ds_all_subcmds] = { intf=reqintf, cmd=cmd } 75 | end 76 | end 77 | end 78 | end 79 | 80 | -- Create a "cc.h" header file containing the command/function codes specificed as EDS value constraints 81 | -- This info was collected earlier, but is easier to use in C files if not mixed with the interface declarations 82 | -- It also needs to be put in a reasonable order and the macro names need to be scrubbed/fixed to match 83 | if (#ds_all_subcmds > 0) then 84 | hdrout = SEDS.output_open(SEDS.to_filename("cc.h", ds.name),ds.xml_filename) 85 | for _,sc in ipairs(ds_all_subcmds) do 86 | hdrout:section_marker(string.format("Command Codes for \'%s\' Interface",sc.intf.name)) 87 | for _,cc in ipairs(sc.cmd.cc_list) do 88 | hdrout:add_documentation(string.format("Command code associated with %s", SEDS.to_ctype_typedef(cc.argtype))) 89 | hdrout:write(string.format("#define %-60s %s", cc.macroname, cc.value)) 90 | end 91 | hdrout:add_whitespace(1) 92 | end 93 | SEDS.output_close(hdrout) 94 | end 95 | 96 | end 97 | -------------------------------------------------------------------------------- /cfecfs/missionlib/eds/90-write_intf_hierarchy.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- LEW-19710-1, CCSDS SOIS Electronic Data Sheet Implementation 3 | -- 4 | -- Copyright (c) 2020 United States Government as represented by 5 | -- the Administrator of the National Aeronautics and Space Administration. 6 | -- All Rights Reserved. 7 | -- 8 | -- Licensed under the Apache License, Version 2.0 (the "License"); 9 | -- you may not use this file except in compliance with the License. 10 | -- You may obtain a copy of the License at 11 | -- 12 | -- http://www.apache.org/licenses/LICENSE-2.0 13 | -- 14 | -- Unless required by applicable law or agreed to in writing, software 15 | -- distributed under the License is distributed on an "AS IS" BASIS, 16 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | -- See the License for the specific language governing permissions and 18 | -- limitations under the License. 19 | -- 20 | 21 | -- --------------------------------------------- 22 | -- generate interface hierarchy graphic 23 | -- This generates dot files based on the interface hierarchy which can be 24 | -- easily turned into graphics using the "dot" tool. 25 | -- This script should run late in the processing stages 26 | -- --------------------------------------------- 27 | 28 | local function add_edges(output,inst) 29 | local desc = inst.component:get_qualified_name() 30 | for _,binding in ipairs(inst.required_links) do 31 | local params = inst.params 32 | if (params) then 33 | for iname,iinf in SEDS.edslib.IterateFields(params) do 34 | for vname,vinf in SEDS.edslib.IterateFields(iinf) do 35 | desc = desc .. string.format("\\n%s.%s=%s", iname, tostring(vname), tostring(vinf)) 36 | end 37 | end 38 | end 39 | output:write(string.format("id%03d -> id%03d [label=\"%s\"]", inst.id, binding.provinst.id, binding.reqintf.name)) 40 | add_edges(output,binding.provinst) 41 | end 42 | output:write(string.format("id%03d [label=\"%s\"]", inst.id, desc)) 43 | end 44 | 45 | SEDS.output_mkdir("intf_dot"); 46 | 47 | for ds in SEDS.root:iterate_children(SEDS.basenode_filter) do 48 | local comps = {} 49 | for _,instance in ipairs(SEDS.highlevel_interfaces) do 50 | local app_ds = instance.component:find_parent(SEDS.basenode_filter) 51 | if (app_ds == ds) then 52 | comps[1 + #comps] = instance 53 | end 54 | end 55 | 56 | if (#comps > 0) then 57 | local output = SEDS.output_open("intf_dot/" .. SEDS.to_filename("interfaces.dot", ds.name)); 58 | output:start_group("digraph mission {") 59 | output:write("rankdir=\"LR\"") 60 | for _,instance in ipairs(comps) do 61 | add_edges(output,instance) 62 | end 63 | output:end_group("}") 64 | SEDS.output_close(output) 65 | end 66 | end 67 | -------------------------------------------------------------------------------- /cfecfs/missionlib/eds/instance-rules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /cfecfs/missionlib/fsw/inc/cfe_missionlib_runtime.h: -------------------------------------------------------------------------------- 1 | /* 2 | * LEW-19710-1, CCSDS SOIS Electronic Data Sheet Implementation 3 | * 4 | * Copyright (c) 2020 United States Government as represented by 5 | * the Administrator of the National Aeronautics and Space Administration. 6 | * All Rights Reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | 21 | /** 22 | * \file cfe_missionlib_runtime.h 23 | * \ingroup fsw 24 | * \author joseph.p.hickey@nasa.gov 25 | * 26 | * In typical ground/debug applications the entire EDS of the mission may be 27 | * statically linked into the executable using a special object named "MISSION_EDS" 28 | * 29 | * This header only provides an "extern" declaration for such an object. It does not 30 | * define the object; that is up to the user application to do. 31 | */ 32 | 33 | #ifndef _CFE_MISSIONLIB_RUNTIME_H_ 34 | #define _CFE_MISSIONLIB_RUNTIME_H_ 35 | 36 | #include "cfe_mission_eds_parameters.h" 37 | #include "cfe_sb_eds_datatypes.h" 38 | #include "cfe_hdr_eds_datatypes.h" 39 | 40 | /* 41 | * This code is intended to support both versions of the header, but 42 | * tuned at compile time via some ifdef macros to account for the difference. 43 | * 44 | * NOTE: It is sometimes required to do source selection at compile-time due 45 | * to differences in how the structures are defined (i.e. to avoid code that 46 | * references a field that does not exist in this config). 47 | * 48 | * These numeric values correlate with the CCSDS primary header version 49 | * field +1 (this avoids zero, since undefined macros may evaluate as 0). 50 | */ 51 | #define CFE_MISSIONLIB_SpacePacketBasic_HEADERS 1 52 | #define CFE_MISSIONLIB_SpacePacketApidQ_HEADERS 2 53 | 54 | #define CFE_MISSIONLIB_CFGSYM_TO_HDRTYPE(hdr) CFE_MISSIONLIB_##hdr##_HEADERS 55 | #define CFE_MISSIONLIB_HDRTYPE(sym) CFE_MISSIONLIB_CFGSYM_TO_HDRTYPE(sym) 56 | 57 | /* 58 | * This definition of CFE_MISSIONLIB_SELECTED_HDRTYPE preprocessor macro yields a single 59 | * string that should resolve to either "CCSDS_SpacePacketBasic_VERSION" or 60 | * "CCSDS_SpacePacketApidQ_VERSION" depending on which is selected in 61 | * the mission configuration EDS file. 62 | * 63 | * When used in a numeric context, it resolves to the CCSDS version field +1. 64 | */ 65 | #define CFE_MISSIONLIB_SELECTED_HDRTYPE CFE_MISSIONLIB_HDRTYPE(CFE_MISSION_MSG_HEADER_TYPE) 66 | 67 | #ifdef __cplusplus 68 | extern "C" 69 | { 70 | #endif 71 | 72 | void CFE_MissionLib_MapListenerComponent(EdsInterface_CFE_SB_SoftwareBus_PubSub_t *Output, 73 | const EdsComponent_CFE_SB_Listener_t * Input); 74 | void CFE_MissionLib_UnmapListenerComponent(EdsComponent_CFE_SB_Listener_t * Output, 75 | const EdsInterface_CFE_SB_SoftwareBus_PubSub_t *Input); 76 | void CFE_MissionLib_MapPublisherComponent(EdsInterface_CFE_SB_SoftwareBus_PubSub_t *Output, 77 | const EdsComponent_CFE_SB_Publisher_t * Input); 78 | void CFE_MissionLib_UnmapPublisherComponent(EdsComponent_CFE_SB_Publisher_t * Output, 79 | const EdsInterface_CFE_SB_SoftwareBus_PubSub_t *Input); 80 | 81 | bool CFE_MissionLib_PubSub_IsListenerComponent(const EdsInterface_CFE_SB_SoftwareBus_PubSub_t *Params); 82 | bool CFE_MissionLib_PubSub_IsPublisherComponent(const EdsInterface_CFE_SB_SoftwareBus_PubSub_t *Params); 83 | 84 | void CFE_MissionLib_Get_PubSub_Parameters(EdsInterface_CFE_SB_SoftwareBus_PubSub_t *Params, 85 | const EdsDataType_CFE_HDR_Message_t * Packet); 86 | void CFE_MissionLib_Set_PubSub_Parameters(EdsDataType_CFE_HDR_Message_t * Packet, 87 | const EdsInterface_CFE_SB_SoftwareBus_PubSub_t *Params); 88 | 89 | #ifdef __cplusplus 90 | } /* extern "C" */ 91 | #endif 92 | 93 | #endif /* _CFE_MISSIONLIB_RUNTIME_H_ */ 94 | -------------------------------------------------------------------------------- /cfecfs/missionlib/fsw/src/cfe_missionlib_database_types.h: -------------------------------------------------------------------------------- 1 | /* 2 | * LEW-19710-1, CCSDS SOIS Electronic Data Sheet Implementation 3 | * 4 | * Copyright (c) 2020 United States Government as represented by 5 | * the Administrator of the National Aeronautics and Space Administration. 6 | * All Rights Reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | 21 | /** 22 | * \file cfe_missionlib_database_types.h 23 | * \ingroup fsw 24 | * \author joseph.p.hickey@nasa.gov 25 | * 26 | */ 27 | 28 | #ifndef _CFE_MISSIONLIB_DATABASE_TYPES_H_ 29 | #define _CFE_MISSIONLIB_DATABASE_TYPES_H_ 30 | 31 | #include 32 | #include 33 | 34 | /* 35 | * Caution about #include'ing additional files here --- 36 | * This is compiled _without_ the full include path from the rest of the CFE build 37 | * System headers are OK (as above) but locally-defined files should be avoided. 38 | */ 39 | 40 | struct CFE_MissionLib_Argument_Entry 41 | { 42 | uint16_t AppIndex; 43 | uint16_t TypeIndex; 44 | }; 45 | 46 | typedef struct CFE_MissionLib_Argument_Entry CFE_MissionLib_Argument_Entry_t; 47 | 48 | struct CFE_MissionLib_Subcommand_Entry 49 | { 50 | uint16_t DispatchOffset; 51 | }; 52 | 53 | typedef struct CFE_MissionLib_Subcommand_Entry CFE_MissionLib_Subcommand_Entry_t; 54 | 55 | struct CFE_MissionLib_Command_Definition_Entry 56 | { 57 | uint16_t SubcommandArg; 58 | uint16_t SubcommandCount; 59 | const struct CFE_MissionLib_Argument_Entry * ArgumentList; 60 | const struct CFE_MissionLib_Subcommand_Entry *SubcommandList; 61 | }; 62 | 63 | typedef struct CFE_MissionLib_Command_Definition_Entry CFE_MissionLib_Command_Definition_Entry_t; 64 | 65 | struct CFE_MissionLib_TopicId_Entry 66 | { 67 | uint16_t DispatchTableId; 68 | uint16_t DispatchStartOffset; 69 | uint16_t InterfaceId; 70 | const char * TopicName; 71 | const CFE_MissionLib_Command_Definition_Entry_t *CommandList; 72 | }; 73 | 74 | typedef struct CFE_MissionLib_TopicId_Entry CFE_MissionLib_TopicId_Entry_t; 75 | 76 | struct CFE_MissionLib_Command_Prototype_Entry 77 | { 78 | uint16_t NumArguments; 79 | const char *CommandName; 80 | }; 81 | 82 | typedef struct CFE_MissionLib_Command_Prototype_Entry CFE_MissionLib_Command_Prototype_Entry_t; 83 | 84 | struct CFE_MissionLib_InterfaceId_Entry 85 | { 86 | uint16_t NumCommands; 87 | uint16_t NumTopics; 88 | const char * InterfaceName; 89 | const CFE_MissionLib_Command_Prototype_Entry_t *CommandList; 90 | const CFE_MissionLib_TopicId_Entry_t * TopicList; 91 | }; 92 | 93 | typedef struct CFE_MissionLib_InterfaceId_Entry CFE_MissionLib_InterfaceId_Entry_t; 94 | 95 | struct CFE_MissionLib_SoftwareBus_Interface 96 | { 97 | uint16_t NumInterfaces; 98 | const CFE_MissionLib_InterfaceId_Entry_t *InterfaceList; 99 | const char *const * InstanceList; 100 | }; 101 | 102 | #endif /* _CFE_MISSIONLIB_DATABASE_TYPES_H_ */ 103 | -------------------------------------------------------------------------------- /cfecfs/missionlib/fsw/ut-stubs/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # LEW-19710-1, CCSDS SOIS Electronic Data Sheet Implementation 3 | # 4 | # Copyright (c) 2020 United States Government as represented by 5 | # the Administrator of the National Aeronautics and Space Administration. 6 | # All Rights Reserved. 7 | # 8 | # Licensed under the Apache License, Version 2.0 (the "License"); 9 | # you may not use this file except in compliance with the License. 10 | # You may obtain a copy of the License at 11 | # 12 | # http://www.apache.org/licenses/LICENSE-2.0 13 | # 14 | # Unless required by applicable law or agreed to in writing, software 15 | # distributed under the License is distributed on an "AS IS" BASIS, 16 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | # See the License for the specific language governing permissions and 18 | # limitations under the License. 19 | # 20 | 21 | # Build script for CFS-EDS mission integration library unit test stubs 22 | add_library(ut_missionlib_stubs 23 | cfe_missionlib_api_handlers.c 24 | cfe_missionlib_api_stubs.c 25 | cfe_missionlib_runtime_handlers.c 26 | cfe_missionlib_runtime_stubs.c 27 | cfe_missionlib_stub_helpers.c 28 | ) 29 | 30 | target_link_libraries(ut_missionlib_stubs 31 | ut_assert 32 | ) -------------------------------------------------------------------------------- /cfecfs/missionlib/fsw/ut-stubs/cfe_missionlib_stub_helpers.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** GSC-18128-1, "Core Flight Executive Version 6.7" 3 | ** 4 | ** Copyright (c) 2006-2019 United States Government as represented by 5 | ** the Administrator of the National Aeronautics and Space Administration. 6 | ** All Rights Reserved. 7 | ** 8 | ** Licensed under the Apache License, Version 2.0 (the "License"); 9 | ** you may not use this file except in compliance with the License. 10 | ** You may obtain a copy of the License at 11 | ** 12 | ** http://www.apache.org/licenses/LICENSE-2.0 13 | ** 14 | ** Unless required by applicable law or agreed to in writing, software 15 | ** distributed under the License is distributed on an "AS IS" BASIS, 16 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | ** See the License for the specific language governing permissions and 18 | ** limitations under the License. 19 | */ 20 | 21 | /* 22 | ** Includes 23 | */ 24 | #include 25 | #include "cfe_missionlib_stub_helpers.h" 26 | 27 | #include "utstubs.h" 28 | #include "utassert.h" 29 | 30 | void CFE_MissionLib_Stub_DefaultZeroOutput(UT_EntryKey_t FuncKey, const UT_StubContext_t *Context, void *OutputBuffer, 31 | size_t OutputSize) 32 | { 33 | int32_t Status; 34 | 35 | UT_Stub_GetInt32StatusCode(Context, &Status); 36 | 37 | if (Status >= 0) 38 | { 39 | if (UT_Stub_CopyToLocal(FuncKey, OutputBuffer, OutputSize) < OutputSize) 40 | { 41 | memset(OutputBuffer, 0, OutputSize); 42 | } 43 | } 44 | } 45 | 46 | void CFE_MissionLib_Stub_DefaultStringOutput(UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) 47 | { 48 | int32_t Status; 49 | void * DataBuffer; 50 | const char * Result; 51 | static const char DEFAULT_OUTPUT[] = "UT"; 52 | 53 | UT_Stub_GetInt32StatusCode(Context, &Status); 54 | 55 | if (Status >= 0) 56 | { 57 | UT_GetDataBuffer(FuncKey, &DataBuffer, NULL, NULL); 58 | if (DataBuffer == NULL) 59 | { 60 | Result = DEFAULT_OUTPUT; 61 | } 62 | else 63 | { 64 | Result = DataBuffer; 65 | } 66 | } 67 | else 68 | { 69 | Result = NULL; 70 | } 71 | 72 | UT_Stub_SetReturnValue(FuncKey, Result); 73 | } 74 | -------------------------------------------------------------------------------- /cfecfs/missionlib/fsw/ut-stubs/cfe_missionlib_stub_helpers.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** GSC-18128-1, "Core Flight Executive Version 6.7" 3 | ** 4 | ** Copyright (c) 2006-2019 United States Government as represented by 5 | ** the Administrator of the National Aeronautics and Space Administration. 6 | ** All Rights Reserved. 7 | ** 8 | ** Licensed under the Apache License, Version 2.0 (the "License"); 9 | ** you may not use this file except in compliance with the License. 10 | ** You may obtain a copy of the License at 11 | ** 12 | ** http://www.apache.org/licenses/LICENSE-2.0 13 | ** 14 | ** Unless required by applicable law or agreed to in writing, software 15 | ** distributed under the License is distributed on an "AS IS" BASIS, 16 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | ** See the License for the specific language governing permissions and 18 | ** limitations under the License. 19 | */ 20 | 21 | #ifndef CFE_MISSIONLIB_STUB_HELPERS_H 22 | #define CFE_MISSIONLIB_STUB_HELPERS_H 23 | 24 | /* 25 | ** Includes 26 | */ 27 | #include 28 | 29 | #include "utstubs.h" 30 | #include "utassert.h" 31 | 32 | void CFE_MissionLib_Stub_DefaultZeroOutput(UT_EntryKey_t FuncKey, const UT_StubContext_t *Context, void *OutputBuffer, 33 | size_t OutputSize); 34 | void CFE_MissionLib_Stub_DefaultStringOutput(UT_EntryKey_t FuncKey, const UT_StubContext_t *Context); 35 | 36 | #endif /* CFE_MISSIONLIB_STUB_HELPERS_H */ 37 | -------------------------------------------------------------------------------- /cfecfs/missionlib/lua/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # LEW-19710-1, CCSDS SOIS Electronic Data Sheet Implementation 3 | # 4 | # Copyright (c) 2020 United States Government as represented by 5 | # the Administrator of the National Aeronautics and Space Administration. 6 | # All Rights Reserved. 7 | # 8 | # Licensed under the Apache License, Version 2.0 (the "License"); 9 | # you may not use this file except in compliance with the License. 10 | # You may obtain a copy of the License at 11 | # 12 | # http://www.apache.org/licenses/LICENSE-2.0 13 | # 14 | # Unless required by applicable law or agreed to in writing, software 15 | # distributed under the License is distributed on an "AS IS" BASIS, 16 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | # See the License for the specific language governing permissions and 18 | # limitations under the License. 19 | # 20 | 21 | # Lua bindings for the CFE-EDS mission integration library 22 | project(EDS_CFECFS_MISSIONLIB_LUABINDINGS C) 23 | 24 | if (LUALIB_FOUND) 25 | include_directories(${LUALIB_INCLUDE_DIRS}) 26 | include_directories(${EDSLIB_FSW_SOURCE_DIR}/inc) 27 | include_directories(${EDSLIB_LUABINDINGS_SOURCE_DIR}/inc) 28 | include_directories(${EDS_CFECFS_MISSIONLIB_FSW_SOURCE_DIR}/inc) 29 | include_directories(inc) 30 | 31 | add_library(cfe_missionlib_lua_softwarebus STATIC 32 | src/cfe_missionlib_lua_softwarebus.c 33 | ) 34 | target_link_libraries(cfe_missionlib_lua_softwarebus edslib_lua cfe_missionlib cfe_missionlib_runtime_static) 35 | add_dependencies(cfe_missionlib_lua_softwarebus edstool-execute) 36 | 37 | add_library(cfe_missionlib_lua_softwarebus_pic OBJECT 38 | src/cfe_missionlib_lua_softwarebus.c 39 | ) 40 | set_target_properties(cfe_missionlib_lua_softwarebus_pic PROPERTIES 41 | POSITION_INDEPENDENT_CODE TRUE 42 | ) 43 | target_include_directories(cfe_missionlib_lua_softwarebus_pic PUBLIC inc ${LUALIB_INCLUDE_DIRS}) 44 | 45 | endif() 46 | -------------------------------------------------------------------------------- /cfecfs/missionlib/lua/inc/cfe_missionlib_lua_softwarebus.h: -------------------------------------------------------------------------------- 1 | /* 2 | * LEW-19710-1, CCSDS SOIS Electronic Data Sheet Implementation 3 | * 4 | * Copyright (c) 2020 United States Government as represented by 5 | * the Administrator of the National Aeronautics and Space Administration. 6 | * All Rights Reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | 21 | 22 | /** 23 | * \file cfe_missionlib_lua_softwarebus.h 24 | * \ingroup lua 25 | * \author joseph.p.hickey@nasa.gov 26 | * 27 | */ 28 | 29 | #ifndef _CFE_MISSIONLIB_LUA_SOFTWAREBUS_H_ 30 | #define _CFE_MISSIONLIB_LUA_SOFTWAREBUS_H_ 31 | 32 | 33 | #include 34 | #include "cfe_missionlib_api.h" 35 | #include "cfe_sb_eds_datatypes.h" 36 | 37 | typedef struct 38 | { 39 | const CFE_MissionLib_SoftwareBus_Interface_t *IntfDB; 40 | uint16_t InstanceNumber; 41 | uint16_t IntfId; 42 | uint16_t TopicId; 43 | uint16_t IndicationId; 44 | EdsLib_Id_t IndicationBaseArg; 45 | } CFE_MissionLib_Lua_Interface_Userdata_t; 46 | 47 | 48 | void CFE_MissionLib_Lua_SoftwareBus_Attach(lua_State *lua, const CFE_MissionLib_SoftwareBus_Interface_t *IntfDB); 49 | 50 | void CFE_MissionLib_Lua_MapPubSubParams(EdsInterface_CFE_SB_SoftwareBus_PubSub_t *PubSub, const CFE_MissionLib_Lua_Interface_Userdata_t *IntfObj); 51 | void CFE_MissionLib_Lua_UnmapPubSubParams(CFE_MissionLib_Lua_Interface_Userdata_t *IntfObj, const EdsInterface_CFE_SB_SoftwareBus_PubSub_t *PubSub); 52 | 53 | #endif /* _CFE_MISSIONLIB_LUA_SOFTWAREBUS_H_ */ 54 | -------------------------------------------------------------------------------- /cfecfs/missionlib/mission_build.cmake: -------------------------------------------------------------------------------- 1 | ########################################################### 2 | # 3 | # EDS CFE mission build setup 4 | # 5 | # This file is evaluated as part of the "prepare" stage 6 | # and can be used to set up prerequisites for the build, 7 | # such as generating header files 8 | # 9 | ########################################################### 10 | 11 | # 12 | # When including this script from a top-level mission build, 13 | # also generate the required build system files. These are 14 | # the same across all CPUs so there is no reason to repeat this 15 | # in the arch-specific builds. 16 | # 17 | function (edslib_find_sources) 18 | 19 | # Now that a complete list of mission dependencies is generated, 20 | # check for the presence of additional special files under each app subdir: 21 | # - Electronic Data Sheet XML source files under eds/ subdirectory 22 | # - Electronic Data Sheet toolchain plugin scripts also under eds/ subdirectory 23 | # - The "functional-test" subdir will be installed to the host functional test dir 24 | # - The "ui" subdir will be installed to the UI pages install dir 25 | file(GLOB_RECURSE MISSION_EDS_FILELIST FOLLOW_SYMLINKS 26 | ${MISSION_DEFS}/eds/*.xml 27 | ) 28 | file(GLOB_RECURSE MISSION_EDS_SCRIPTLIST FOLLOW_SYMLINKS 29 | ${MISSION_DEFS}/eds/*.lua 30 | ${MISSION_SOURCE_DIR}/tools/eds/tool/scripts/*.lua 31 | ) 32 | foreach(APP ${MISSION_DEPS}) 33 | set(APPSRC ${${APP}_MISSION_DIR}) 34 | if (IS_DIRECTORY ${APPSRC}/functional-test AND DEFINED FT_INSTALL_SUBDIR) 35 | install(DIRECTORY ${APPSRC}/functional-test/ DESTINATION ${FT_INSTALL_SUBDIR}) 36 | endif (IS_DIRECTORY ${APPSRC}/functional-test AND DEFINED FT_INSTALL_SUBDIR) 37 | 38 | if (IS_DIRECTORY ${APPSRC}/ui AND DEFINED UI_INSTALL_SUBDIR) 39 | install(DIRECTORY ${APPSRC}/ui/ DESTINATION ${UI_INSTALL_SUBDIR}/pages) 40 | endif() 41 | 42 | if (IS_DIRECTORY ${APPSRC}/eds) 43 | file(GLOB_RECURSE APPXML FOLLOW_SYMLINKS ${APPSRC}/eds/*.xml) 44 | file(GLOB_RECURSE APPSCRIPTS FOLLOW_SYMLINKS ${APPSRC}/eds/*.lua) 45 | list(APPEND MISSION_EDS_FILELIST ${APPXML}) 46 | list(APPEND MISSION_EDS_SCRIPTLIST ${APPSCRIPTS}) 47 | unset(APPXML) 48 | unset(APPSCRIPTS) 49 | endif() 50 | endforeach(APP ${MISSION_DEPS}) 51 | 52 | # EDS toolchain plugin scripts may have ordering dependencies between them, 53 | # so the assembled set of available scripts should be sorted by its filename 54 | # This allows a numeric prefix (NN-) to be prepended in cases where 55 | # the execution order is a concern (similar to UNIX SysV init system approach) 56 | set(EDS_SCRIPT_BASENAMES) 57 | foreach(SCRIPTFILE ${MISSION_EDS_SCRIPTLIST}) 58 | get_filename_component(BASENAME ${SCRIPTFILE} NAME_WE) 59 | set(${BASENAME}_SCRIPT_LOCATION ${SCRIPTFILE}) 60 | list(APPEND EDS_SCRIPT_BASENAMES ${BASENAME}) 61 | endforeach(SCRIPTFILE ${MISSION_EDS_SCRIPTLIST}) 62 | list(SORT EDS_SCRIPT_BASENAMES) 63 | set(MISSION_EDS_SCRIPTLIST) 64 | foreach(BASENAME ${EDS_SCRIPT_BASENAMES}) 65 | list(APPEND MISSION_EDS_SCRIPTLIST ${${BASENAME}_SCRIPT_LOCATION}) 66 | unset(${BASENAME}_SCRIPT_LOCATION) 67 | endforeach(BASENAME ${EDS_SCRIPT_BASENAMES}) 68 | unset(EDS_SCRIPT_BASENAMES) 69 | 70 | # Export the set of EDS source files 71 | configure_file( 72 | ${missionlib_MISSION_DIR}/cmake/edstool-sources.d.in 73 | ${CMAKE_BINARY_DIR}/obj/edstool-sources.d 74 | ) 75 | 76 | endfunction (edslib_find_sources) 77 | 78 | # Capture the set of EDS source files present in the build tree 79 | edslib_find_sources() 80 | 81 | # Generate a list of CPU targets 82 | set(TGTNAMELIST "/* Automatically generated from targets.cmake - do not edit this file directly */\n\n") 83 | if(DEFINED MISSION_CPUNAMES) 84 | foreach(CPUNAME ${MISSION_CPUNAMES}) 85 | set(TGTNAMELIST "${TGTNAMELIST}DEFINE_TGTNAME(${CPUNAME})\n") 86 | endforeach() 87 | else() 88 | set(TGTID 1) 89 | while(DEFINED TGT${TGTID}_NAME) 90 | set(TGTNAMELIST "${TGTNAMELIST}DEFINE_TGTNAME(${TGT${TGTID}_NAME})\n") 91 | math(EXPR TGTID "${TGTID} + 1") 92 | endwhile() 93 | endif() 94 | 95 | # Update the output only if different - avoid unnecessary rebuilds 96 | file(WRITE ${MISSION_BINARY_DIR}/inc/cfe_mission_tgtnames.inc.tmp ${TGTNAMELIST}) 97 | execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different 98 | ${MISSION_BINARY_DIR}/inc/cfe_mission_tgtnames.inc.tmp 99 | ${MISSION_BINARY_DIR}/inc/cfe_mission_tgtnames.inc 100 | ) 101 | file(REMOVE ${MISSION_BINARY_DIR}/inc/cfe_mission_tgtnames.inc.tmp) 102 | 103 | # At the mission scope the "edstool-execute" builds the full set of artifacts 104 | add_custom_target(edstool-execute 105 | COMMAND "\$(MAKE)" 106 | EDSTOOL=$ 107 | -I ${CMAKE_BINARY_DIR}/obj 108 | -f ${missionlib_MISSION_DIR}/cmake/edstool-execute-mission.mk 109 | all 110 | WORKING_DIRECTORY 111 | ${MISSION_BINARY_DIR} 112 | DEPENDS 113 | sedstool 114 | ) 115 | 116 | # Executing the EDS tool per above custom commands is hooked into 117 | # the pre-build process so it is done before any CPU builds. 118 | add_dependencies(mission-prebuild edstool-execute) 119 | -------------------------------------------------------------------------------- /cfecfs/missionlib/python/inc/cfe_missionlib_python.h: -------------------------------------------------------------------------------- 1 | /* 2 | * LEW-20211-1, Python Bindings for the Core Flight Executive Mission Library 3 | * 4 | * Copyright (c) 2020 United States Government as represented by 5 | * the Administrator of the National Aeronautics and Space Administration. 6 | * All Rights Reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | 21 | /****************************************************************************** 22 | ** File: cfe_missionlib_python_module.h 23 | ** 24 | ** Created on: Feb 11, 2020 25 | ** Author: mathew.j.mccaskey@nasa.gov 26 | ** 27 | ** Purpose: 28 | ** Header file for Python / MissionLib bindings 29 | ** 30 | ******************************************************************************/ 31 | 32 | #ifndef TOOLS_EDS_CFECFS_MISSIONLIB_PYTHON_INC_CFE_MISSIONLIB_PYTHON_H_ 33 | #define TOOLS_EDS_CFECFS_MISSIONLIB_PYTHON_INC_CFE_MISSIONLIB_PYTHON_H_ 34 | 35 | #include 36 | #include "cfe_missionlib_api.h" 37 | //#include 38 | //#include 39 | 40 | /** 41 | * Documentation string for this Python module 42 | * 43 | * This is provided for applications that supply their own custom init routine. 44 | */ 45 | #define CFE_MISSIONLIB_PYTHON_DOC "Module which provides an interface to the CFE_MissionLib Runtime Library." 46 | 47 | /** 48 | * Base Name of the Python module 49 | * 50 | * Applications should use this name if registering a custom inittab. 51 | * It needs to be consistent because all module-supplied types use this 52 | * as the base name, which carries through to the respective "repr()" 53 | * implementation and other user-visible items. 54 | */ 55 | #define CFE_MISSIONLIB_PYTHON_MODULE_NAME "CFE_MissionLib" 56 | 57 | /** 58 | * Get the name of a Python entity 59 | * 60 | * This macro converts an unqualified name to a qualified name, 61 | * by adding a prefix of CFE_MISSIONLIB_PYTHON_MODULE_NAME. It is used 62 | * by all types to keep the naming consistent. 63 | */ 64 | #define CFE_MISSIONLIB_PYTHON_ENTITY_NAME(x) CFE_MISSIONLIB_PYTHON_MODULE_NAME "." x 65 | 66 | 67 | /** 68 | * Main Initializer function that sets up a newly-minted module object 69 | * 70 | * This calls PyType_Ready() for all the Python type objects defined in 71 | * this module, and adds the required members to the module, and returns 72 | * the new module to the caller. 73 | * 74 | * This is almost (but not quite) usable as a Python module init function. 75 | * Depending on the environment, additional members may need to be added, 76 | * and the API/name might need to be adjusted (Python2 and Python3 have 77 | * different naming and calling conventions). So it is expected that 78 | * an additional wrapper around this will be added to accommodate this. 79 | */ 80 | PyObject* CFE_MissionLib_Python_CreateModule(void); 81 | 82 | /** 83 | * Creates a Python SoftwareBus Interface Database object from a C Database Object 84 | * 85 | * This would typically be used when the DB object is statically linked 86 | * into the C environment, and should be exposed to Python as a built-in. 87 | */ 88 | PyObject *CFE_MissionLib_Python_Database_CreateFromStaticDB(const char *Name, const CFE_MissionLib_SoftwareBus_Interface_t *Intf); 89 | 90 | /** 91 | * Gets the C EDS Database object from a Python MissionLib Database Object 92 | * 93 | * This should be used when calling the MissionLib API from Python. 94 | */ 95 | const CFE_MissionLib_SoftwareBus_Interface_t *CFE_MissionLib_Python_Database_GetDB(PyObject *obj); 96 | 97 | /** 98 | * Gets a topic entry from a Python CFE MissionLib Interface Database object using a C Msg_Id_t value 99 | * 100 | * This is a convenience wrapper that performs type checking and conversions 101 | */ 102 | //PyTypeObject *CFE_MissionLib_Python_TopicEntry_GetFromMsgId(PyObject *dbobj, const EdsInterface_CFE_SB_SoftwareBus_PubSub_t Params); 103 | 104 | #endif /* TOOLS_EDS_CFECFS_MISSIONLIB_PYTHON_INC_CFE_MISSIONLIB_PYTHON_H_ */ 105 | -------------------------------------------------------------------------------- /cfecfs/missionlib/python/src/cfe_missionlib_python_internal.h: -------------------------------------------------------------------------------- 1 | /* 2 | * LEW-20211-1, Python Bindings for the Core Flight Executive Mission Library 3 | * 4 | * Copyright (c) 2020 United States Government as represented by 5 | * the Administrator of the National Aeronautics and Space Administration. 6 | * All Rights Reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | 21 | /****************************************************************************** 22 | ** File: cfe_missionlib_python_internal.h 23 | ** 24 | ** Created on: Feb 11, 2020 25 | ** Author: mathew.j.mccaskey 26 | ** 27 | ** Purpose: 28 | ** Internal Header file for Python / cfe_missionlib bindings 29 | ** 30 | ******************************************************************************/ 31 | 32 | 33 | #ifndef _CFE_MISSIONLIB_PYTHON_INTERNAL_H_ 34 | #define _CFE_MISSIONLIB_PYTHON_INTERNAL_H_ 35 | 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | 45 | #include "cfe_missionlib_python.h" 46 | #include "cfe_missionlib_database_types.h" 47 | #include "edslib_binding_objects.h" 48 | #include "edslib_python_internal.h" 49 | 50 | typedef struct 51 | { 52 | PyObject_HEAD 53 | void *dl; 54 | const CFE_MissionLib_SoftwareBus_Interface_t *IntfDb; 55 | EdsLib_Python_Database_t *EdsDbObj; 56 | PyObject *DbName; 57 | /* TypeCache contains weak references to Databases, such that they 58 | * will not be re-created each time they are required. This also gives persistence, 59 | * i.e. repeated calls to lookup the same type give the same object, instead of a 60 | * separate-but-equal object. */ 61 | PyObject *TypeCache; 62 | PyObject *WeakRefList; 63 | } CFE_MissionLib_Python_Database_t; 64 | 65 | typedef struct 66 | { 67 | PyObject_HEAD 68 | CFE_MissionLib_Python_Database_t *DbObj; 69 | PyObject *IntfName; 70 | uint16_t InterfaceId; 71 | CFE_MissionLib_InterfaceInfo_t IntfInfo; 72 | 73 | /* TypeCache contains weak references to Interfaces in the db, such that they 74 | * will not be re-created each time they are required. This also gives persistence, 75 | * i.e. repeated calls to lookup the same type give the same object, instead of a 76 | * separate-but-equal object. */ 77 | PyObject *TypeCache; 78 | PyObject *WeakRefList; 79 | } CFE_MissionLib_Python_Interface_t; 80 | 81 | typedef struct 82 | { 83 | PyObject_HEAD 84 | CFE_MissionLib_Python_Interface_t *IntfObj; 85 | PyObject *TopicName; 86 | uint16_t TopicId; 87 | EdsLib_Id_t EdsId; 88 | CFE_MissionLib_IndicationInfo_t IndInfo; 89 | 90 | /* TypeCache contains weak references to Topics in the db, such that they 91 | * will not be re-created each time they are required. This also gives persistence, 92 | * i.e. repeated calls to lookup the same type give the same object, instead of a 93 | * separate-but-equal object. */ 94 | PyObject *TypeCache; 95 | PyObject *WeakRefList; 96 | } CFE_MissionLib_Python_Topic_t; 97 | 98 | typedef struct 99 | { 100 | PyObject_HEAD 101 | uint16_t Index; 102 | PyObject* refobj; 103 | } CFE_MissionLib_Python_InstanceIterator_t; 104 | 105 | typedef struct 106 | { 107 | PyObject_HEAD 108 | uint16_t Index; 109 | PyObject* refobj; 110 | } CFE_MissionLib_Python_InterfaceIterator_t; 111 | 112 | typedef struct 113 | { 114 | PyObject_HEAD 115 | EdsLib_Id_t Index; 116 | PyObject* refobj; 117 | } CFE_MissionLib_Python_TopicIterator_t; 118 | 119 | const CFE_MissionLib_SoftwareBus_Interface_t *CFE_MissionLib_Python_Database_GetDB(PyObject *obj); 120 | //const CFE_MissionLib_InterfaceId_Entry_t *CFE_MissionLib_Python_Interface_GetEntry(PyObject *obj); 121 | //const CFE_MissionLib_TopicId_Entry_t *CFE_MissionLib_Python_Topic_GetEntry(PyObject *obj); 122 | 123 | PyObject *CFE_MissionLib_Python_Interface_GetFromIntfName(CFE_MissionLib_Python_Database_t *obj, PyObject *InterfaceName); 124 | PyObject *CFE_MissionLib_Python_Topic_GetFromTopicName(CFE_MissionLib_Python_Interface_t *obj, PyObject *TopicName); 125 | 126 | PyObject *CFE_MissionLib_Python_Database_CreateFromStaticDB(const char *Name, const CFE_MissionLib_SoftwareBus_Interface_t *IntfDb); 127 | 128 | extern PyObject *CFE_MissionLib_Python_DatabaseCache; 129 | extern PyObject *CFE_MissionLib_Python_InterfaceCache; 130 | extern PyObject *CFE_MissionLib_Python_TopicCache; 131 | 132 | extern PyTypeObject CFE_MissionLib_Python_DatabaseType; 133 | extern PyTypeObject CFE_MissionLib_Python_InterfaceType; 134 | extern PyTypeObject CFE_MissionLib_Python_TopicType; 135 | 136 | #endif /* _CFE_MISSIONLIB_PYTHON_INTERNAL_H_ */ 137 | -------------------------------------------------------------------------------- /cfecfs/missionlib/python/src/cfe_missionlib_python_module.c: -------------------------------------------------------------------------------- 1 | /* 2 | * LEW-20211-1, Python Bindings for the Core Flight Executive Mission Library 3 | * 4 | * Copyright (c) 2020 United States Government as represented by 5 | * the Administrator of the National Aeronautics and Space Administration. 6 | * All Rights Reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | 21 | /****************************************************************************** 22 | ** File: cfe_missionlib_python_module.c 23 | ** 24 | ** Created on: Feb 11, 2017 25 | ** Author: mathew.j.mccaskey 26 | ** 27 | ** Purpose: 28 | ** A module that implements Python bindings for CFE_MissionLib objects 29 | ** 30 | ** This file is just a thin wrapper that contains a Python-compatible init 31 | ** function for the module. This is expected to be used when the MissionLib 32 | ** module is imported directly in a Python program. No built-in database 33 | ** object will be added. The user is on their own to load a database 34 | ** separately from the CFE_MissionLib module. 35 | ** 36 | ** Note that other applications which embed Python would typically 37 | ** _not_ use this entry point. Instead, the MissionLib would be registered 38 | ** as a built-in module using its own customized init, and typically 39 | ** would add an actual database object to the module during that process. 40 | ** 41 | ******************************************************************************/ 42 | 43 | #include "cfe_missionlib_python.h" 44 | #include 45 | #include 46 | #include 47 | #include 48 | #include 49 | #include 50 | #include 51 | #include 52 | 53 | /* 54 | * Init Function / Entry point 55 | * 56 | * A wrapper function is necessary to handle the 57 | * difference in module init between Python 2 (void) and 58 | * Python 3 (PyObject*). The symbol also has a different 59 | * naming convention. The Python2 wrapper just calls the 60 | * common init function and discards the return value. 61 | * 62 | * This entry point also should be declared using the 63 | * PyMODINIT_FUNC macro to ensure it is externally visible 64 | * and has the right calling convention. 65 | */ 66 | #if (PY_MAJOR_VERSION >= 3) 67 | 68 | /* 69 | * Python 3+ init function variant: 70 | * Returns the new module object to the interpreter. 71 | * Python3 should always define PyMODINIT_FUNC 72 | */ 73 | PyMODINIT_FUNC PyInit_CFE_MissionLib(void) 74 | { 75 | /* python3 init should return the module object */ 76 | return CFE_MissionLib_Python_CreateModule(); 77 | } 78 | 79 | #else 80 | 81 | /* 82 | * In case the Python headers didn't supply PyMODINIT_FUNC, 83 | * (which is possible in older versions) then just use void. 84 | */ 85 | #ifndef PyMODINIT_FUNC 86 | #define PyMODINIT_FUNC void 87 | #endif 88 | 89 | 90 | PyMODINIT_FUNC initCFE_MissionLib(void) 91 | { 92 | /* python2 does not want module object */ 93 | CFE_MissionLib_Python_CreateModule(); 94 | } 95 | 96 | #endif 97 | 98 | -------------------------------------------------------------------------------- /cfecfs/missionlib/python/src/cfe_missionlib_python_setup.c: -------------------------------------------------------------------------------- 1 | /* 2 | * LEW-20211-1, Python Bindings for the Core Flight Executive Mission Library 3 | * 4 | * Copyright (c) 2020 United States Government as represented by 5 | * the Administrator of the National Aeronautics and Space Administration. 6 | * All Rights Reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | 21 | /****************************************************************************** 22 | ** File: cfe_missionlib_python_setup.c 23 | ** 24 | ** Created on: Feb 11, 2020 25 | ** Author: mathew.j.mccaskey 26 | ** 27 | ** Purpose: 28 | ** Implement setup function / initializer for EDS/MissionLib module objects 29 | ** 30 | ******************************************************************************/ 31 | 32 | #include "cfe_missionlib_python_internal.h" 33 | 34 | /* 35 | * Instantiation function. 36 | * 37 | * The C API differs between Python 3+ (PyModule_Create) and 38 | * Python 2 (Py_InitModule3). This just creates a wrapper 39 | * to call the right one. 40 | */ 41 | #if (PY_MAJOR_VERSION >= 3) 42 | 43 | static PyModuleDef CFE_MissionLib_Python_ModuleDef = 44 | { 45 | PyModuleDef_HEAD_INIT, 46 | CFE_MISSIONLIB_PYTHON_MODULE_NAME, 47 | PyDoc_STR(CFE_MISSIONLIB_PYTHON_DOC), 48 | -1 49 | }; 50 | 51 | static inline PyObject* CFE_MissionLib_Python_InstantiateModule(void) 52 | { 53 | /* python3 uses PyModule_Create() API */ 54 | return PyModule_Create(&CFE_MissionLib_Python_ModuleDef); 55 | } 56 | 57 | #else 58 | 59 | static inline PyObject* CFE_MissionLib_Python_InstantiateModule(void) 60 | { 61 | /* python2 uses Py_InitModule3() API */ 62 | return Py_InitModule3(CFE_MISSIONLIB_PYTHON_MODULE_NAME, NULL, CFE_MISSIONLIB_PYTHON_DOC); 63 | } 64 | 65 | #endif 66 | 67 | 68 | PyObject* CFE_MissionLib_Python_CreateModule(void) 69 | { 70 | PyObject *m = NULL; 71 | 72 | do 73 | { 74 | /* 75 | * Prepare all of the types defined here 76 | */ 77 | if (PyType_Ready(&CFE_MissionLib_Python_DatabaseType) != 0 || 78 | PyType_Ready(&CFE_MissionLib_Python_InterfaceType) != 0 || 79 | PyType_Ready(&CFE_MissionLib_Python_TopicType) != 0) 80 | { 81 | break; 82 | } 83 | 84 | if (CFE_MissionLib_Python_DatabaseCache == NULL) 85 | { 86 | CFE_MissionLib_Python_DatabaseCache = PyDict_New(); 87 | if (CFE_MissionLib_Python_DatabaseCache == NULL) 88 | { 89 | break; 90 | } 91 | } 92 | 93 | if (CFE_MissionLib_Python_InterfaceCache == NULL) 94 | { 95 | CFE_MissionLib_Python_InterfaceCache = PyDict_New(); 96 | if (CFE_MissionLib_Python_InterfaceCache == NULL) 97 | { 98 | break; 99 | } 100 | } 101 | 102 | if (CFE_MissionLib_Python_TopicCache == NULL) 103 | { 104 | CFE_MissionLib_Python_TopicCache = PyDict_New(); 105 | if (CFE_MissionLib_Python_TopicCache == NULL) 106 | { 107 | break; 108 | } 109 | } 110 | 111 | m = CFE_MissionLib_Python_InstantiateModule(); 112 | if (m == NULL) 113 | { 114 | break; 115 | } 116 | 117 | /* 118 | * Add appropriate types so object instances can be constructed 119 | */ 120 | PyModule_AddObject(m, "Database", (PyObject*)&CFE_MissionLib_Python_DatabaseType); 121 | PyModule_AddObject(m, "Interface", (PyObject*)&CFE_MissionLib_Python_InterfaceType); 122 | PyModule_AddObject(m, "Topic", (PyObject*)&CFE_MissionLib_Python_TopicType); 123 | } 124 | while(0); 125 | 126 | return m; 127 | } 128 | -------------------------------------------------------------------------------- /cfecfs/scriptengine/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(CFE_SCRIPTENGINE C) 2 | 3 | # Create the app module 4 | add_cfe_app(scriptengine 5 | fsw/src/scriptengine.c 6 | $ 7 | $ 8 | ) 9 | 10 | target_include_directories(scriptengine PUBLIC fsw/inc) 11 | target_include_directories(scriptengine PRIVATE 12 | $ 13 | $ 14 | ) 15 | 16 | if (ENABLE_UNIT_TESTS) 17 | add_subdirectory(ut-stubs) 18 | endif (ENABLE_UNIT_TESTS) 19 | 20 | # Install the executables to a staging area for test in cross environments 21 | if (INSTALL_TARGET_LIST) 22 | foreach(TGT ${INSTALL_TARGET_LIST}) 23 | install(FILES scripts/testscript.lua DESTINATION ${TGT}/${INSTALL_SUBDIR}) 24 | endforeach() 25 | endif() 26 | -------------------------------------------------------------------------------- /cfecfs/scriptengine/fsw/inc/scriptengine.h: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes” 3 | * 4 | * Copyright (c) 2020 United States Government as represented by the 5 | * Administrator of the National Aeronautics and Space Administration. 6 | * All Rights Reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 9 | * not use this file except in compliance with the License. You may obtain 10 | * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | ************************************************************************/ 18 | 19 | /** 20 | * \file 21 | * Specification for the sample library functions. 22 | */ 23 | #ifndef SCRIPTENGINE_H 24 | #define SCRIPTENGINE_H 25 | 26 | /************************************************************************ 27 | ** Includes 28 | *************************************************************************/ 29 | #include "cfe.h" 30 | 31 | /************************************************************************ 32 | ** Type Definitions 33 | *************************************************************************/ 34 | 35 | /************************************************************************* 36 | ** Exported Functions 37 | *************************************************************************/ 38 | 39 | /************************************************************************/ 40 | /** \brief Library Initialization Function 41 | ** 42 | ** \par Description 43 | ** This function is required by CFE to initialize the library 44 | ** It should be specified in the cfe_es_startup.scr file as part 45 | ** of loading this library. It is not directly invoked by 46 | ** applications. 47 | ** 48 | ** \par Assumptions, External Events, and Notes: 49 | ** None 50 | ** 51 | ** \return Execution status, see \ref CFEReturnCodes 52 | ** 53 | ** 54 | *************************************************************************/ 55 | int32 SCRIPTENGINE_Init(void); 56 | 57 | int32 SCRIPTENGINE_LoadFile(const char *Filename); 58 | 59 | int32 SCRIPTENGINE_CallFunctionVoid(const char *FunctionName); 60 | int32 SCRIPTENGINE_CallFunctionArg(const char *FunctionName, void *ArgData, uint16 AppIdx, uint16 FormatIdx); 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /cfecfs/scriptengine/fsw/src/scriptengine_internal.h: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes” 3 | * 4 | * Copyright (c) 2020 United States Government as represented by the 5 | * Administrator of the National Aeronautics and Space Administration. 6 | * All Rights Reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 9 | * not use this file except in compliance with the License. You may obtain 10 | * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | ************************************************************************/ 18 | 19 | /** 20 | * @file 21 | * An example of an internal (private) header file for SAMPLE Lib 22 | */ 23 | #ifndef SCRIPTENGINE_INTERNAL_H 24 | #define SCRIPTENGINE_INTERNAL_H 25 | 26 | /* Include all external/public definitions */ 27 | #include "scriptengine.h" 28 | 29 | #include 30 | 31 | 32 | /************************************************************************* 33 | ** Macro Definitions 34 | *************************************************************************/ 35 | 36 | typedef struct 37 | { 38 | lua_State *lua; 39 | } SCRIPTENGINE_Global_t; 40 | 41 | /************************************************************************* 42 | ** Internal Data Structures 43 | *************************************************************************/ 44 | extern SCRIPTENGINE_Global_t SCRIPTENGINE_Global; 45 | 46 | /************************************************************************* 47 | ** Function Declarations 48 | *************************************************************************/ 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /cfecfs/scriptengine/scripts/testscript.lua: -------------------------------------------------------------------------------- 1 | print "Hello, World. Lua engine is starting." 2 | 3 | function TestFunc() 4 | print "This is TestFunc()" 5 | 6 | cmd = EdsDB.GetInterface("CFE_ES/Application/CMD") 7 | testobj = EdsDB.NewMessage(cmd, "NoopCMD") 8 | 9 | print("obj=" .. EdsDB.ToHexString(testobj)) 10 | 11 | CFE.SendMsg(testobj) 12 | end 13 | 14 | print "Completed Lua engine startup." 15 | -------------------------------------------------------------------------------- /cfecfs/scriptengine/ut-stubs/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ################################################################## 2 | # 3 | # This CMake file contains the recipe for building the stub function 4 | # libraries that correlate with the library public API. This supports 5 | # unit testing of OTHER modules, where the test cases for those modules 6 | # are linked with the stubs supplied here. 7 | # 8 | ################################################################## 9 | 10 | add_cfe_coverage_stubs(scriptengine scriptengine_stubs.c) 11 | -------------------------------------------------------------------------------- /cfecfs/scriptengine/ut-stubs/scriptengine_stubs.c: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes” 3 | * 4 | * Copyright (c) 2020 United States Government as represented by the 5 | * Administrator of the National Aeronautics and Space Administration. 6 | * All Rights Reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 9 | * not use this file except in compliance with the License. You may obtain 10 | * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | ************************************************************************/ 18 | 19 | /** 20 | * @file 21 | * 22 | * Auto-Generated stub implementations for functions defined in scriptengine header 23 | */ 24 | 25 | #include "scriptengine.h" 26 | #include "utgenstub.h" 27 | 28 | /* 29 | * ---------------------------------------------------- 30 | * Generated stub function for SCRIPTENGINE_CallFunctionArg() 31 | * ---------------------------------------------------- 32 | */ 33 | int32 SCRIPTENGINE_CallFunctionArg(const char *FunctionName, void *ArgData, uint16 AppIdx, uint16 FormatIdx) 34 | { 35 | UT_GenStub_SetupReturnBuffer(SCRIPTENGINE_CallFunctionArg, int32); 36 | 37 | UT_GenStub_AddParam(SCRIPTENGINE_CallFunctionArg, const char *, FunctionName); 38 | UT_GenStub_AddParam(SCRIPTENGINE_CallFunctionArg, void *, ArgData); 39 | UT_GenStub_AddParam(SCRIPTENGINE_CallFunctionArg, uint16, AppIdx); 40 | UT_GenStub_AddParam(SCRIPTENGINE_CallFunctionArg, uint16, FormatIdx); 41 | 42 | UT_GenStub_Execute(SCRIPTENGINE_CallFunctionArg, Basic, NULL); 43 | 44 | return UT_GenStub_GetReturnValue(SCRIPTENGINE_CallFunctionArg, int32); 45 | } 46 | 47 | /* 48 | * ---------------------------------------------------- 49 | * Generated stub function for SCRIPTENGINE_CallFunctionVoid() 50 | * ---------------------------------------------------- 51 | */ 52 | int32 SCRIPTENGINE_CallFunctionVoid(const char *FunctionName) 53 | { 54 | UT_GenStub_SetupReturnBuffer(SCRIPTENGINE_CallFunctionVoid, int32); 55 | 56 | UT_GenStub_AddParam(SCRIPTENGINE_CallFunctionVoid, const char *, FunctionName); 57 | 58 | UT_GenStub_Execute(SCRIPTENGINE_CallFunctionVoid, Basic, NULL); 59 | 60 | return UT_GenStub_GetReturnValue(SCRIPTENGINE_CallFunctionVoid, int32); 61 | } 62 | 63 | /* 64 | * ---------------------------------------------------- 65 | * Generated stub function for SCRIPTENGINE_Init() 66 | * ---------------------------------------------------- 67 | */ 68 | int32 SCRIPTENGINE_Init(void) 69 | { 70 | UT_GenStub_SetupReturnBuffer(SCRIPTENGINE_Init, int32); 71 | 72 | UT_GenStub_Execute(SCRIPTENGINE_Init, Basic, NULL); 73 | 74 | return UT_GenStub_GetReturnValue(SCRIPTENGINE_Init, int32); 75 | } 76 | 77 | /* 78 | * ---------------------------------------------------- 79 | * Generated stub function for SCRIPTENGINE_LoadFile() 80 | * ---------------------------------------------------- 81 | */ 82 | int32 SCRIPTENGINE_LoadFile(const char *Filename) 83 | { 84 | UT_GenStub_SetupReturnBuffer(SCRIPTENGINE_LoadFile, int32); 85 | 86 | UT_GenStub_AddParam(SCRIPTENGINE_LoadFile, const char *, Filename); 87 | 88 | UT_GenStub_Execute(SCRIPTENGINE_LoadFile, Basic, NULL); 89 | 90 | return UT_GenStub_GetReturnValue(SCRIPTENGINE_LoadFile, int32); 91 | } 92 | -------------------------------------------------------------------------------- /cfecfs/testexecutive/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # LEW-19710-1, CCSDS SOIS Electronic Data Sheet Implementation 3 | # 4 | # Copyright (c) 2020 United States Government as represented by 5 | # the Administrator of the National Aeronautics and Space Administration. 6 | # All Rights Reserved. 7 | # 8 | # Licensed under the Apache License, Version 2.0 (the "License"); 9 | # you may not use this file except in compliance with the License. 10 | # You may obtain a copy of the License at 11 | # 12 | # http://www.apache.org/licenses/LICENSE-2.0 13 | # 14 | # Unless required by applicable law or agreed to in writing, software 15 | # distributed under the License is distributed on an "AS IS" BASIS, 16 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | # See the License for the specific language governing permissions and 18 | # limitations under the License. 19 | # 20 | 21 | # Functional test (black box) framework 22 | 23 | include_directories(${MISSION_BINARY_DIR}/inc) 24 | include_directories(${osal_MISSION_DIR}/src/os/inc) 25 | include_directories(${osal_MISSION_DIR}/ut_assert/inc) 26 | include_directories(${OSAL_INCLUDEDIR}) 27 | include_directories(${EDSLIB_FSW_SOURCE_DIR}/inc) 28 | include_directories(${EDSLIB_LUABINDINGS_SOURCE_DIR}/inc) 29 | include_directories(${EDS_CFECFS_MISSIONLIB_FSW_SOURCE_DIR}/inc) 30 | include_directories(${EDS_CFECFS_MISSIONLIB_LUABINDINGS_SOURCE_DIR}/inc) 31 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}/inc) 32 | include_directories(${LUALIB_INCLUDE_DIRS}) 33 | include_directories(${CMAKE_CURRENT_BINARY_DIR}) 34 | 35 | add_definitions(-Wall -Werror) 36 | set(TESTEXEC_INTF_MODULES Remote) 37 | 38 | if (DEFINED to_lab_MISSION_DIR AND DEFINED ci_lab_MISSION_DIR) 39 | list(APPEND TESTEXEC_INTF_MODULES CI_TO_LAB) 40 | endif() 41 | 42 | set(TESTEXEC_LIBS 43 | edslib_runtime_static 44 | cfe_missionlib 45 | cfe_missionlib_runtime_static 46 | cfe_edsdb_static 47 | cfe_missionlib_interfacedb_static 48 | ) 49 | 50 | set(TESTEXEC_INTF_SRCFILES) 51 | set(TESTEXEC_INTF_MODLIST) 52 | foreach (MOD ${TESTEXEC_INTF_MODULES}) 53 | string(TOLOWER ${MOD} LMOD) 54 | list(APPEND TESTEXEC_INTF_SRCFILES modules/${LMOD}_interface.c) 55 | list(APPEND TESTEXEC_INTF_MODLIST "TESTEXEC_MODULE(${MOD})\n") 56 | endforeach (MOD ${TESTEXEC_INTF_MODULES}) 57 | file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/testexec_compiledin_modules.h.tmp" 58 | ${TESTEXEC_INTF_MODLIST}) 59 | execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different 60 | "${CMAKE_CURRENT_BINARY_DIR}/testexec_compiledin_modules.h.tmp" 61 | "${CMAKE_CURRENT_BINARY_DIR}/testexec_compiledin_modules.h") 62 | 63 | 64 | add_executable(testexec src/testexec.c src/test_interface.c ${TESTEXEC_INTF_SRCFILES}) 65 | add_dependencies(testexec edstool-execute) 66 | target_link_libraries(testexec 67 | ut_bsp 68 | ut_assert 69 | osal 70 | edslib_lua 71 | cfe_missionlib_lua_softwarebus 72 | ${TESTEXEC_LIBS} 73 | ) 74 | 75 | add_executable(testctrl src/testctrl.c) 76 | add_dependencies(testctrl edstool-execute) 77 | target_link_libraries(testctrl 78 | osal 79 | ${TESTEXEC_LIBS} 80 | ) 81 | 82 | install(TARGETS testexec testctrl DESTINATION host) 83 | -------------------------------------------------------------------------------- /cfecfs/testexecutive/inc/testexec.h: -------------------------------------------------------------------------------- 1 | /* 2 | * LEW-19710-1, CCSDS SOIS Electronic Data Sheet Implementation 3 | * 4 | * Copyright (c) 2020 United States Government as represented by 5 | * the Administrator of the National Aeronautics and Space Administration. 6 | * All Rights Reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | 21 | 22 | /** 23 | * \file testexec.h 24 | * \ingroup testexecutive 25 | * \author joseph.p.hickey@nasa.gov 26 | * 27 | * Test executive header file 28 | */ 29 | 30 | #ifndef _TESTEXEC_H_ 31 | #define _TESTEXEC_H_ 32 | 33 | 34 | int TestIntf_Udp_Create(struct lua_State *lua); 35 | int TestIntf_Remote_Create(struct lua_State *lua); 36 | int TestIntf_GetFactory(struct lua_State *lua); 37 | 38 | #endif /* _TESTEXEC_H_ */ 39 | 40 | -------------------------------------------------------------------------------- /cfecfs/util/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # LEW-19710-1, CCSDS SOIS Electronic Data Sheet Implementation 3 | # 4 | # Copyright (c) 2020 United States Government as represented by 5 | # the Administrator of the National Aeronautics and Space Administration. 6 | # All Rights Reserved. 7 | # 8 | # Licensed under the Apache License, Version 2.0 (the "License"); 9 | # you may not use this file except in compliance with the License. 10 | # You may obtain a copy of the License at 11 | # 12 | # http://www.apache.org/licenses/LICENSE-2.0 13 | # 14 | # Unless required by applicable law or agreed to in writing, software 15 | # distributed under the License is distributed on an "AS IS" BASIS, 16 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | # See the License for the specific language governing permissions and 18 | # limitations under the License. 19 | # 20 | 21 | 22 | # This directory provides command-line utilities which are 23 | # useful when debugging CFS applications that use EDS 24 | 25 | include_directories(${MISSION_BINARY_DIR}/inc) 26 | include_directories(${EDSLIB_FSW_SOURCE_DIR}/inc) 27 | include_directories(${EDS_CFECFS_MISSIONLIB_FSW_SOURCE_DIR}/inc) 28 | 29 | set(UTIL_LINK_LIBS 30 | edslib_runtime_static 31 | cfe_missionlib 32 | cfe_missionlib_runtime_static 33 | cfe_edsdb_static 34 | cfe_missionlib_interfacedb_static 35 | ) 36 | 37 | # CMake snippet for building cmdUtil 38 | 39 | add_executable(cmdutil cmdUtil.c) 40 | target_link_libraries(cmdutil ${UTIL_LINK_LIBS}) 41 | install(TARGETS cmdutil DESTINATION host) 42 | 43 | 44 | # CMake snippet for building EDS tlm decoder tool 45 | 46 | add_executable(tlm_decode tlm_decode.c) 47 | target_link_libraries(tlm_decode ${UTIL_LINK_LIBS}) 48 | install(TARGETS tlm_decode DESTINATION host) 49 | 50 | 51 | -------------------------------------------------------------------------------- /doc/.gitignore: -------------------------------------------------------------------------------- 1 | *.pdf 2 | -------------------------------------------------------------------------------- /doc/Makefile: -------------------------------------------------------------------------------- 1 | # Command to generate the user guide PDF from the markdown file 2 | 3 | eds_dom_reference.pdf: eds-dom-reference.md 4 | egrep -v '^\\' eds-dom-reference.md | pandoc -f markdown -s -N -V documentclass=report -V geometry:margin=1in -o eds_dom_reference.pdf 5 | -------------------------------------------------------------------------------- /doc/seds-dom-example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa/EdsLib/7eb94477c5aa32a2dba1f342df720a56722821a1/doc/seds-dom-example.png -------------------------------------------------------------------------------- /doc/seds-dom-interfaces.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa/EdsLib/7eb94477c5aa32a2dba1f342df720a56722821a1/doc/seds-dom-interfaces.png -------------------------------------------------------------------------------- /edslib/cmake/dbobj_patternrules.mk: -------------------------------------------------------------------------------- 1 | # Generic pattern rules for building EDS database objects 2 | 3 | # 4 | # ****************************************************************************** 5 | # ** Pattern rule to build a single database file ** 6 | # ****************************************************************************** 7 | # 8 | 9 | EDSTOOL_ARCH ?= host 10 | 11 | $(O)/%_impl.o: src/%_impl.c 12 | @echo EDS: Compiling $(<) for $(EDSTOOL_ARCH) 13 | $(CC) $(CFLAGS) -Iinc -D_EDSLIB_BUILD_ -MMD -c -o $@ $< 14 | 15 | 16 | # 17 | # ****************************************************************************** 18 | # ** Pattern rule to build a static archive file ** 19 | # ****************************************************************************** 20 | # 21 | 22 | $(O)/%.a: 23 | @echo EDS: Archiving $(@) for $(EDSTOOL_ARCH) 24 | -rm -f $(@) 25 | $(AR) cr $@ $^ 26 | 27 | 28 | # 29 | # ****************************************************************************** 30 | # ** Pattern rule to build a dynamic shared object file ** 31 | # ****************************************************************************** 32 | # 33 | 34 | # This is a bit of a hack - 35 | # Embedded targets like VxWorks and RTEMS use relocatable objects (i.e. .obj files) as 36 | # loadable modules. These are not shared objects (.so) in the Linux/POSIX sense, and 37 | # need a different linker flag(s) to build them. In lieu of somehow extracting the full 38 | # linker logic that CMake uses, this just assumes a GNU-style LD, and that the file extension 39 | # (.so or .obj) indicates the style of loadable object being used. 40 | 41 | $(O)/%.so: 42 | @echo EDS: Linking shared object $(@) for $(EDSTOOL_ARCH) 43 | $(LD) $(SHARED_LDFLAGS) -shared -o $@ $^ 44 | 45 | $(O)/%.obj: 46 | @echo EDS: Linking relocatable object $(@) for $(EDSTOOL_ARCH) 47 | $(LD) $(SHARED_LDFLAGS) -r -o $@ $^ 48 | -------------------------------------------------------------------------------- /edslib/configtest/edslib_longdouble.c: -------------------------------------------------------------------------------- 1 | /* 2 | * LEW-19710-1, CCSDS SOIS Electronic Data Sheet Implementation 3 | * 4 | * Copyright (c) 2020 United States Government as represented by 5 | * the Administrator of the National Aeronautics and Space Administration. 6 | * All Rights Reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | 21 | 22 | /** 23 | * \file edslib_longdouble.c 24 | * \ingroup edslib 25 | * \author joseph.p.hickey@nasa.gov 26 | * 27 | ** This is a configuration test file used by the build system to determine 28 | ** the level of floating point type support of the compiler and C library. 29 | ** 30 | ** For the Pack/Unpack routines in EdsLib it is beneficial to use the maximum 31 | ** precision that is possible using the native FPU. C99 defined the "long double" 32 | ** type and other systems may even have some form of quad type. 33 | ** 34 | ** On the other end of the spectrum, embedded microcontrollers may not even 35 | ** support any sort of extended-precision type at all. 36 | ** 37 | ** At the moment this checks if we can compile a simple function that uses 38 | ** the long double type. If this succeeds then it is assumed that the system 39 | ** has a functional "long double" implementation. Otherwise a standard "double" 40 | ** can be used instead. 41 | */ 42 | 43 | #include 44 | #include 45 | #include 46 | 47 | int main(void) 48 | { 49 | long double x1,x2; 50 | long double y; 51 | int e; 52 | 53 | x1 = 1234.0L; 54 | 55 | /* 56 | * It is important to actually call some C99 long-double math functions, 57 | * as it is possible the compiler knows the type but the C library does not. 58 | * (RTEMS is an example) 59 | * 60 | * EdsLib uses some others beyond these two, but it is assumed if these 61 | * two will build and link than the others will too. 62 | */ 63 | y = frexpl(x1, &e); 64 | x2 = ldexpl(y, e); 65 | 66 | if (x1 != x2) 67 | { 68 | return(EXIT_FAILURE); 69 | } 70 | 71 | return(EXIT_SUCCESS); 72 | } 73 | -------------------------------------------------------------------------------- /edslib/doc/.gitignore: -------------------------------------------------------------------------------- 1 | html 2 | latex 3 | -------------------------------------------------------------------------------- /edslib/doc/images/compilation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa/EdsLib/7eb94477c5aa32a2dba1f342df720a56722821a1/edslib/doc/images/compilation.png -------------------------------------------------------------------------------- /edslib/doc/images/overview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa/EdsLib/7eb94477c5aa32a2dba1f342df720a56722821a1/edslib/doc/images/overview.png -------------------------------------------------------------------------------- /edslib/doc/images/prebuild.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa/EdsLib/7eb94477c5aa32a2dba1f342df720a56722821a1/edslib/doc/images/prebuild.png -------------------------------------------------------------------------------- /edslib/doc/images/verification.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa/EdsLib/7eb94477c5aa32a2dba1f342df720a56722821a1/edslib/doc/images/verification.png -------------------------------------------------------------------------------- /edslib/eds/55-write_edsdb_makefiles.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- LEW-19710-1, CCSDS SOIS Electronic Data Sheet Implementation 3 | -- 4 | -- Copyright (c) 2020 United States Government as represented by 5 | -- the Administrator of the National Aeronautics and Space Administration. 6 | -- All Rights Reserved. 7 | -- 8 | -- Licensed under the Apache License, Version 2.0 (the "License"); 9 | -- you may not use this file except in compliance with the License. 10 | -- You may obtain a copy of the License at 11 | -- 12 | -- http://www.apache.org/licenses/LICENSE-2.0 13 | -- 14 | -- Unless required by applicable law or agreed to in writing, software 15 | -- distributed under the License is distributed on an "AS IS" BASIS, 16 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | -- See the License for the specific language governing permissions and 18 | -- limitations under the License. 19 | -- 20 | 21 | 22 | -- ------------------------------------------------------------------------- 23 | -- Lua Script to actually _build_ the edslib generated source files 24 | -- 25 | -- After this script completes, "SEDS.edslib" should be a fully-functioning 26 | -- set of Lua bindings for the EDS objects just as it would be in an external tool, 27 | -- and thus it can be used to instantiate C versions of EDS-described objects that 28 | -- will be compatible with future Flight Software code. 29 | -- ------------------------------------------------------------------------- 30 | 31 | local output 32 | local objdir = SEDS.get_define("OBJDIR") or "obj" 33 | local makefilename = SEDS.to_filename("db_objects.mk") 34 | local libtypes = { ".a", ".so", ".obj" } 35 | local dbobjects = { "_datatypedb_impl.o", "_displaydb_impl.o" } 36 | local global_sym_prefix = SEDS.get_define("MISSION_NAME") 37 | global_sym_prefix = global_sym_prefix and string.upper(global_sym_prefix) or "EDS" 38 | 39 | -- ------------------------------------- 40 | -- Simple helper to get the object names 41 | local function get_objnames(prefix,suffix,n,q) 42 | local result = "" 43 | for _,t in ipairs(suffix) do 44 | result = result .. string.format("%s/%s%s ",prefix,SEDS.to_filename(n,q),t) 45 | end 46 | return result 47 | end 48 | 49 | -- ------------------------------------- 50 | -- Simple helper to write a makefile rule to an output file 51 | -- They are written on separate lines to improve readability of the generated file 52 | local function write_rule(output,targets,dependencies) 53 | output:write(string.format("%s:\\", targets)) 54 | output:write(string.format(" %s",dependencies)) 55 | output:add_whitespace(1) 56 | end 57 | 58 | 59 | -- -------------------------------------------------------------------- 60 | -- Step 1: generate a C source file for db "summary information" 61 | -- This is basically a master table which contains references back to 62 | -- all database objects generated by previous scripts 63 | -- -------------------------------------------------------------------- 64 | output = SEDS.output_open(SEDS.to_filename("summary_impl.c")) 65 | 66 | output:write(string.format("#include \"edslib_database_types.h\"")) 67 | output:write(string.format("#include \"%s\"",SEDS.to_filename("master_index.h"))) 68 | output:add_whitespace(1) 69 | 70 | output:write(string.format("extern EdsLib_DataTypeDB_t %s_DATATYPEDB_APPTBL[];",global_sym_prefix)) 71 | output:write(string.format("extern EdsLib_DisplayDB_t %s_DISPLAYDB_APPTBL[];",global_sym_prefix)) 72 | 73 | output:section_marker("EDS mission object that incorporates all generated elements") 74 | output:write(string.format("const EdsLib_DatabaseObject_t %s_DATABASE =",global_sym_prefix)) 75 | output:start_group("{") 76 | output:write(string.format(".AppTableSize = %s_MAX_INDEX,",global_sym_prefix)) 77 | output:write(string.format(".DataTypeDB_Table = %s_DATATYPEDB_APPTBL,",global_sym_prefix)) 78 | output:write(string.format(".DisplayDB_Table = %s_DISPLAYDB_APPTBL,",global_sym_prefix)) 79 | output:end_group("};") 80 | 81 | SEDS.output_close(output) 82 | 83 | 84 | -- -------------------------------------------------------------------- 85 | -- Step 3: generate a makefile for the actual EDS database 86 | -- This is a set dependencies between the library objects (.a and .so files) 87 | -- and the sources that go into each one. The pattern rules from the previous 88 | -- step will be used to formulate actual build commands. 89 | -- -------------------------------------------------------------------- 90 | output = SEDS.output_open(makefilename) 91 | 92 | output:write("include $(O)/edstool-buildenv.d $(wildcard $(O)/*.d)") 93 | output:write("include $(EDSLIB_SOURCE_DIR)/cmake/dbobj_patternrules.mk") 94 | output:add_whitespace(1) 95 | 96 | output:section_marker("Mission Summary Object") 97 | write_rule(output, 98 | get_objnames("$(O)",libtypes, "db"), 99 | get_objnames("$(O)",dbobjects,"") .. string.format("$(O)/%s", SEDS.to_filename("summary_impl.o")) 100 | ) 101 | 102 | output:section_marker("Database objects from EDS files") 103 | for ds in SEDS.root:iterate_children(SEDS.basenode_filter) do 104 | output:write(string.format("# Targets from %s",ds.xml_filename)) 105 | write_rule(output, 106 | get_objnames("$(O)", libtypes, "", ds.name) .. get_objnames("$(O)", libtypes, "db"), 107 | get_objnames("$(O)", dbobjects, "", ds.name) 108 | ) 109 | output:add_whitespace(1) 110 | end 111 | 112 | SEDS.output_close(output) 113 | -------------------------------------------------------------------------------- /edslib/fsw/inc/edslib_init.h: -------------------------------------------------------------------------------- 1 | /* 2 | * LEW-19710-1, CCSDS SOIS Electronic Data Sheet Implementation 3 | * 4 | * Copyright (c) 2020 United States Government as represented by 5 | * the Administrator of the National Aeronautics and Space Administration. 6 | * All Rights Reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | 21 | 22 | /** 23 | * \file edslib_init.h 24 | * \ingroup fsw 25 | * \author joseph.p.hickey@nasa.gov 26 | * 27 | * Prototype for the combined EDS library init function 28 | */ 29 | 30 | #ifndef _EDSLIB_INIT_H_ 31 | #define _EDSLIB_INIT_H_ 32 | 33 | /** 34 | * Combined EDS library initializer function. 35 | * 36 | * Initializes the complete library, including the DataTypeDB, 37 | * DisplayDB, and Binding object API. 38 | */ 39 | void EdsLib_Initialize(void); 40 | 41 | #endif /* _EDSLIB_INIT_H_ */ 42 | 43 | -------------------------------------------------------------------------------- /edslib/fsw/src/edslib_datatypedb_lookup.c: -------------------------------------------------------------------------------- 1 | /* 2 | * LEW-19710-1, CCSDS SOIS Electronic Data Sheet Implementation 3 | * 4 | * Copyright (c) 2020 United States Government as represented by 5 | * the Administrator of the National Aeronautics and Space Administration. 6 | * All Rights Reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | 21 | 22 | /** 23 | * \file edslib_datatypedb_lookup.c 24 | * \ingroup fsw 25 | * \author joseph.p.hickey@nasa.gov 26 | * 27 | * Internal API functions for dealing with the EDS-defined type identifiers 28 | * that are used in the external API. These are safe indices into the internal database, 29 | * which can be converted into a pointer into the DB. 30 | * 31 | * Since the index value can be checked and verified before actually dereferencing the 32 | * data, it is safer to use than a direct memory pointer. However all internal API calls 33 | * generally pass around direct DB object pointers for efficiency. 34 | * 35 | * This is linked as part of the "basic" EDS library 36 | */ 37 | 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | 44 | #include "edslib_internal.h" 45 | 46 | 47 | void EdsLib_Decode_StructId(EdsLib_DatabaseRef_t *RefObj, EdsLib_Id_t EdsId) 48 | { 49 | RefObj->AppIndex = EdsLib_Get_AppIdx(EdsId); 50 | RefObj->TypeIndex = EdsLib_Get_FormatIdx(EdsId); 51 | } 52 | 53 | EdsLib_Id_t EdsLib_Encode_StructId(const EdsLib_DatabaseRef_t *RefObj) 54 | { 55 | if (RefObj == NULL) 56 | { 57 | return EDSLIB_ID_INVALID; 58 | } 59 | return EDSLIB_MAKE_ID(RefObj->AppIndex, RefObj->TypeIndex); 60 | } 61 | 62 | EdsLib_DataTypeDB_t EdsLib_DataTypeDB_GetTopLevel(const EdsLib_DatabaseObject_t *GD, uint16_t AppIdx) 63 | { 64 | if (GD == NULL || GD->DataTypeDB_Table == NULL) 65 | { 66 | return NULL; 67 | } 68 | 69 | if (AppIdx >= GD->AppTableSize) 70 | { 71 | return NULL; 72 | } 73 | 74 | return GD->DataTypeDB_Table[AppIdx]; 75 | } 76 | 77 | const EdsLib_DataTypeDB_Entry_t *EdsLib_DataTypeDB_GetEntry(const EdsLib_DatabaseObject_t *GD, const EdsLib_DatabaseRef_t *RefObj) 78 | { 79 | EdsLib_DataTypeDB_t Dict; 80 | const EdsLib_DataTypeDB_Entry_t *DataDictEntry; 81 | const EdsLib_DatabaseRef_t *CurrRef; 82 | 83 | DataDictEntry = NULL; 84 | CurrRef = RefObj; 85 | 86 | while (true) 87 | { 88 | if (CurrRef == NULL) 89 | { 90 | break; 91 | } 92 | 93 | Dict = EdsLib_DataTypeDB_GetTopLevel(GD, CurrRef->AppIndex); 94 | if (Dict == NULL) 95 | { 96 | break; 97 | } 98 | 99 | if (CurrRef->TypeIndex >= Dict->DataTypeTableSize) 100 | { 101 | break; 102 | } 103 | 104 | DataDictEntry = &Dict->DataTypeTable[CurrRef->TypeIndex]; 105 | 106 | if (DataDictEntry->BasicType != EDSLIB_BASICTYPE_ALIAS) 107 | { 108 | break; 109 | } 110 | 111 | CurrRef = &DataDictEntry->Detail.Alias.RefObj; 112 | } 113 | 114 | return DataDictEntry; 115 | } 116 | 117 | 118 | void EdsLib_DataTypeDB_CopyTypeInfo(const EdsLib_DataTypeDB_Entry_t *DataDictEntry, EdsLib_DataTypeDB_TypeInfo_t *TypeInfo) 119 | { 120 | memset(TypeInfo, 0, sizeof(*TypeInfo)); 121 | if (DataDictEntry != NULL) 122 | { 123 | TypeInfo->Size = DataDictEntry->SizeInfo; 124 | TypeInfo->ElemType = DataDictEntry->BasicType; 125 | TypeInfo->NumSubElements = DataDictEntry->NumSubElements; 126 | } 127 | } 128 | 129 | -------------------------------------------------------------------------------- /edslib/fsw/src/edslib_displaydb_lookup.c: -------------------------------------------------------------------------------- 1 | /* 2 | * LEW-19710-1, CCSDS SOIS Electronic Data Sheet Implementation 3 | * 4 | * Copyright (c) 2020 United States Government as represented by 5 | * the Administrator of the National Aeronautics and Space Administration. 6 | * All Rights Reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | 21 | 22 | /** 23 | * \file edslib_displaydb_lookup.c 24 | * \ingroup fsw 25 | * \author joseph.p.hickey@nasa.gov 26 | * 27 | * Public API functions for dealing with the EDS-defined "Mission-Unique" 28 | * message identifiers. This includes: 29 | * - looking up a descriptive name for a message id 30 | * - converting a user-supplied string to a message id 31 | * 32 | * This is linked as part of the "full" EDS library 33 | */ 34 | 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | 41 | #include "edslib_internal.h" 42 | 43 | EdsLib_DisplayDB_t EdsLib_DisplayDB_GetTopLevel(const EdsLib_DatabaseObject_t *GD, uint16_t AppIdx) 44 | { 45 | /* 46 | * As name tables are dependent on data tables, check that data table is also present 47 | */ 48 | if (GD->DisplayDB_Table == NULL) 49 | { 50 | return NULL; 51 | } 52 | 53 | if (AppIdx >= GD->AppTableSize) 54 | { 55 | return NULL; 56 | } 57 | 58 | return GD->DisplayDB_Table[AppIdx]; 59 | } 60 | 61 | const EdsLib_DisplayDB_Entry_t *EdsLib_DisplayDB_GetEntry(const EdsLib_DatabaseObject_t *GD, const EdsLib_DatabaseRef_t *RefObj) 62 | { 63 | EdsLib_DisplayDB_t NameDict; 64 | EdsLib_DataTypeDB_t DataDict; 65 | 66 | if (RefObj == NULL) 67 | { 68 | return NULL; 69 | } 70 | 71 | DataDict = EdsLib_DataTypeDB_GetTopLevel(GD, RefObj->AppIndex); 72 | if (DataDict == NULL) 73 | { 74 | return NULL; 75 | } 76 | 77 | NameDict = EdsLib_DisplayDB_GetTopLevel(GD, RefObj->AppIndex); 78 | if (NameDict == NULL) 79 | { 80 | return NULL; 81 | } 82 | 83 | if (NameDict->DisplayInfoTable == NULL || 84 | RefObj->TypeIndex >= DataDict->DataTypeTableSize) 85 | { 86 | return NULL; 87 | } 88 | 89 | return &NameDict->DisplayInfoTable[RefObj->TypeIndex]; 90 | } 91 | 92 | -------------------------------------------------------------------------------- /edslib/fsw/src/edslib_init.c: -------------------------------------------------------------------------------- 1 | /* 2 | * LEW-19710-1, CCSDS SOIS Electronic Data Sheet Implementation 3 | * 4 | * Copyright (c) 2020 United States Government as represented by 5 | * the Administrator of the National Aeronautics and Space Administration. 6 | * All Rights Reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | 21 | 22 | /** 23 | * \file edslib_init.c 24 | * \ingroup fsw 25 | * \author joseph.p.hickey@nasa.gov 26 | * 27 | * Implementation EDS library initialization function. 28 | * 29 | * Depending on the type of environment/executable that the EDS runtime library is 30 | * utilized in, it may need a custom initialization function. This source file 31 | * is kept separate so it can be easily replaced/overridden by a custom initializer 32 | * if necessary. 33 | */ 34 | 35 | #include "edslib_internal.h" 36 | 37 | /* 38 | * ************************************************************************************* 39 | * Complete Initializer Function 40 | * Initializes the DataTypeDB, DisplayDB, and Binding Object subsystems. 41 | * ************************************************************************************* 42 | */ 43 | 44 | void EdsLib_Initialize(void) 45 | { 46 | EdsLib_DataTypeDB_Initialize(); 47 | EdsLib_DisplayDB_Initialize(); 48 | EdsLib_Binding_Initialize(); 49 | } 50 | 51 | -------------------------------------------------------------------------------- /edslib/fsw/src/edslib_msgid_api.c: -------------------------------------------------------------------------------- 1 | /* 2 | * LEW-19710-1, CCSDS SOIS Electronic Data Sheet Implementation 3 | * 4 | * Copyright (c) 2020 United States Government as represented by 5 | * the Administrator of the National Aeronautics and Space Administration. 6 | * All Rights Reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | 21 | 22 | /** 23 | * \file edslib_msgid_api.c 24 | * \ingroup fsw 25 | * \author joseph.p.hickey@nasa.gov 26 | * 27 | * Public API functions for dealing with the EDS-defined "Mission-Unique" 28 | * message identifiers. This includes: 29 | * - looking up a descriptive name for a message id 30 | * - converting a user-supplied string to a message id 31 | * 32 | * This is linked as part of the "full" EDS library 33 | */ 34 | 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | 41 | #include "edslib_displaydb.h" 42 | #include "edslib_internal.h" 43 | 44 | EdsLib_Id_t EdsLib_DisplayDB_LookupTypeName(const EdsLib_DatabaseObject_t *GD, const char *String) 45 | { 46 | EdsLib_DisplayDB_t NameDict; 47 | EdsLib_DataTypeDB_t DataDict; 48 | const EdsLib_DisplayDB_Entry_t *DisplayInfo; 49 | const char *EndPtr; 50 | size_t PartLength; 51 | uint16_t InstanceNum; 52 | uint16_t AppIdx; 53 | uint16_t StructId; 54 | EdsLib_Id_t Result; 55 | 56 | /* 57 | * A global structure ID is different than a message ID in two ways: 58 | * - there is no cpu number 59 | * - the format index goes directly into the map table 60 | */ 61 | 62 | Result = EDSLIB_ID_INVALID; 63 | NameDict = NULL; 64 | InstanceNum = 0; 65 | 66 | if (GD->DisplayDB_Table != NULL && GD->DataTypeDB_Table != NULL) 67 | { 68 | /* 69 | * Next component is the EDS object name (required) 70 | * this is actually the fully-qualified name including the namespace parts 71 | * Note that the DB is organized by datasheets, NOT by namespace, so there is 72 | * no way to go directly to a namespace -- it could be scattered in multiple datasheets. 73 | * So this must do a sequential search 74 | */ 75 | for (AppIdx = 0; AppIdx < GD->AppTableSize; ++AppIdx) 76 | { 77 | DataDict = GD->DataTypeDB_Table[AppIdx]; 78 | NameDict = GD->DisplayDB_Table[AppIdx]; 79 | if (NameDict == NULL || DataDict == NULL || 80 | NameDict->DisplayInfoTable == NULL) 81 | { 82 | continue; 83 | } 84 | 85 | DisplayInfo = NameDict->DisplayInfoTable; 86 | for (StructId = 0; StructId < DataDict->DataTypeTableSize; ++StructId, ++DisplayInfo) 87 | { 88 | EndPtr = String; 89 | if (DisplayInfo->Namespace != NULL) 90 | { 91 | PartLength = strlen(DisplayInfo->Namespace); 92 | if (strncmp(DisplayInfo->Namespace, String, PartLength) != 0 || 93 | String[PartLength] != '/') 94 | { 95 | continue; 96 | } 97 | EndPtr += PartLength + 1; 98 | } 99 | if (DisplayInfo->Name != NULL && 100 | strcmp(DisplayInfo->Name,EndPtr) == 0) 101 | { 102 | /* Initialize the Global ID with the result */ 103 | Result = EDSLIB_MAKE_ID(AppIdx, StructId); 104 | EdsLib_Set_CpuNumber(&Result, InstanceNum); 105 | break; 106 | } 107 | } 108 | } 109 | } 110 | 111 | return Result; 112 | } 113 | 114 | -------------------------------------------------------------------------------- /edslib/fsw/ut-stubs/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # LEW-19710-1, CCSDS SOIS Electronic Data Sheet Implementation 3 | # 4 | # Copyright (c) 2020 United States Government as represented by 5 | # the Administrator of the National Aeronautics and Space Administration. 6 | # All Rights Reserved. 7 | # 8 | # Licensed under the Apache License, Version 2.0 (the "License"); 9 | # you may not use this file except in compliance with the License. 10 | # You may obtain a copy of the License at 11 | # 12 | # http://www.apache.org/licenses/LICENSE-2.0 13 | # 14 | # Unless required by applicable law or agreed to in writing, software 15 | # distributed under the License is distributed on an "AS IS" BASIS, 16 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | # See the License for the specific language governing permissions and 18 | # limitations under the License. 19 | # 20 | 21 | # 22 | # Create the generic stubs library 23 | # 24 | add_library(ut_edslib_stubs STATIC 25 | edslib_binding_objects_stubs.c 26 | edslib_datatypedb_stubs.c 27 | edslib_displaydb_stubs.c 28 | edslib_init_stubs.c 29 | ) 30 | 31 | target_link_libraries(ut_edslib_stubs 32 | edslib_api 33 | ut_assert 34 | ) 35 | -------------------------------------------------------------------------------- /edslib/fsw/ut-stubs/edslib_init_stubs.c: -------------------------------------------------------------------------------- 1 | /* 2 | * LEW-19710-1, CCSDS SOIS Electronic Data Sheet Implementation 3 | * 4 | * Copyright (c) 2020 United States Government as represented by 5 | * the Administrator of the National Aeronautics and Space Administration. 6 | * All Rights Reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | 21 | /** 22 | * @file 23 | * 24 | * Auto-Generated stub implementations for functions defined in edslib_init header 25 | */ 26 | 27 | #include "edslib_init.h" 28 | #include "utgenstub.h" 29 | 30 | /* 31 | * ---------------------------------------------------- 32 | * Generated stub function for EdsLib_Initialize() 33 | * ---------------------------------------------------- 34 | */ 35 | void EdsLib_Initialize(void) 36 | { 37 | 38 | UT_GenStub_Execute(EdsLib_Initialize, Basic, NULL); 39 | } 40 | -------------------------------------------------------------------------------- /edslib/json/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # LEW-19710-1, CCSDS SOIS Electronic Data Sheet Implementation 3 | # 4 | # Copyright (c) 2020 United States Government as represented by 5 | # the Administrator of the National Aeronautics and Space Administration. 6 | # All Rights Reserved. 7 | # 8 | # Licensed under the Apache License, Version 2.0 (the "License"); 9 | # you may not use this file except in compliance with the License. 10 | # You may obtain a copy of the License at 11 | # 12 | # http://www.apache.org/licenses/LICENSE-2.0 13 | # 14 | # Unless required by applicable law or agreed to in writing, software 15 | # distributed under the License is distributed on an "AS IS" BASIS, 16 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | # See the License for the specific language governing permissions and 18 | # limitations under the License. 19 | # 20 | 21 | # Build script for EdsLib-JSON binding library 22 | project(EDSLIB_JSONBINDINGS C) 23 | 24 | # This uses the "json-c" library to do JSON manipulation 25 | if(NOT JSON_C_FOUND) 26 | 27 | # By default, try to find any json-c version if no version specified... 28 | # This simplifies building as a simple local library. 29 | 30 | # But do not assume this default when cross-compiling or building CFS, 31 | # because if the toolchain isn't configured correctly, searching could 32 | # find the wrong version and break the build 33 | # (in particular, pkg-config might find the host version instead of 34 | # the cross version and try to use it) 35 | 36 | # In any sort of cross-compile or CFS build, then the user needs to 37 | # explicitly do something to enable JSON bindings. 38 | 39 | if (NOT DEFINED EDSLIB_JSON_C_SEARCH_VERSION AND 40 | NOT CMAKE_CROSSCOMPILING AND 41 | NOT IS_CFS_ARCH_BUILD) 42 | set(EDSLIB_JSON_C_SEARCH_VERSION json-c json) 43 | endif() 44 | 45 | if (EDSLIB_JSON_C_SEARCH_VERSION) 46 | find_edslib_dependency(JSON_C json.h ${EDSLIB_JSON_C_SEARCH_VERSION}) 47 | endif(EDSLIB_JSON_C_SEARCH_VERSION) 48 | 49 | endif(NOT JSON_C_FOUND) 50 | 51 | 52 | # If not found then this module cannot be built, however 53 | # this is an optional feature therefore not a fatal error. 54 | if (NOT JSON_C_FOUND) 55 | message(" JSON support not configured, skipping EdsLib JSON bindings") 56 | else(NOT JSON_C_FOUND) 57 | include_directories(${EDSLIB_FSW_SOURCE_DIR}/inc) 58 | include_directories(${JSON_C_INCLUDE_DIRS}) 59 | include_directories(inc) 60 | 61 | set(EDSLIB_JSON_SOURCES src/edslib_json_objects.c) 62 | 63 | # The "edslib_json_static" target is a simple static library 64 | add_library(edslib_json_static STATIC EXCLUDE_FROM_ALL 65 | ${EDSLIB_JSON_SOURCES}) 66 | target_link_libraries(edslib_json_static ${JSON_C_LIBRARIES}) 67 | 68 | # The "edslib_json_pic" target is the same code complied as PIC 69 | # it can be used as the basis of a module or shared lib 70 | add_library(edslib_json_pic OBJECT EXCLUDE_FROM_ALL 71 | ${EDSLIB_JSON_SOURCES}) 72 | set_target_properties(edslib_json_pic PROPERTIES 73 | POSITION_INDEPENDENT_CODE TRUE) 74 | 75 | 76 | endif (NOT JSON_C_FOUND) 77 | 78 | -------------------------------------------------------------------------------- /edslib/json/inc/edslib_json_objects.h: -------------------------------------------------------------------------------- 1 | /* 2 | * LEW-19710-1, CCSDS SOIS Electronic Data Sheet Implementation 3 | * 4 | * Copyright (c) 2020 United States Government as represented by 5 | * the Administrator of the National Aeronautics and Space Administration. 6 | * All Rights Reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | 21 | 22 | /** 23 | * \file edslib_json_objects.h 24 | * \ingroup json 25 | * \author joseph.p.hickey@nasa.gov 26 | * 27 | * API definition for EdsLib-JSON binding library 28 | */ 29 | 30 | #ifndef _EDSLIB_JSON_OBJECTS_H_ 31 | #define _EDSLIB_JSON_OBJECTS_H_ 32 | 33 | #include 34 | 35 | 36 | #ifdef __cplusplus 37 | extern "C" 38 | { 39 | #endif 40 | 41 | /* 42 | * decouple from json-c headers; 43 | * json_object will be an abstract struct 44 | */ 45 | typedef struct json_object EdsLib_JsonBinding_Object_t; 46 | typedef struct EdsLib_Binding_DescriptorObject EdsLib_JsonBinding_DescriptorObject_t; 47 | 48 | void EdsLib_JSON_EdsObjectFromJSON(EdsLib_JsonBinding_DescriptorObject_t *DstObject, EdsLib_JsonBinding_Object_t *SrcObject); 49 | EdsLib_JsonBinding_Object_t *EdsLib_JSON_EdsObjectToJSON(const EdsLib_JsonBinding_DescriptorObject_t *SrcObject); 50 | 51 | #ifdef __cplusplus 52 | } /* extern "C" */ 53 | #endif 54 | 55 | 56 | #endif /* _EDSLIB_JSON_OBJECTS_H_ */ 57 | 58 | -------------------------------------------------------------------------------- /edslib/lua/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # LEW-19710-1, CCSDS SOIS Electronic Data Sheet Implementation 3 | # 4 | # Copyright (c) 2020 United States Government as represented by 5 | # the Administrator of the National Aeronautics and Space Administration. 6 | # All Rights Reserved. 7 | # 8 | # Licensed under the Apache License, Version 2.0 (the "License"); 9 | # you may not use this file except in compliance with the License. 10 | # You may obtain a copy of the License at 11 | # 12 | # http://www.apache.org/licenses/LICENSE-2.0 13 | # 14 | # Unless required by applicable law or agreed to in writing, software 15 | # distributed under the License is distributed on an "AS IS" BASIS, 16 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | # See the License for the specific language governing permissions and 18 | # limitations under the License. 19 | # 20 | 21 | # LUA bindings for EdsLib 22 | project(EDSLIB_LUABINDINGS C) 23 | 24 | # This library depends on a Lua library on the system 25 | if(NOT LUALIB_FOUND) 26 | 27 | # By default, try to find any 5.x version if no version specified... 28 | # This simplifies building as a simple local library. 29 | 30 | # But do not assume this default when cross-compiling or building CFS, 31 | # because if the toolchain isn't configured correctly, searching could 32 | # find the wrong version and break the build 33 | # (in particular, pkg-config might find the host version instead of 34 | # the cross version and try to use it) 35 | 36 | # In any sort of cross-compile or CFS build, then the user needs to 37 | # explicitly do something to enable Lua bindings. 38 | 39 | if (NOT DEFINED EDSLIB_LUA_SEARCH_VERSION AND 40 | NOT CMAKE_CROSSCOMPILING AND 41 | NOT IS_CFS_ARCH_BUILD) 42 | set(EDSLIB_LUA_SEARCH_VERSION lua-5.3 lua5.3 lua-5.2 lua5.2 lua-5.1 lua5.1 lua>=5.1) 43 | endif() 44 | 45 | if (EDSLIB_LUA_SEARCH_VERSION) 46 | find_edslib_dependency(LUALIB lua.h ${EDSLIB_LUA_SEARCH_VERSION}) 47 | endif(EDSLIB_LUA_SEARCH_VERSION) 48 | 49 | endif(NOT LUALIB_FOUND) 50 | 51 | 52 | # If not found then this module cannot be built, however 53 | # this is an optional feature therefore not a fatal error. 54 | if (NOT LUALIB_FOUND) 55 | message(" Lua support not configured, skipping EdsLib Lua bindings") 56 | else (NOT LUALIB_FOUND) 57 | include_directories(${EDSLIB_FSW_SOURCE_DIR}/inc) 58 | include_directories(${LUALIB_INCLUDE_DIRS}) 59 | include_directories(inc) 60 | 61 | add_library(edslib_lua STATIC 62 | src/edslib_lua_objects.c 63 | ) 64 | target_link_libraries(edslib_lua ${LUALIB_LDFLAGS}) 65 | 66 | add_library(edslib_lua_pic OBJECT EXCLUDE_FROM_ALL 67 | src/edslib_lua_objects.c 68 | ) 69 | set_target_properties(edslib_lua_pic PROPERTIES 70 | POSITION_INDEPENDENT_CODE TRUE) 71 | target_include_directories(edslib_lua_pic PUBLIC inc ${LUALIB_INCLUDE_DIRS}) 72 | 73 | endif(NOT LUALIB_FOUND) 74 | -------------------------------------------------------------------------------- /edslib/lua/inc/edslib_lua_objects.h: -------------------------------------------------------------------------------- 1 | /* 2 | * LEW-19710-1, CCSDS SOIS Electronic Data Sheet Implementation 3 | * 4 | * Copyright (c) 2020 United States Government as represented by 5 | * the Administrator of the National Aeronautics and Space Administration. 6 | * All Rights Reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | 21 | 22 | /** 23 | * \file edslib_lua_objects.h 24 | * \ingroup lua 25 | * \author joseph.p.hickey@nasa.gov 26 | * 27 | * API for EdsLib-Lua binding library 28 | */ 29 | 30 | #ifndef _EDSLIB_LUA_OBJECTS_H_ 31 | #define _EDSLIB_LUA_OBJECTS_H_ 32 | 33 | 34 | #include 35 | #include 36 | 37 | /* 38 | * Abstract types for the Lua binding 39 | * These are not distinct types, but intended to be aliases of types defined elsewhere. 40 | * They are aliases to avoid creating a dependency on the header file which actually defines them. 41 | */ 42 | typedef struct lua_State EdsLib_LuaBinding_State_t; 43 | typedef struct EdsLib_Binding_DescriptorObject EdsLib_LuaBinding_DescriptorObject_t; 44 | typedef struct EdsLib_DatabaseObject EdsLib_LuaBinding_DatabaseObject_t; 45 | 46 | typedef struct 47 | { 48 | const EdsLib_LuaBinding_DatabaseObject_t *GD; 49 | } EdsLib_Lua_Database_Userdata_t; 50 | 51 | void EdsLib_LuaBinding_GetNativeObject(EdsLib_LuaBinding_State_t *lua, int narg, void **OutPtr, size_t *SizeBuf); 52 | EdsLib_LuaBinding_DescriptorObject_t *EdsLib_LuaBinding_CreateEmptyObject(EdsLib_LuaBinding_State_t *lua, size_t MaxSize); 53 | void EdsLib_Lua_Attach(EdsLib_LuaBinding_State_t *lua, const EdsLib_LuaBinding_DatabaseObject_t *MissionObj); 54 | 55 | 56 | #endif /* _EDSLIB_LUA_OBJECTS_H_ */ 57 | 58 | -------------------------------------------------------------------------------- /edslib/mainpage.dox: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | \mainpage Electronic Data Sheets (EDS) build tools and runtime library main page 4 | 5 | The EDS library provides an implementation of the CCSDS book 876 electronic data sheets. The 6 | library provided here is intended for both ground and embedded use. 7 | 8 | \tableofcontents 9 | 10 | \section intro Introduction 11 | 12 | Electronic Data Sheets are implemented in XML - a well established, widely used, 13 | platform neutral, machine readable language 14 | 15 | - Geared toward space applications, and the more general problem of getting different 16 | devices from different vendors, different space agencies/nationalities to reliably 17 | communicate with each other even as specifications change. 18 | - EDS XML schema developed CCSDS Spacecraft Onboard Information Systems (SOIS) working group, 19 | collaboration between NASA and ESA. 20 | - Internationally reviewed by various CCSDS member agencies. 21 | 22 | EDS defines interface hierarchies 23 | 24 | - Message that contain sub-messages, depending on a given field (i.e. “message type”). 25 | - Encoded in the EDS, so implementations do not rely on their own “dispatch tables” that could become outdated. 26 | 27 | EDS defines binary formats of interface components 28 | 29 | - Defined as sequence of integers, strings, floats, etc. of varying sizes 30 | - Defines symbolic names for enumerated integer values in messages 31 | 32 | \image html overview.png "Overview of EDS workflow" 33 | 34 | \subpage build 35 | 36 | */ 37 | 38 | -------------------------------------------------------------------------------- /edslib/python/src/edslib_python_module.c: -------------------------------------------------------------------------------- 1 | /* 2 | * LEW-19710-1, CCSDS SOIS Electronic Data Sheet Implementation 3 | * 4 | * Copyright (c) 2020 United States Government as represented by 5 | * the Administrator of the National Aeronautics and Space Administration. 6 | * All Rights Reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | 21 | 22 | /** 23 | * \file edslib_python_module.c 24 | * \ingroup python 25 | * \author joseph.p.hickey@nasa.gov 26 | * 27 | ** A module that implements Python bindings for EDS objects 28 | ** 29 | ** This file is just a thin wrapper that contains a Python-compatible init 30 | ** function for the module. This is expected to be used when the EdsLib 31 | ** module is imported directly in a Python program. No built-in database 32 | ** object will be added. The user is on their own to load a database 33 | ** separately from the EdsLib module. 34 | ** 35 | ** Note that other applications which embed Python would typically 36 | ** _not_ use this entry point. Instead, the EdsLib would be registered 37 | ** as a built-in module using its own customized init, and typically 38 | ** would add an actual database object to the module during that process. 39 | */ 40 | 41 | #include "edslib_python.h" 42 | 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include 48 | #include 49 | #include 50 | #include 51 | 52 | /* 53 | * Init Function / Entry point 54 | * 55 | * A wrapper function is necessary to handle the 56 | * difference in module init between Python 2 (void) and 57 | * Python 3 (PyObject*). The symbol also has a different 58 | * naming convention. The Python2 wrapper just calls the 59 | * common init function and discards the return value. 60 | * 61 | * This entry point also should be declared using the 62 | * PyMODINIT_FUNC macro to ensure it is externally visible 63 | * and has the right calling convention. 64 | */ 65 | #if (PY_MAJOR_VERSION >= 3) 66 | 67 | /* 68 | * Python 3+ init function variant: 69 | * Returns the new module object to the interpreter. 70 | * Python3 should always define PyMODINIT_FUNC 71 | */ 72 | PyMODINIT_FUNC PyInit_EdsLib(void) 73 | { 74 | /* python3 init should return the module object */ 75 | return EdsLib_Python_CreateModule(); 76 | } 77 | 78 | #else 79 | 80 | /* 81 | * In case the Python headers didn't supply PyMODINIT_FUNC, 82 | * (which is possible in older versions) then just use void. 83 | */ 84 | #ifndef PyMODINIT_FUNC 85 | #define PyMODINIT_FUNC void 86 | #endif 87 | 88 | 89 | PyMODINIT_FUNC initEdsLib(void) 90 | { 91 | /* python2 does not want module object */ 92 | EdsLib_Python_CreateModule(); 93 | } 94 | 95 | #endif 96 | 97 | -------------------------------------------------------------------------------- /edslib/python/src/edslib_python_scalar.c: -------------------------------------------------------------------------------- 1 | /* 2 | * LEW-19710-1, CCSDS SOIS Electronic Data Sheet Implementation 3 | * 4 | * Copyright (c) 2020 United States Government as represented by 5 | * the Administrator of the National Aeronautics and Space Administration. 6 | * All Rights Reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | 21 | 22 | /** 23 | * \file edslib_python_scalar.c 24 | * \ingroup python 25 | * \author joseph.p.hickey@nasa.gov 26 | * 27 | ** Implement Python data type for EDS scalar objects. 28 | ** 29 | ** This is to provide a better implementation of the "str" routine, which 30 | ** converts EDS objects into strings. Without this, the "repr" function 31 | ** would be used which produces less useful results for passing into another 32 | ** function which expects a string. 33 | */ 34 | 35 | #include "edslib_python_internal.h" 36 | 37 | static PyObject *EdsLib_Python_NativeObject_ScalarType_str(PyObject *obj); 38 | 39 | PyTypeObject EdsLib_Python_ObjectScalarType = 40 | { 41 | PyVarObject_HEAD_INIT(NULL, 0) 42 | .tp_name = EDSLIB_PYTHON_ENTITY_NAME("Scalar"), 43 | .tp_basicsize = sizeof(EdsLib_Python_ObjectBase_t), 44 | .tp_base = &EdsLib_Python_ObjectBaseType, 45 | .tp_str = EdsLib_Python_NativeObject_ScalarType_str, 46 | .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, 47 | .tp_doc = PyDoc_STR("EDS ScalarDataType") 48 | }; 49 | 50 | static PyObject *EdsLib_Python_NativeObject_ScalarType_str(PyObject *obj) 51 | { 52 | PyObject *pyobj; 53 | PyObject *result = NULL; 54 | 55 | /* 56 | * First convert into the most appropriate native python object 57 | * 58 | * This may return a unicode object directly, if it is indeed a StringDataType in EDS. 59 | * 60 | * Note that only scalars should ever get here, as arrays and containers would 61 | * not be a derivative of this type. 62 | */ 63 | pyobj = EdsLib_Python_ConvertEdsObjectToPython((EdsLib_Python_ObjectBase_t *)obj); 64 | 65 | if (pyobj != NULL) 66 | { 67 | if (pyobj->ob_type == &PyUnicode_Type) 68 | { 69 | /* already a unicode object, so return it */ 70 | Py_INCREF(pyobj); 71 | result = pyobj; 72 | } 73 | else 74 | { 75 | /* further coerce the python object into a string */ 76 | result = PyObject_Str(pyobj); 77 | } 78 | Py_DECREF(pyobj); 79 | } 80 | 81 | return result; 82 | } 83 | -------------------------------------------------------------------------------- /edslib/python/src/edslib_python_setup.c: -------------------------------------------------------------------------------- 1 | /* 2 | * LEW-19710-1, CCSDS SOIS Electronic Data Sheet Implementation 3 | * LEW-20211-1, Python Bindings for the Core Flight Executive Mission Library 4 | * 5 | * Copyright (c) 2020 United States Government as represented by 6 | * the Administrator of the National Aeronautics and Space Administration. 7 | * All Rights Reserved. 8 | * 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | */ 21 | 22 | 23 | /** 24 | * \file edslib_python_setup.c 25 | * \ingroup python 26 | * \author joseph.p.hickey@nasa.gov 27 | * 28 | ** Implement setup function / initializer for EDS/Python module objects 29 | */ 30 | 31 | #include "edslib_python_internal.h" 32 | 33 | /* 34 | * Instantiation function. 35 | * 36 | * The C API differs between Python 3+ (PyModule_Create) and 37 | * Python 2 (Py_InitModule3). This just creates a wrapper 38 | * to call the right one. 39 | */ 40 | #if (PY_MAJOR_VERSION >= 3) 41 | 42 | static PyModuleDef EdsLib_Python_ModuleDef = 43 | { 44 | PyModuleDef_HEAD_INIT, 45 | EDSLIB_PYTHON_MODULE_NAME, 46 | PyDoc_STR(EDSLIB_PYTHON_DOC), 47 | -1 48 | }; 49 | 50 | static inline PyObject* EdsLib_Python_InstantiateModule(void) 51 | { 52 | /* python3 uses PyModule_Create() API */ 53 | return PyModule_Create(&EdsLib_Python_ModuleDef); 54 | } 55 | 56 | #else 57 | 58 | static inline PyObject* EdsLib_Python_InstantiateModule(void) 59 | { 60 | /* python2 uses Py_InitModule3() API */ 61 | return Py_InitModule3(EDSLIB_PYTHON_MODULE_NAME, NULL, EDSLIB_PYTHON_DOC); 62 | } 63 | 64 | #endif 65 | 66 | 67 | PyObject* EdsLib_Python_CreateModule(void) 68 | { 69 | PyObject *m = NULL; 70 | 71 | do 72 | { 73 | /* 74 | * Prepare all of the types defined here 75 | */ 76 | if (PyType_Ready(&EdsLib_Python_DatabaseType) != 0 || 77 | PyType_Ready(&EdsLib_Python_DatabaseEntryType) != 0 || 78 | PyType_Ready(&EdsLib_Python_BufferType) != 0 || 79 | PyType_Ready(&EdsLib_Python_AccessorType) != 0 || 80 | PyType_Ready(&EdsLib_Python_PackedObjectType) != 0 || 81 | PyType_Ready(&EdsLib_Python_ContainerIteratorType) != 0 || 82 | PyType_Ready(&EdsLib_Python_EnumEntryIteratorType) != 0 || 83 | PyType_Ready(&EdsLib_Python_ContainerEntryIteratorType) != 0 || 84 | PyType_Ready(&EdsLib_Python_ObjectBaseType) != 0 || 85 | PyType_Ready(&EdsLib_Python_ObjectScalarType) != 0 || 86 | PyType_Ready(&EdsLib_Python_ObjectNumberType) != 0 || 87 | PyType_Ready(&EdsLib_Python_ObjectContainerType) != 0 || 88 | PyType_Ready(&EdsLib_Python_ObjectArrayType) != 0 || 89 | PyType_Ready(&EdsLib_Python_DynamicArrayType) != 0) 90 | { 91 | break; 92 | } 93 | 94 | if (EdsLib_Python_DatabaseCache == NULL) 95 | { 96 | EdsLib_Python_DatabaseCache = PyDict_New(); 97 | if (EdsLib_Python_DatabaseCache == NULL) 98 | { 99 | break; 100 | } 101 | } 102 | 103 | m = EdsLib_Python_InstantiateModule(); 104 | if (m == NULL) 105 | { 106 | break; 107 | } 108 | 109 | /* 110 | * Add appropriate types so object instances can be constructed 111 | */ 112 | PyModule_AddObject(m, "Database", (PyObject*)&EdsLib_Python_DatabaseType); 113 | PyModule_AddObject(m, "DatabaseEntry", (PyObject*)&EdsLib_Python_DatabaseEntryType); 114 | PyModule_AddObject(m, "PackedObject", (PyObject*)&EdsLib_Python_PackedObjectType); 115 | PyModule_AddObject(m, "ElementAccessor", (PyObject*)&EdsLib_Python_AccessorType); 116 | PyModule_AddObject(m, "DynamicArray", (PyObject*)&EdsLib_Python_DynamicArrayType); 117 | } 118 | while(0); 119 | 120 | return m; 121 | } 122 | 123 | -------------------------------------------------------------------------------- /edslib/unit-test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # LEW-19710-1, CCSDS SOIS Electronic Data Sheet Implementation 3 | # 4 | # Copyright (c) 2020 United States Government as represented by 5 | # the Administrator of the National Aeronautics and Space Administration. 6 | # All Rights Reserved. 7 | # 8 | # Licensed under the Apache License, Version 2.0 (the "License"); 9 | # you may not use this file except in compliance with the License. 10 | # You may obtain a copy of the License at 11 | # 12 | # http://www.apache.org/licenses/LICENSE-2.0 13 | # 14 | # Unless required by applicable law or agreed to in writing, software 15 | # distributed under the License is distributed on an "AS IS" BASIS, 16 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | # See the License for the specific language governing permissions and 18 | # limitations under the License. 19 | # 20 | 21 | # 22 | # EDS Unit Test Build script 23 | # 24 | # For consistent unit testing we will use a custom XML data definition, NOT the one from the active mission 25 | # This gives a couple advantages - 26 | # - The custom XML files can be crafted to exercise as many features as possible, regardless of 27 | # what is actively in use in the current mission 28 | # - The edslib unit test should not break when the active mission XML is updated. 29 | if (DEFINED MISSION_BINARY_DIR) 30 | set(UTM_BINARY_DIR ${MISSION_BINARY_DIR}/edslib/unit-test) 31 | else () 32 | set(UTM_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) 33 | endif () 34 | 35 | include_directories(${EDSLIB_SOURCE_DIR}/inc) 36 | include_directories(${UTM_BINARY_DIR}/inc) 37 | 38 | # Add the components to the EDS UT top level target 39 | file(GLOB_RECURSE UTXML FOLLOW_SYMLINKS ${CMAKE_CURRENT_SOURCE_DIR}/eds/*.xml) 40 | eds_start_toplevel(UTM) 41 | foreach(XMLFILE ${UTXML}) 42 | get_filename_component(EDSFILE ${XMLFILE} NAME_WE) 43 | eds_add_component(UTM ${EDSFILE} ${EDSFILE}) 44 | endforeach() 45 | 46 | if (COMMAND eds_add_generator) 47 | eds_add_generator(UTM "UTHDR/BasePacket" "" ${UTXML}) 48 | else() 49 | include_directories(${OSAL_SOURCE_DIR}/ut_assert/inc) 50 | aux_source_directory(../fsw/src EDSLIB_SRCS) 51 | add_unit_test_lib(edslib_test ${EDSLIB_SRCS}) 52 | add_unit_test_exe(edslib_test edslib_test.c edslib_basic_test.c edslib_full_test.c) 53 | target_link_libraries(edslib_test UTM_eds) 54 | endif() 55 | 56 | 57 | -------------------------------------------------------------------------------- /edslib/unit-test/eds/UTHDR.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /edslib/unit-test/eds/ut-base-types.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /edslib/unit-test/edslib_test.c: -------------------------------------------------------------------------------- 1 | /* 2 | * LEW-19710-1, CCSDS SOIS Electronic Data Sheet Implementation 3 | * 4 | * Copyright (c) 2020 United States Government as represented by 5 | * the Administrator of the National Aeronautics and Space Administration. 6 | * All Rights Reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | 21 | 22 | /** 23 | * \file edslib_test.c 24 | * \ingroup edslib 25 | * \author joseph.p.hickey@nasa.gov 26 | * 27 | * Unit test entry point 28 | */ 29 | 30 | #include "utassert.h" 31 | #include "uttest.h" 32 | 33 | extern void EdsLib_Basic_Test(void); 34 | extern void EdsLib_Full_Test(void); 35 | extern void EdsLib_StringConv_Test(void); 36 | 37 | void UtTest_Setup(void) 38 | { 39 | UtTest_Add(EdsLib_Basic_Test, NULL, NULL, "EDS Basic"); 40 | UtTest_Add(EdsLib_Full_Test, NULL, NULL, "EDS Full"); 41 | UtTest_Add(EdsLib_StringConv_Test, NULL, NULL, "EDS String Conversions"); 42 | } 43 | 44 | -------------------------------------------------------------------------------- /tool/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # LEW-19710-1, CCSDS SOIS Electronic Data Sheet Implementation 3 | # 4 | # Copyright (c) 2020 United States Government as represented by 5 | # the Administrator of the National Aeronautics and Space Administration. 6 | # All Rights Reserved. 7 | # 8 | # Licensed under the Apache License, Version 2.0 (the "License"); 9 | # you may not use this file except in compliance with the License. 10 | # You may obtain a copy of the License at 11 | # 12 | # http://www.apache.org/licenses/LICENSE-2.0 13 | # 14 | # Unless required by applicable law or agreed to in writing, software 15 | # distributed under the License is distributed on an "AS IS" BASIS, 16 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | # See the License for the specific language governing permissions and 18 | # limitations under the License. 19 | # 20 | 21 | # 22 | # CFE/CFS build utility tools makefile 23 | # This will build cFE/CFS EDS generator tools. 24 | # 25 | # These tools require the "expat" library, so the "-dev" or "-devel" 26 | # package for the host machine should be installed. 27 | # 28 | # Note this is built natively on the build machine for use during compilation - 29 | # none of this code is loaded directly onto the target. The output of these 30 | # tools are linked into the final executables, but there is no dependency 31 | # on expat in the final binaries. 32 | # 33 | cmake_minimum_required(VERSION 3.5) 34 | project(EDSTOOL C) 35 | 36 | add_definitions(-Wall -Werror -std=c99 -pedantic) 37 | 38 | # expat is required for the EDS XML conversion tools 39 | # note this is just for the build step - no XML is used on the target (at least for EDS) 40 | find_library(EXPAT_LIB expat) 41 | if (NOT EXPAT_LIB) 42 | message(FATAL_ERROR "The Expat library is required for the build - install the expat development packages") 43 | endif () 44 | 45 | if (NOT TARGET edslib_runtime_static) 46 | add_subdirectory("../edslib" edslib) 47 | endif() 48 | 49 | if (NOT TARGET edslib_lua) 50 | message(FATAL_ERROR "Lua bindings are required to execute the EDS tool - install the Lua development packages") 51 | endif() 52 | 53 | 54 | include_directories(inc) 55 | include_directories(${LUALIB_INCLUDE_DIRS}) 56 | include_directories(${EDSLIB_FSW_SOURCE_DIR}/inc) 57 | include_directories(${EDSLIB_LUABINDINGS_SOURCE_DIR}/inc) 58 | 59 | add_executable(sedstool 60 | src/seds_xmlparser.c 61 | src/seds_preprocess.c 62 | src/seds_generic_props.c 63 | src/seds_checksum.c 64 | src/seds_tree_node.c 65 | src/seds_instance_node.c 66 | src/seds_memreq.c 67 | src/seds_outputfile.c 68 | src/seds_plugin.c 69 | src/seds_user_message.c 70 | src/seds_tool_main.c) 71 | 72 | file(GLOB LUA_CODE src/*.lua) 73 | set_source_files_properties(src/seds_tool_main.c PROPERTIES OBJECT_DEPENDS ${LUA_CODE}) 74 | 75 | # Note -- the contents of edslib_lua_static need to be linked into this EXE 76 | # The base tool does not use it, but future loadable modules may need it 77 | # the --whole-archive linker flag is for this purpose however this is GNU-specific syntax 78 | set_target_properties(sedstool PROPERTIES ENABLE_EXPORTS TRUE) 79 | target_link_libraries(sedstool 80 | edslib_lua 81 | edslib_runtime_static 82 | ${EXPAT_LIB} 83 | dl 84 | ) 85 | -------------------------------------------------------------------------------- /tool/edsbuild.dox: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | \defgroup build EDS build tools 4 | 5 | Compile-time tools for generating intermediate build products 6 | 7 | \section overview Overview 8 | 9 | \image html prebuild.png "Overview of EDS build tools" 10 | 11 | Using EDS requires establishing a three-part build procedure: 12 | - First, the EDS build tools (this source tree) must be compiled using the _native_ compiler for the development machine 13 | - Next, The EDS build tools are then _executed_ on the development machine to produce the intermediate build products 14 | - Finally, the intermediate products are compiled and linked into the _target_ binaries. 15 | 16 | 17 | \section usage Usage 18 | 19 | __Important__: All files in the `src` subdirectory should be compiled using the native host compiler, _not_ a cross-compiler. 20 | 21 | Files with a `seds_` prefix are part of the main EDS processor utility as depicted here. See the documentation for `seds_gencdecl.c` for 22 | command line options and other usage instructions. 23 | 24 | The `updatefiles.c` source file provides a helper utility to aid in incremental build procedures. See the documentation for 25 | that utility. 26 | 27 | \section operation Operation 28 | 29 | The EDS processor toolchain follows this general operational flow: 30 | 31 | 1. Read entire set of all EDS XML files into tree structure in memory. 32 | 33 | 2. After all EDS files are read, resolve all cross-references / undefined symbols between EDS files and project configuration. 34 | - All Value Constraints and symbols are resolved to absolute/concrete numbers 35 | - All structures are mapped to their final concrete definitions 36 | - The size of all types are calculated 37 | - Must be no conflicts or unresolved values after this stage. Toolchain will indicate errors if this is not the case (must be fixed). 38 | 39 | 3. Output Temporary C Header files (`*_msgdefs.h` and `*_dictionary.h`) 40 | 41 | 4. Output Temporary C Runtime Database files (`*-impl.c`) 42 | 43 | 5. Update "Final" C files from temporary files, if different (via the `updatefiles.c` tool) 44 | 45 | 46 | 47 | \dir build 48 | \ingroup build 49 | 50 | 51 | */ 52 | 53 | -------------------------------------------------------------------------------- /tool/src/seds_checksum.h: -------------------------------------------------------------------------------- 1 | /* 2 | * LEW-19710-1, CCSDS SOIS Electronic Data Sheet Implementation 3 | * 4 | * Copyright (c) 2020 United States Government as represented by 5 | * the Administrator of the National Aeronautics and Space Administration. 6 | * All Rights Reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | 21 | 22 | /** 23 | * \file seds_checksum.h 24 | * \ingroup tool 25 | * \author joseph.p.hickey@nasa.gov 26 | * 27 | * Public interface to the SEDS checksum algorithm, used throughout the 28 | * toolchain operation 29 | * 30 | * See full module description in seds_checksum.c 31 | */ 32 | 33 | #ifndef _SEDS_CHECKSUM_H_ 34 | #define _SEDS_CHECKSUM_H_ 35 | 36 | 37 | #include "seds_global.h" 38 | 39 | 40 | /*******************************************************************************/ 41 | /* Macro definitions */ 42 | /*******************************************************************************/ 43 | 44 | /** 45 | * Initial value to use for checksum calculations 46 | */ 47 | #define SEDS_CHECKSUM_INITIAL 0x49A42201BE3217D6U 48 | 49 | 50 | /*******************************************************************************/ 51 | /* Function documentation and prototypes */ 52 | /* (everything referenced outside this unit should be described here) */ 53 | /*******************************************************************************/ 54 | 55 | /** 56 | * Initialization of the checksum table 57 | * 58 | * Must be called early in the startup procedure, 59 | * before any other functions are used. 60 | */ 61 | void seds_checksum_init_table(void); 62 | 63 | /** 64 | * Update a checksum based on an unsigned integer value 65 | * 66 | * The checksum is updated based on the supplied integer. 67 | * 68 | * IMPORTANT: all checksum updates are done by value, not by binary representation of the 69 | * dat. It should produce the same value on big endian and little endian machines, regardless 70 | * of how binary integers are represented in memory. 71 | * 72 | * @param sum previous checksum value 73 | * @param localvalue the integer value to incorporate into the checksum 74 | * @param significant_bits the number of bits in localvalue to consider 75 | * @return updated checksum 76 | */ 77 | seds_checksum_t seds_update_checksum_numeric(seds_checksum_t sum, uintmax_t localvalue, seds_integer_t significant_bits); 78 | 79 | /** 80 | * Update a checksum based on a string value 81 | * 82 | * The checksum is updated based on the supplied string, which must be terminated by 83 | * a null character. 84 | * 85 | * @note this currently does not take character encoding into account, and in general 86 | * will probably only produce consistent results if the string is limited to 7-bit ASCII. 87 | * Any string containing extended character sequences may generate different checksums 88 | * on different machines. This could be a candidate for future enhancement, but currently 89 | * there is not much driving need to support special characters into EDS object names. 90 | * 91 | * @param sum previous checksum value 92 | * @param cstr the string value to incorporate into the checksum 93 | * @return updated checksum 94 | */ 95 | seds_checksum_t seds_update_checksum_string(seds_checksum_t sum, const char *cstr); 96 | 97 | /** 98 | * Update a checksum based on an integer value 99 | * 100 | * The checksum is updated based on the supplied integer. This is a simplified interface 101 | * that accepts a seds_integer_t type, as opposed to seds_update_checksum_numeric(). 102 | * 103 | * @param sum previous checksum value 104 | * @param value the integer value to incorporate into the checksum 105 | * @return updated checksum 106 | */ 107 | seds_checksum_t seds_update_checksum_int(seds_checksum_t sum, seds_integer_t value); 108 | 109 | 110 | #endif /* _SEDS_CHECKSUM_H_ */ 111 | 112 | -------------------------------------------------------------------------------- /tool/src/seds_generic_props.h: -------------------------------------------------------------------------------- 1 | /* 2 | * LEW-19710-1, CCSDS SOIS Electronic Data Sheet Implementation 3 | * 4 | * Copyright (c) 2020 United States Government as represented by 5 | * the Administrator of the National Aeronautics and Space Administration. 6 | * All Rights Reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | 21 | 22 | /** 23 | * \file seds_generic_props.h 24 | * \ingroup tool 25 | * \author joseph.p.hickey@nasa.gov 26 | * 27 | * Header file for the properties module. 28 | * See full module description on seds_generic_props.c 29 | */ 30 | 31 | #ifndef _SEDS_GENERIC_PROPS_H_ 32 | #define _SEDS_GENERIC_PROPS_H_ 33 | 34 | 35 | #include "seds_global.h" 36 | 37 | /*******************************************************************************/ 38 | /* Function documentation and prototypes */ 39 | /* (everything referenced outside this unit should be described here) */ 40 | /*******************************************************************************/ 41 | 42 | 43 | /** 44 | * Lua callable function to get a property of a userdata object 45 | * 46 | * SEDS DOM nodes may contain any number of arbitrary properties. These 47 | * are typically set by various plug-in scripts as the tool executes, and 48 | * they follow the Lua table paradigm being key/value pairs. 49 | * 50 | * This function provides the basic facility to read a key and get the value. 51 | * 52 | * Expected Lua input stack: 53 | * 1: userdata object 54 | * 2: property key 55 | * 56 | * returns value associated with the key (which may in be a Lua table containing 57 | * more key/value pairs). 58 | * 59 | * @sa seds_set_userdata_property 60 | */ 61 | int seds_generic_props_get_property(lua_State *lua); 62 | 63 | /** 64 | * Lua callable function to set a property of a userdata object 65 | * 66 | * SEDS DOM nodes may contain any number of arbitrary properties. These 67 | * are typically set by various plug-in scripts as the tool executes, and 68 | * they follow the Lua table paradigm being key/value pairs. 69 | * 70 | * This function provides the basic facility to write a key and set the value. 71 | * 72 | * Expected Lua input stack: 73 | * 1: userdata object 74 | * 2: property key 75 | * 3: property value 76 | * 77 | * @sa seds_get_userdata_property 78 | */ 79 | int seds_generic_props_set_property(lua_State *lua); 80 | 81 | /** 82 | * Debugging helper function to enumerate the added keys in a DOM node 83 | * 84 | * Lua callable function, returns an array containing the keys 85 | * in the "uservalue" table of the userdata object 86 | */ 87 | int seds_generic_props_enumerate_properties(lua_State *lua); 88 | 89 | 90 | /** 91 | * Register any globals associated with this module in the Lua state 92 | */ 93 | void seds_generic_props_register_globals(lua_State *lua); 94 | 95 | 96 | #endif /* _SEDS_GENERIC_PROPS_H_ */ 97 | 98 | -------------------------------------------------------------------------------- /tool/src/seds_instance_methods.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- LEW-19710-1, CCSDS SOIS Electronic Data Sheet Implementation 3 | -- 4 | -- Copyright (c) 2020 United States Government as represented by 5 | -- the Administrator of the National Aeronautics and Space Administration. 6 | -- All Rights Reserved. 7 | -- 8 | -- Licensed under the Apache License, Version 2.0 (the "License"); 9 | -- you may not use this file except in compliance with the License. 10 | -- You may obtain a copy of the License at 11 | -- 12 | -- http://www.apache.org/licenses/LICENSE-2.0 13 | -- 14 | -- Unless required by applicable law or agreed to in writing, software 15 | -- distributed under the License is distributed on an "AS IS" BASIS, 16 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | -- See the License for the specific language governing permissions and 18 | -- limitations under the License. 19 | -- 20 | 21 | 22 | -- ------------------------------------------------------------------------- 23 | -- Lua Method implementation for "instance" objects 24 | -- 25 | -- This returns a table object which contains a static set of methods that 26 | -- operate on instance objects (i.e. "seds_instance" userdata. 27 | -- ------------------------------------------------------------------------- 28 | 29 | SEDS.info "loading SEDS component instance methods" 30 | 31 | -- ----------------------------------------------------------------------- 32 | --- 33 | -- get_qualified_name: obtains the fully-qualified name of an instance object 34 | -- 35 | -- The fully qualified name is the name of the component (the instance type) 36 | -- combined with the node that demanded it, for on demand entities. 37 | -- 38 | local function get_qualified_name(node) 39 | local name 40 | if (node.trigger) then 41 | name = node.trigger:get_qualified_name() 42 | end 43 | if (name) then 44 | name = name .. "/" .. node.component.name 45 | else 46 | name = node.component:get_qualified_name() 47 | end 48 | return name 49 | end 50 | 51 | -- ----------------------------------------------------------------------- 52 | --- 53 | -- find_param_of_type: drill down the bindings to locate a specific type of intf param 54 | -- 55 | -- Searches the interface chain (provided/required pairings) to locate a 56 | -- specific type name 57 | -- 58 | local function find_param_of_type(instance,typename) 59 | local result 60 | for i,binding in ipairs(instance.required_links) do 61 | if (binding.reqintf.type:get_qualified_name() == typename) then 62 | result = binding.reqinst.params 63 | elseif (binding.provinst) then 64 | result = find_param_of_type(binding.provinst,typename) 65 | end 66 | 67 | if (result) then 68 | break 69 | end 70 | end 71 | 72 | return result 73 | end 74 | 75 | -- ----------------------------------------------------------------------- 76 | --- 77 | -- debug_print: obtains the fully-qualified name of an instance object 78 | -- 79 | -- Print the node properties on the console for debugging purposes 80 | -- 81 | local function debug_print(node) 82 | 83 | print ("-- BEGIN INSTANCE PROPERTIES --") 84 | for i,v in ipairs(node:get_properties()) do 85 | local propval = node[v] 86 | print (" [" .. tostring(v) .. "] =>" .. type(propval) .. ":" .. tostring(propval)) 87 | if (type(propval) == "table") then 88 | SEDS.debug_print_table(" ", propval) 89 | end 90 | end 91 | print ("-- END INSTANCE PROPERTIES --") 92 | end 93 | 94 | -- Return a table of methods for instance objects 95 | return { 96 | get_qualified_name = get_qualified_name, 97 | find_param_of_type = find_param_of_type, 98 | debug_print = debug_print 99 | } 100 | -------------------------------------------------------------------------------- /tool/src/seds_instance_node.h: -------------------------------------------------------------------------------- 1 | /* 2 | * LEW-19710-1, CCSDS SOIS Electronic Data Sheet Implementation 3 | * 4 | * Copyright (c) 2020 United States Government as represented by 5 | * the Administrator of the National Aeronautics and Space Administration. 6 | * All Rights Reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | 21 | 22 | /** 23 | * \file seds_instance_node.h 24 | * \ingroup tool 25 | * \author joseph.p.hickey@nasa.gov 26 | * 27 | * Implements methods for "instance nodes" within the seds DOM 28 | * See full description in seds_instance_node.c 29 | */ 30 | 31 | #ifndef _SEDS_INSTANCE_NODE_H_ 32 | #define _SEDS_INSTANCE_NODE_H_ 33 | 34 | #include "seds_global.h" 35 | 36 | /*******************************************************************************/ 37 | /* Function documentation and prototypes */ 38 | /* (everything referenced outside this unit should be described here) */ 39 | /*******************************************************************************/ 40 | 41 | 42 | /** 43 | * Register the tree functions which are called from Lua 44 | * These are added to a table which is at the top of the stack 45 | */ 46 | void seds_instance_node_register_globals(lua_State *lua); 47 | 48 | 49 | #endif /* _SEDS_INSTANCE_NODE_H_ */ 50 | 51 | -------------------------------------------------------------------------------- /tool/src/seds_memreq.h: -------------------------------------------------------------------------------- 1 | /* 2 | * LEW-19710-1, CCSDS SOIS Electronic Data Sheet Implementation 3 | * 4 | * Copyright (c) 2020 United States Government as represented by 5 | * the Administrator of the National Aeronautics and Space Administration. 6 | * All Rights Reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | 21 | 22 | /** 23 | * \file seds_memreq.h 24 | * \ingroup tool 25 | * \author joseph.p.hickey@nasa.gov 26 | * 27 | * Memory requirement calculator module declarations. 28 | * For full module description, see seds_memreq.c 29 | */ 30 | 31 | #ifndef _SEDS_MEMREQ_H_ 32 | #define _SEDS_MEMREQ_H_ 33 | 34 | 35 | #include "seds_global.h" 36 | #include "seds_checksum.h" 37 | 38 | typedef enum 39 | { 40 | /** 41 | * Set when no packing has been identified yet 42 | */ 43 | SEDS_BYTEPACK_STATUS_UNDEFINED, 44 | 45 | /** 46 | * Set when packing adheres to "bigendian" style: 47 | * - Big Endian byte order 48 | * - IEEE754 floating point encoding 49 | * - Twos complement signed integer encoding 50 | * 51 | * Processors such as POWERPC and SPARC often use this 52 | * style natively in memory during runtime. 53 | */ 54 | SEDS_BYTEPACK_STATUS_BIGENDIAN_STYLE, 55 | 56 | /** 57 | * Set when packing adheres to "littlendian" style: 58 | * - Little Endian byte order 59 | * - IEEE754 floating point encoding 60 | * - Twos complement signed integer encoding 61 | * 62 | * Processors such as x86 and ARM often use this 63 | * style natively in memory during runtime. 64 | */ 65 | SEDS_BYTEPACK_STATUS_LITTLEENDIAN_STYLE, 66 | 67 | /** 68 | * Set when packing adheres to none of the defined styles. 69 | * - Mixed endianness in a container 70 | * - Signed Integer encoding other than twos complement 71 | * - Floating Point encoding other than IEEE 754 72 | * - Includes embedded padding or special fields 73 | */ 74 | SEDS_BYTEPACK_STATUS_OTHER 75 | } seds_bytepack_status_t; 76 | 77 | 78 | /** 79 | * Structure that tracks the size of EDS-defined objects 80 | * 81 | * Instances of these objects (in the form of Lua userdata objects) may be 82 | * attached to any EDS DOM node which has a size associated with it (e.g. data types). 83 | */ 84 | typedef struct 85 | { 86 | seds_integer_t raw_bit_size; /**< Total bits consumed by the object */ 87 | seds_integer_t endpoint_bytes; /**< Byte offset of the end of the object */ 88 | seds_integer_t local_storage_bytes; /**< Total byte storage required (may include padding) */ 89 | seds_integer_t local_align_mask; /**< Expected alignment requirements based on typical alignment rules */ 90 | seds_bytepack_status_t packing_status; /**< If the structure is packed efficiently, this allows for some added optimizations */ 91 | seds_checksum_t checksum; /**< Checksum/Hash value for the data type definition */ 92 | } seds_memreq_t; 93 | 94 | 95 | /*******************************************************************************/ 96 | /* Function documentation and prototypes */ 97 | /* (everything referenced outside this unit should be described here) */ 98 | /*******************************************************************************/ 99 | 100 | /** 101 | * Registers the memreq functions into the SEDS library object 102 | * These are added to a table which is at the top of the stack 103 | */ 104 | void seds_memreq_register_globals(lua_State *lua); 105 | 106 | 107 | #endif /* _SEDS_MEMREQ_H_ */ 108 | 109 | -------------------------------------------------------------------------------- /tool/src/seds_outputfile.h: -------------------------------------------------------------------------------- 1 | /* 2 | * LEW-19710-1, CCSDS SOIS Electronic Data Sheet Implementation 3 | * 4 | * Copyright (c) 2020 United States Government as represented by 5 | * the Administrator of the National Aeronautics and Space Administration. 6 | * All Rights Reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | 21 | 22 | /** 23 | * \file seds_outputfile.h 24 | * \ingroup tool 25 | * \author joseph.p.hickey@nasa.gov 26 | * 27 | * Contains prototypes for C functions related to the "output file" component. 28 | * For full module description, see seds_outputfile.c 29 | */ 30 | 31 | #ifndef _SEDS_OUTPUTFILE_H_ 32 | #define _SEDS_OUTPUTFILE_H_ 33 | 34 | #include "seds_global.h" 35 | 36 | /*******************************************************************************/ 37 | /* Function documentation and prototypes */ 38 | /* (everything referenced outside this unit should be described here) */ 39 | /*******************************************************************************/ 40 | 41 | /** 42 | * Register the output file library with the Lua engine. 43 | * 44 | * All output files are intended to be generated from Lua scripts. There 45 | * are no directly C-callable routines for this module, except to register 46 | * the Lua functions in the Lua state object. 47 | */ 48 | void seds_outputfile_register_globals(lua_State *lua); 49 | 50 | #endif /* _SEDS_OUTPUTFILE_H_ */ 51 | 52 | -------------------------------------------------------------------------------- /tool/src/seds_plugin.h: -------------------------------------------------------------------------------- 1 | /* 2 | * LEW-19710-1, CCSDS SOIS Electronic Data Sheet Implementation 3 | * 4 | * Copyright (c) 2020 United States Government as represented by 5 | * the Administrator of the National Aeronautics and Space Administration. 6 | * All Rights Reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | 21 | 22 | /** 23 | * \file seds_plugin.h 24 | * \ingroup tool 25 | * \author joseph.p.hickey@nasa.gov 26 | * 27 | * Plug-in loader module declarations. 28 | * For full module description, see seds_plugin.c 29 | */ 30 | 31 | #ifndef _SEDS_PLUGIN_H_ 32 | #define _SEDS_PLUGIN_H_ 33 | 34 | #include "seds_global.h" 35 | 36 | 37 | /*******************************************************************************/ 38 | /* Function documentation and prototypes */ 39 | /* (everything referenced outside this unit should be described here) */ 40 | /*******************************************************************************/ 41 | 42 | 43 | /** 44 | * Load a Lua runtime script plugin from the C source directory. 45 | * 46 | * A wrapper around the underlying luaL_loadfile() implementation that uses 47 | * the path of the C source code as the source for the specified Lua file. 48 | * 49 | * A considerable amount of tool functionality is actually implemented in 50 | * Lua. Only the base engine is implemented in C. The Lua source files for the 51 | * main tool operation are loaded at runtime via this function. 52 | * 53 | * @note The binary executable and all Lua source files must be moved together; the 54 | * tool will not execute if the corresponding Lua source is not present. 55 | * 56 | * If the source files are moved from their original location at the time of compilation, 57 | * the "-s" command option may be used to indicate the correct Lua source location. 58 | * 59 | * @param lua Lua state object 60 | * @param runtime_file file to load from C source directory 61 | */ 62 | void seds_plugin_load_lua(lua_State *lua, const char *runtime_file); 63 | 64 | /** 65 | * Load a dynamic shared object (.so) plugin from the binary build directory. 66 | * 67 | * A wrapper around the underlying luaL_loadfile() implementation that uses 68 | * the path of the C source code as the source for the specified Lua file. 69 | * 70 | * @param lua Lua state object 71 | * @param runtime_file file to load from C source directory 72 | */ 73 | void seds_plugin_load_so(lua_State *lua, const char *filename); 74 | 75 | /** 76 | * Register functions related to Plugin loading with the Lua interpreter 77 | */ 78 | void seds_plugin_register_globals(lua_State *lua); 79 | 80 | 81 | 82 | #endif /* _SEDS_PLUGIN_H_ */ 83 | 84 | -------------------------------------------------------------------------------- /tool/src/seds_preprocess.h: -------------------------------------------------------------------------------- 1 | /* 2 | * LEW-19710-1, CCSDS SOIS Electronic Data Sheet Implementation 3 | * 4 | * Copyright (c) 2020 United States Government as represented by 5 | * the Administrator of the National Aeronautics and Space Administration. 6 | * All Rights Reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | 21 | 22 | /** 23 | * \file seds_preprocess.h 24 | * \ingroup tool 25 | * \author joseph.p.hickey@nasa.gov 26 | * 27 | * Preprocessor module prototypes. 28 | * For full module description, see seds_preprocess.c 29 | */ 30 | 31 | #ifndef _SEDS_PREPROCESS_H_ 32 | #define _SEDS_PREPROCESS_H_ 33 | 34 | 35 | /** 36 | * Register the preprocessor functions in the global Lua state 37 | */ 38 | void seds_preprocess_register_globals(lua_State *lua); 39 | 40 | 41 | #endif /* _SEDS_PREPROCESS_H_ */ 42 | 43 | -------------------------------------------------------------------------------- /tool/src/seds_xmlparser.h: -------------------------------------------------------------------------------- 1 | /* 2 | * LEW-19710-1, CCSDS SOIS Electronic Data Sheet Implementation 3 | * 4 | * Copyright (c) 2020 United States Government as represented by 5 | * the Administrator of the National Aeronautics and Space Administration. 6 | * All Rights Reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | 21 | 22 | /** 23 | * \file seds_xmlparser.h 24 | * \ingroup tool 25 | * \author joseph.p.hickey@nasa.gov 26 | * 27 | * Public interface to the XML parser routines 28 | * For full module description see the implementation file: seds_xmlparser.c 29 | */ 30 | 31 | #ifndef _SEDS_XMLPARSER_H_ 32 | #define _SEDS_XMLPARSER_H_ 33 | 34 | #include "seds_global.h" 35 | 36 | /** 37 | * Lua-callable function to instantiate an XML parser object 38 | * and start building a document object model (DOM) tree 39 | */ 40 | int seds_xmlparser_create(lua_State *lua); 41 | 42 | /** 43 | * Lua-callable function to read an XML file, adding it to 44 | * the DOM tree. 45 | */ 46 | int seds_xmlparser_readfile(lua_State *lua); 47 | 48 | /** 49 | * Lua-callable function to finalize the DOM tree and return 50 | * it to the caller. 51 | */ 52 | int seds_xmlparser_finish(lua_State *lua); 53 | 54 | 55 | #endif /* _SEDS_XMLPARSER_H_ */ 56 | 57 | --------------------------------------------------------------------------------