├── CONTRIBUTING.md ├── .github ├── workflows │ ├── format-check.yml │ ├── static-analysis.yml │ └── codeql-build.yml ├── ISSUE_TEMPLATE │ ├── feature_request.md │ └── bug_report.md └── pull_request_template.md ├── config ├── default_to_lab_perfids.h ├── default_to_lab_tbl.h ├── default_to_lab_topicids.h ├── default_to_lab_mission_cfg.h ├── default_to_lab_msgids.h ├── default_to_lab_msg.h ├── default_to_lab_platform_cfg.h ├── default_to_lab_tbldefs.h ├── default_to_lab_interface_cfg.h ├── default_to_lab_fcncodes.h ├── default_to_lab_tblstruct.h ├── default_to_lab_msgdefs.h ├── default_to_lab_internal_cfg.h └── default_to_lab_msgstruct.h ├── arch_build.cmake ├── CMakeLists.txt ├── fsw ├── src │ ├── to_lab_dispatch.h │ ├── to_lab_encode.h │ ├── to_lab_cmds.h │ ├── to_lab_passthru_encode.c │ ├── to_lab_app.h │ ├── to_lab_version.h │ ├── to_lab_eds_encode.c │ ├── to_lab_dispatch.c │ ├── to_lab_eds_dispatch.c │ ├── to_lab_cmds.c │ └── to_lab_app.c ├── inc │ └── to_lab_eventids.h └── tables │ └── to_lab_sub.c ├── README.md ├── mission_build.cmake ├── SECURITY.md ├── CHANGELOG.md ├── eds └── to_lab.xml └── LICENSE /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing Guide 2 | 3 | Please see our [top-level contributing guide](https://github.com/nasa/cFS/blob/main/CONTRIBUTING.md) for more information on how to contribute. -------------------------------------------------------------------------------- /.github/workflows/format-check.yml: -------------------------------------------------------------------------------- 1 | name: Format Check 2 | 3 | # Run on main push and pull requests 4 | on: 5 | push: 6 | pull_request: 7 | 8 | jobs: 9 | 10 | format-check: 11 | name: Run format check 12 | uses: nasa/cFS/.github/workflows/format-check.yml@main 13 | -------------------------------------------------------------------------------- /.github/workflows/static-analysis.yml: -------------------------------------------------------------------------------- 1 | name: Static Analysis 2 | 3 | # Run on main push and pull requests 4 | on: 5 | push: 6 | pull_request: 7 | 8 | jobs: 9 | 10 | static-analysis: 11 | name: Run cppcheck 12 | uses: nasa/cFS/.github/workflows/static-analysis.yml@main 13 | -------------------------------------------------------------------------------- /.github/workflows/codeql-build.yml: -------------------------------------------------------------------------------- 1 | name: "CodeQL Analysis" 2 | 3 | on: 4 | push: 5 | pull_request: 6 | 7 | jobs: 8 | codeql: 9 | name: Codeql 10 | uses: nasa/cFS/.github/workflows/codeql-reusable.yml@main 11 | with: 12 | component-path: apps/to_lab 13 | prep: 'make prep; make -C build/tools/elf2cfetbl' 14 | make: 'make -C build/native/default_cpu1/apps/to_lab' 15 | -------------------------------------------------------------------------------- /.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/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 | -------------------------------------------------------------------------------- /config/default_to_lab_perfids.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 | * Define TO Lab Performance IDs 22 | */ 23 | #ifndef TO_LAB_PERFIDS_H 24 | #define TO_LAB_PERFIDS_H 25 | 26 | #define TO_LAB_MAIN_TASK_PERF_ID 34 27 | #define TO_LAB_SOCKET_SEND_PERF_ID 35 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /arch_build.cmake: -------------------------------------------------------------------------------- 1 | ########################################################### 2 | # 3 | # TO_LAB 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 | # The list of header files that control the TO_LAB configuration 12 | set(TO_LAB_PLATFORM_CONFIG_FILE_LIST 13 | to_lab_internal_cfg.h 14 | to_lab_platform_cfg.h 15 | to_lab_perfids.h 16 | to_lab_msgids.h 17 | ) 18 | 19 | # Create wrappers around the all the config header files 20 | # This makes them individually overridable by the missions, without modifying 21 | # the distribution default copies 22 | foreach(TO_LAB_CFGFILE ${TO_LAB_PLATFORM_CONFIG_FILE_LIST}) 23 | get_filename_component(CFGKEY "${TO_LAB_CFGFILE}" NAME_WE) 24 | if (DEFINED TO_LAB_CFGFILE_SRC_${CFGKEY}) 25 | set(DEFAULT_SOURCE GENERATED_FILE "${TO_LAB_CFGFILE_SRC_${CFGKEY}}") 26 | else() 27 | set(DEFAULT_SOURCE FALLBACK_FILE "${CMAKE_CURRENT_LIST_DIR}/config/default_${TO_LAB_CFGFILE}") 28 | endif() 29 | generate_config_includefile( 30 | FILE_NAME "${TO_LAB_CFGFILE}" 31 | ${DEFAULT_SOURCE} 32 | ) 33 | endforeach() 34 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | project(CFS_TO_LAB C) 3 | 4 | set(TO_TABLE_COMPILE_DEFS) 5 | 6 | # These references are specifically needed for the table build 7 | # it is easiest to add them as directory properties so they won't 8 | # be considered include directories for TO_LAB itself. Each one 9 | # gets a macro for conditional inclusion in the subscription table. 10 | foreach(EXT_APP ci_lab sample_app hs fm ds sc lc) 11 | list (FIND TGTSYS_${SYSVAR}_APPS ${EXT_APP} HAVE_APP) 12 | if (HAVE_APP GREATER_EQUAL 0) 13 | include_directories($) 14 | string(TOUPPER "HAVE_${EXT_APP}" APP_MACRO) 15 | add_definitions(-D${APP_MACRO}) 16 | endif() 17 | endforeach() 18 | 19 | set(APP_SRC_FILES 20 | fsw/src/to_lab_app.c 21 | fsw/src/to_lab_cmds.c 22 | ) 23 | 24 | if (CFE_EDS_ENABLED_BUILD) 25 | list(APPEND APP_SRC_FILES 26 | fsw/src/to_lab_eds_dispatch.c 27 | fsw/src/to_lab_eds_encode.c 28 | ) 29 | else() 30 | list(APPEND APP_SRC_FILES 31 | fsw/src/to_lab_dispatch.c 32 | fsw/src/to_lab_passthru_encode.c 33 | ) 34 | endif() 35 | 36 | # Create the app module 37 | add_cfe_app(to_lab ${APP_SRC_FILES}) 38 | add_cfe_tables(to_lab fsw/tables/to_lab_sub.c) 39 | 40 | target_include_directories(to_lab PUBLIC fsw/inc) 41 | -------------------------------------------------------------------------------- /config/default_to_lab_tbl.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 TO_LAB table structures 22 | * 23 | * @note 24 | * Constants and enumerated types related to these table structures 25 | * are defined in to_lab_tbldefs.h. 26 | */ 27 | #ifndef TO_LAB_TBL_H 28 | #define TO_LAB_TBL_H 29 | 30 | #include "to_lab_tbldefs.h" 31 | #include "to_lab_tblstruct.h" 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /config/default_to_lab_topicids.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 | * TO_LAB Application Topic IDs 22 | */ 23 | #ifndef TO_LAB_TOPICIDS_H 24 | #define TO_LAB_TOPICIDS_H 25 | 26 | #define CFE_MISSION_TO_LAB_CMD_TOPICID 0x80 27 | #define CFE_MISSION_TO_LAB_SEND_HK_TOPICID 0x81 28 | #define CFE_MISSION_TO_LAB_HK_TLM_TOPICID 0x80 29 | #define CFE_MISSION_TO_LAB_DATA_TYPES_TOPICID 0x81 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /fsw/src/to_lab_dispatch.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 | * Define TO Lab Application header file 22 | */ 23 | 24 | #ifndef TO_LAB_DISPATCH_H 25 | #define TO_LAB_DISPATCH_H 26 | 27 | #include "common_types.h" 28 | 29 | /******************************************************************************/ 30 | 31 | /* 32 | ** Prototypes Section 33 | */ 34 | void TO_LAB_TaskPipe(const CFE_SB_Buffer_t *SBBufPtr); 35 | 36 | /******************************************************************************/ 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![Static Analysis](https://github.com/nasa/to_lab/workflows/Static%20Analysis/badge.svg) 2 | ![Format Check](https://github.com/nasa/to_lab/workflows/Format%20Check/badge.svg) 3 | 4 | # Core Flight System : Framework : App : Telemetry Output Lab 5 | 6 | This repository contains NASA's Telemetry Output Lab (to_lab), which is a framework component of the Core Flight System. 7 | 8 | This lab application is a non-flight utility to downlink telemetry from the cFS Bundle. It is intended to be located in the `apps/to_lab` subdirectory of a cFS Mission Tree. The Core Flight System is bundled at (which includes to_lab as a submodule), which includes build and execution instructions. 9 | 10 | to_lab is a simple telemetry downlink application that sends CCSDS telecommand packets over a UDP/IP port. The UDP port and IP address are specified in the "Enable Telemetry" command. It does not provide a full CCSDS Telecommand stack implementation. 11 | 12 | To send telemetry to the "ground" or UDP/IP port, edit the subscription table in the platform include file: fsw/platform_inc/to_lab_sub_table.h. to_lab will subscribe to the packet IDs that are listed in this table and send the telemetry packets it receives to the UDP/IP port. 13 | 14 | ## Known issues 15 | 16 | As a lab application, extensive testing is not performed prior to release and only minimal functionality is included. 17 | 18 | ## Getting Help 19 | 20 | For best results, submit issues:questions or issues:help wanted requests at . 21 | 22 | Official cFS page: 23 | -------------------------------------------------------------------------------- /config/default_to_lab_mission_cfg.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 | * 22 | * TO_LAB Application Mission Configuration Header File 23 | * 24 | * This is a compatibility header for the "mission_cfg.h" file that has 25 | * traditionally provided public config definitions for each CFS app. 26 | * 27 | * @note This file may be overridden/superceded by mission-provided defintions 28 | * either by overriding this header or by generating definitions from a command/data 29 | * dictionary tool. 30 | */ 31 | #ifndef TO_LAB_MISSION_CFG_H 32 | #define TO_LAB_MISSION_CFG_H 33 | 34 | #include "to_lab_interface_cfg.h" 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /config/default_to_lab_msgids.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 | * TO_LAB Application Message IDs 22 | */ 23 | #ifndef TO_LAB_MSGIDS_H 24 | #define TO_LAB_MSGIDS_H 25 | 26 | #include "cfe_core_api_base_msgids.h" 27 | #include "to_lab_topicids.h" 28 | 29 | #define TO_LAB_CMD_MID CFE_PLATFORM_CMD_TOPICID_TO_MIDV(CFE_MISSION_TO_LAB_CMD_TOPICID) 30 | #define TO_LAB_SEND_HK_MID CFE_PLATFORM_CMD_TOPICID_TO_MIDV(CFE_MISSION_TO_LAB_SEND_HK_TOPICID) 31 | #define TO_LAB_HK_TLM_MID CFE_PLATFORM_TLM_TOPICID_TO_MIDV(CFE_MISSION_TO_LAB_HK_TLM_TOPICID) 32 | #define TO_LAB_DATA_TYPES_MID CFE_PLATFORM_TLM_TOPICID_TO_MIDV(CFE_MISSION_TO_LAB_DATA_TYPES_TOPICID) 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /fsw/src/to_lab_encode.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 | * Define TO Lab Application header file 22 | */ 23 | 24 | #ifndef TO_LAB_ENCODE_H 25 | #define TO_LAB_ENCODE_H 26 | 27 | #include "common_types.h" 28 | #include "cfe_msg.h" 29 | #include "cfe_error.h" 30 | 31 | /******************************************************************************/ 32 | 33 | /* 34 | ** Prototypes Section 35 | */ 36 | CFE_Status_t TO_LAB_EncodeOutputMessage(const CFE_SB_Buffer_t *SourceBuffer, const void **DestBufferOut, 37 | size_t *DestSizeOut); 38 | 39 | /******************************************************************************/ 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /config/default_to_lab_msg.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 TO_LAB command and telemetry 22 | * message data types. 23 | * 24 | * This is a compatibility header for the "to_lab_msg.h" file that has 25 | * traditionally provided the message definitions for cFS apps. 26 | * 27 | * @note This file may be overridden/superceded by mission-provided defintions 28 | * either by overriding this header or by generating definitions from a command/data 29 | * dictionary tool. 30 | */ 31 | #ifndef TO_LAB_MSG_H 32 | #define TO_LAB_MSG_H 33 | 34 | #include "to_lab_interface_cfg.h" 35 | #include "to_lab_msgdefs.h" 36 | #include "to_lab_msgstruct.h" 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /.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 | 2. 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 II 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/cFE/blob/master/docs/GSC_18128_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/cFE/blob/master/docs/GSC_18128_Ind_CLA_form_1219.pdf) 35 | -------------------------------------------------------------------------------- /config/default_to_lab_platform_cfg.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 | * 22 | * TO_LAB Application Platform Configuration Header File 23 | * 24 | * This is a compatibility header for the "platform_cfg.h" file that has 25 | * traditionally provided both public and private config definitions 26 | * for each CFS app. 27 | * 28 | * These definitions are now provided in two separate files, one for 29 | * the public/mission scope and one for internal scope. 30 | * 31 | * @note This file may be overridden/superceded by mission-provided defintions 32 | * either by overriding this header or by generating definitions from a command/data 33 | * dictionary tool. 34 | */ 35 | #ifndef TO_LAB_PLATFORM_CFG_H 36 | #define TO_LAB_PLATFORM_CFG_H 37 | 38 | #include "to_lab_mission_cfg.h" 39 | #include "to_lab_internal_cfg.h" 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /config/default_to_lab_tbldefs.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 TO_LAB table related 22 | * constant definitions. 23 | * 24 | * @note 25 | * These Macro definitions have been put in this file (instead of 26 | * to_lab_tbl.h). DO NOT PUT ANY TYPEDEFS OR 27 | * STRUCTURE DEFINITIONS IN THIS FILE! 28 | * ADD THEM TO to_lab_tbl.h IF NEEDED! 29 | */ 30 | #ifndef TO_LAB_TBLDEFS_H 31 | #define TO_LAB_TBLDEFS_H 32 | 33 | #include "common_types.h" 34 | #include "to_lab_mission_cfg.h" 35 | #include "cfe_sb_extern_typedefs.h" 36 | 37 | /************************************************************************ 38 | * Macro Definitions 39 | ************************************************************************/ 40 | 41 | typedef struct 42 | { 43 | CFE_SB_MsgId_t Stream; 44 | CFE_SB_Qos_t Flags; 45 | uint16 BufLimit; 46 | } TO_LAB_Sub_t; 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /config/default_to_lab_interface_cfg.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 | * TO_LAB Application Public Definitions 22 | * 23 | * This provides default values for configurable items that affect 24 | * the interface(s) of this module. This includes the CMD/TLM message 25 | * interface, tables definitions, and any other data products that 26 | * serve to exchange information with other entities. 27 | * 28 | * @note This file may be overridden/superceded by mission-provided defintions 29 | * either by overriding this header or by generating definitions from a command/data 30 | * dictionary tool. 31 | */ 32 | #ifndef TO_LAB_INTERFACE_CFG_H 33 | #define TO_LAB_INTERFACE_CFG_H 34 | 35 | /** 36 | * @brief The base UDP port number that TO_LAB will send to 37 | */ 38 | #define TO_LAB_TLM_PORT 1235 39 | 40 | /** 41 | * @brief The maximum number of subscriptions that TO_LAB can subscribe to 42 | */ 43 | #define TO_LAB_MAX_SUBSCRIPTIONS 32 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /mission_build.cmake: -------------------------------------------------------------------------------- 1 | ########################################################### 2 | # 3 | # TO_LAB 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 | # The list of header files that control the TO_LAB configuration 12 | set(TO_LAB_MISSION_CONFIG_FILE_LIST 13 | to_lab_fcncodes.h 14 | to_lab_interface_cfg.h 15 | to_lab_mission_cfg.h 16 | to_lab_perfids.h 17 | to_lab_msg.h 18 | to_lab_msgdefs.h 19 | to_lab_msgstruct.h 20 | to_lab_tbl.h 21 | to_lab_tbldefs.h 22 | to_lab_tblstruct.h 23 | to_lab_topicids.h 24 | ) 25 | 26 | if (CFE_EDS_ENABLED_BUILD) 27 | 28 | # In an EDS-based build, these files come generated from the EDS tool 29 | set(TO_LAB_CFGFILE_SRC_to_lab_interface_cfg "to_lab_eds_designparameters.h") 30 | set(TO_LAB_CFGFILE_SRC_to_lab_tbldefs "to_lab_eds_typedefs.h") 31 | set(TO_LAB_CFGFILE_SRC_to_lab_tblstruct "to_lab_eds_typedefs.h") 32 | set(TO_LAB_CFGFILE_SRC_to_lab_msgdefs "to_lab_eds_typedefs.h") 33 | set(TO_LAB_CFGFILE_SRC_to_lab_msgstruct "to_lab_eds_typedefs.h") 34 | set(TO_LAB_CFGFILE_SRC_to_lab_fcncodes "to_lab_eds_cc.h") 35 | 36 | endif(CFE_EDS_ENABLED_BUILD) 37 | 38 | # Create wrappers around the all the config header files 39 | # This makes them individually overridable by the missions, without modifying 40 | # the distribution default copies 41 | foreach(TO_LAB_CFGFILE ${TO_LAB_MISSION_CONFIG_FILE_LIST}) 42 | get_filename_component(CFGKEY "${TO_LAB_CFGFILE}" NAME_WE) 43 | if (DEFINED TO_LAB_CFGFILE_SRC_${CFGKEY}) 44 | set(DEFAULT_SOURCE GENERATED_FILE "${TO_LAB_CFGFILE_SRC_${CFGKEY}}") 45 | else() 46 | set(DEFAULT_SOURCE FALLBACK_FILE "${CMAKE_CURRENT_LIST_DIR}/config/default_${TO_LAB_CFGFILE}") 47 | endif() 48 | generate_config_includefile( 49 | FILE_NAME "${TO_LAB_CFGFILE}" 50 | ${DEFAULT_SOURCE} 51 | ) 52 | endforeach() 53 | -------------------------------------------------------------------------------- /fsw/src/to_lab_cmds.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 | * Define TO Lab Application header file 22 | */ 23 | 24 | #ifndef TO_LAB_CMDS_H 25 | #define TO_LAB_CMDS_H 26 | 27 | #include "common_types.h" 28 | #include "cfe_error.h" 29 | #include "to_lab_msg.h" 30 | 31 | /******************************************************************************/ 32 | 33 | /* 34 | ** Prototypes Section 35 | */ 36 | CFE_Status_t TO_LAB_AddPacketCmd(const TO_LAB_AddPacketCmd_t *data); 37 | CFE_Status_t TO_LAB_NoopCmd(const TO_LAB_NoopCmd_t *data); 38 | CFE_Status_t TO_LAB_EnableOutputCmd(const TO_LAB_EnableOutputCmd_t *data); 39 | CFE_Status_t TO_LAB_RemoveAllCmd(const TO_LAB_RemoveAllCmd_t *data); 40 | CFE_Status_t TO_LAB_RemovePacketCmd(const TO_LAB_RemovePacketCmd_t *data); 41 | CFE_Status_t TO_LAB_ResetCountersCmd(const TO_LAB_ResetCountersCmd_t *data); 42 | CFE_Status_t TO_LAB_SendDataTypesCmd(const TO_LAB_SendDataTypesCmd_t *data); 43 | CFE_Status_t TO_LAB_SendHkCmd(const TO_LAB_SendHkCmd_t *data); 44 | 45 | /******************************************************************************/ 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /config/default_to_lab_fcncodes.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 TO_LAB command function codes 22 | * 23 | * @note 24 | * This file should be strictly limited to the command/function code (CC) 25 | * macro definitions. Other definitions such as enums, typedefs, or other 26 | * macros should be placed in the msgdefs.h or msg.h files. 27 | */ 28 | #ifndef TO_LAB_FCNCODES_H 29 | #define TO_LAB_FCNCODES_H 30 | 31 | /************************************************************************ 32 | * Macro Definitions 33 | ************************************************************************/ 34 | 35 | /* 36 | ** TO_LAB command codes 37 | */ 38 | #define TO_LAB_NOOP_CC 0 /* no-op command */ 39 | #define TO_LAB_RESET_STATUS_CC 1 /* reset status */ 40 | #define TO_LAB_ADD_PKT_CC 2 /* add packet */ 41 | #define TO_LAB_SEND_DATA_TYPES_CC 3 /* send data types */ 42 | #define TO_LAB_REMOVE_PKT_CC 4 /* remove packet */ 43 | #define TO_LAB_REMOVE_ALL_PKT_CC 5 /* remove all packet */ 44 | #define TO_LAB_OUTPUT_ENABLE_CC 6 /* output enable */ 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /config/default_to_lab_tblstruct.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 TO_LAB table structures 22 | * 23 | * Provides default definitions for TO_LAB table structures 24 | * 25 | * @note This file may be overridden/superceded by mission-provided defintions 26 | * either by overriding this header or by generating definitions from a command/data 27 | * dictionary tool. 28 | */ 29 | #ifndef TO_LAB_TBLSTRUCT_H 30 | #define TO_LAB_TBLSTRUCT_H 31 | 32 | /************************************************************************* 33 | * Includes 34 | *************************************************************************/ 35 | #include "to_lab_tbldefs.h" 36 | 37 | /************************************************************************ 38 | * Macro Definitions 39 | ************************************************************************/ 40 | 41 | /************************************************************************* 42 | * Type Definitions 43 | *************************************************************************/ 44 | 45 | typedef struct 46 | { 47 | TO_LAB_Sub_t Subs[TO_LAB_MAX_SUBSCRIPTIONS]; 48 | } TO_LAB_Subs_t; 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /config/default_to_lab_msgdefs.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 TO_LAB command and telemetry 22 | * message constant definitions. 23 | * 24 | * For TO_LAB this is only the function/command code definitions 25 | */ 26 | #ifndef TO_LAB_MSGDEFS_H 27 | #define TO_LAB_MSGDEFS_H 28 | 29 | #include "common_types.h" 30 | #include "cfe_sb_extern_typedefs.h" 31 | #include "to_lab_fcncodes.h" 32 | 33 | typedef struct 34 | { 35 | uint8 CommandCounter; 36 | uint8 CommandErrorCounter; 37 | uint8 spareToAlign[2]; 38 | } TO_LAB_HkTlm_Payload_t; 39 | 40 | typedef struct 41 | { 42 | uint16 synch; 43 | uint8 bl1, bl2; /* boolean */ 44 | int8 b1, b2, b3, b4; 45 | int16 w1, w2; 46 | int32 dw1, dw2; 47 | float f1, f2; 48 | double df1, df2; 49 | char str[10]; 50 | } TO_LAB_DataTypes_Payload_t; 51 | 52 | typedef struct 53 | { 54 | CFE_SB_MsgId_t Stream; 55 | CFE_SB_Qos_t Flags; 56 | uint8 BufLimit; 57 | } TO_LAB_AddPacket_Payload_t; 58 | 59 | typedef struct 60 | { 61 | CFE_SB_MsgId_t Stream; 62 | } TO_LAB_RemovePacket_Payload_t; 63 | 64 | typedef struct 65 | { 66 | char dest_IP[16]; 67 | } TO_LAB_EnableOutput_Payload_t; 68 | 69 | #endif 70 | -------------------------------------------------------------------------------- /fsw/src/to_lab_passthru_encode.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 | * This file contains the source code for the TO lab application 22 | */ 23 | 24 | #include "cfe_config.h" 25 | #include "cfe_sb.h" 26 | #include "cfe_msg.h" 27 | 28 | #include "to_lab_app.h" 29 | #include "to_lab_encode.h" 30 | 31 | /* 32 | * -------------------------------------------- 33 | * This implements an "encoder" that simply outputs the same pointer that was passed in. 34 | * This matches the traditional TO behavior where the "C" struct is passed directly to the socket. 35 | * 36 | * The only thing this needs to do get the real size of the output datagram, which should be 37 | * the size stored in the CFE message header. 38 | * -------------------------------------------- 39 | */ 40 | CFE_Status_t TO_LAB_EncodeOutputMessage(const CFE_SB_Buffer_t *SourceBuffer, const void **DestBufferOut, 41 | size_t *DestSizeOut) 42 | { 43 | CFE_Status_t ResultStatus; 44 | CFE_MSG_Size_t SourceBufferSize; 45 | 46 | ResultStatus = CFE_MSG_GetSize(&SourceBuffer->Msg, &SourceBufferSize); 47 | 48 | *DestBufferOut = SourceBuffer; 49 | *DestSizeOut = SourceBufferSize; 50 | 51 | return ResultStatus; 52 | } 53 | -------------------------------------------------------------------------------- /fsw/inc/to_lab_eventids.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 | * Define TO Lab Event messages 22 | */ 23 | #ifndef TO_LAB_EVENTIDS_H 24 | #define TO_LAB_EVENTIDS_H 25 | 26 | /*****************************************************************************/ 27 | 28 | /* Event message ID's */ 29 | #define TO_LAB_EVM_RESERVED 0 30 | 31 | #define TO_LAB_INIT_INF_EID 1 32 | #define TO_LAB_CR_PIPE_ERR_EID 2 33 | #define TO_LAB_TLMOUTENA_INF_EID 3 34 | #define TO_LAB_SUBSCRIBE_ERR_EID 4 35 | #define TO_LAB_TLMPIPE_ERR_EID 5 36 | #define TO_LAB_TLMOUTSOCKET_ERR_EID 6 37 | #define TO_LAB_TLMOUTSTOP_ERR_EID 7 38 | #define TO_LAB_MID_ERR_EID 8 39 | #define TO_LAB_FNCODE_ERR_EID 9 40 | #define TO_LAB_ADDPKT_ERR_EID 10 41 | #define TO_LAB_REMOVEPKT_ERR_EID 11 42 | #define TO_LAB_REMOVEALLPTKS_ERR_EID 12 43 | #define TO_LAB_RESET_INF_EID 13 44 | #define TO_LAB_ADDPKT_INF_EID 15 45 | #define TO_LAB_REMOVEPKT_INF_EID 16 46 | #define TO_LAB_REMOVEALLPKTS_INF_EID 17 47 | #define TO_LAB_NOOP_INF_EID 18 48 | #define TO_LAB_TBL_ERR_EID 19 49 | #define TO_LAB_ENCODE_ERR_EID 20 50 | 51 | /******************************************************************************/ 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /config/default_to_lab_internal_cfg.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 | * TO_LAB Application Private Config Definitions 22 | * 23 | * This provides default values for configurable items that are internal 24 | * to this module and do NOT affect the interface(s) of this module. Changes 25 | * to items in this file only affect the local module and will be transparent 26 | * to external entities that are using the public interface(s). 27 | * 28 | * @note This file may be overridden/superceded by mission-provided defintions 29 | * either by overriding this header or by generating definitions from a command/data 30 | * dictionary tool. 31 | */ 32 | #ifndef TO_LAB_INTERNAL_CFG_H 33 | #define TO_LAB_INTERNAL_CFG_H 34 | 35 | /*****************************************************************************/ 36 | 37 | /** 38 | * @brief Main loop task delay 39 | */ 40 | #define TO_LAB_TASK_MSEC 500 /* run at 2 Hz */ 41 | 42 | /** 43 | * @brief Telemetry pipe timeout 44 | */ 45 | #define TO_LAB_TLM_PIPE_TIMEOUT CFE_SB_POLL 46 | 47 | /** 48 | * @brief Maximum number of telemetry packets to send each wakeup 49 | */ 50 | #define TO_LAB_MAX_TLM_PKTS OS_QUEUE_MAX_DEPTH 51 | 52 | /** 53 | * Depth of pipe for commands to the TO_LAB application itself 54 | */ 55 | #define TO_LAB_CMD_PIPE_DEPTH 8 56 | 57 | /** 58 | * Depth of pipe for telemetry forwarded through the TO_LAB application 59 | */ 60 | #define TO_LAB_TLM_PIPE_DEPTH OS_QUEUE_MAX_DEPTH 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /fsw/src/to_lab_app.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 | * Define TO Lab Application header file 22 | */ 23 | 24 | #ifndef TO_LAB_APP_H 25 | #define TO_LAB_APP_H 26 | 27 | #include "common_types.h" 28 | #include "osapi.h" 29 | #include "cfe.h" 30 | 31 | #include "to_lab_mission_cfg.h" 32 | #include "to_lab_platform_cfg.h" 33 | #include "to_lab_cmds.h" 34 | #include "to_lab_dispatch.h" 35 | #include "to_lab_msg.h" 36 | #include "to_lab_tbl.h" 37 | 38 | /************************************************************************ 39 | ** Type Definitions 40 | *************************************************************************/ 41 | 42 | /** 43 | * CI global data structure 44 | */ 45 | typedef struct 46 | { 47 | CFE_SB_PipeId_t Tlm_pipe; 48 | CFE_SB_PipeId_t Cmd_pipe; 49 | osal_id_t TLMsockid; 50 | bool downlink_on; 51 | char tlm_dest_IP[17]; 52 | bool suppress_sendto; 53 | 54 | TO_LAB_HkTlm_t HkTlm; 55 | TO_LAB_DataTypesTlm_t DataTypesTlm; 56 | 57 | TO_LAB_Subs_t * SubsTblPtr; 58 | CFE_TBL_Handle_t SubsTblHandle; 59 | 60 | } TO_LAB_GlobalData_t; 61 | 62 | /************************************************************************ 63 | * Function Prototypes 64 | ************************************************************************/ 65 | 66 | void TO_LAB_AppMain(void); 67 | void TO_LAB_openTLM(void); 68 | int32 TO_LAB_init(void); 69 | void TO_LAB_process_commands(void); 70 | void TO_LAB_forward_telemetry(void); 71 | 72 | /******************************************************************************/ 73 | 74 | /* Global State Object */ 75 | extern TO_LAB_GlobalData_t TO_LAB_Global; 76 | 77 | #endif 78 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ## Reporting a Vulnerability 4 | 5 | To report a vulnerability for the to_lab subsystem please [submit an issue](https://github.com/nasa/to_lab/issues/new/choose). 6 | 7 | For general cFS vulnerabilities please [open a cFS framework issue](https://github.com/nasa/cfs/issues/new/choose) and see our [top-level security policy](https://github.com/nasa/cFS/security/policy) for additional information. 8 | 9 | In either case please use the "Bug Report" template and provide as much information as possible. Apply appropriate labels for each report. For security related reports, tag the issue with the "security" label. 10 | 11 | ## Testing 12 | 13 | **Disclaimer: nasa/to_lab is not responsible for any liability incurred under the [Apache License 2.0](https://github.com/nasa/to_lab/blob/main/LICENSE).** 14 | 15 | Testing is an important aspect our team values to improve to_lab. 16 | 17 | To view tools used for the cFS bundle, see our [top-level security policy](https://github.com/nasa/cFS/security/policy). 18 | 19 | ### CodeQL 20 | 21 | The [to_lab CodeQL GitHub Actions workflow](https://github.com/nasa/to_lab/actions/workflows/codeql-build.yml) is available to the public. To review the results, fork the to_lab repository and run the CodeQL workflow. 22 | 23 | CodeQL is ran for every push and pull-request on all branches of to_lab in GitHub Actions. 24 | 25 | For the CodeQL GitHub Actions setup, visit https://github.com/github/codeql-action. 26 | 27 | ### Cppcheck 28 | 29 | The [to_lab Cppcheck GitHub Actions workflow and results](https://github.com/nasa/to_lab/actions/workflows/static-analysis.yml) are available to the public. To view the results, select a workflow and download the artifacts. 30 | 31 | Cppcheck is ran for every push on the main branch and every pull request on all branches of to_lab in Github Actions. 32 | 33 | For more information about Cppcheck, visit http://cppcheck.sourceforge.net/. 34 | 35 | ## Additional Support 36 | 37 | For additional support, submit a GitHub issue. You can also email the cfs community at cfs-community@lists.nasa.gov. 38 | 39 | You can subscribe to the mailing list [here](https://lists.nasa.gov/mailman/listinfo/cfs-community) that includes all the community members/users of the NASA core Flight Software (cFS) product line. The mailing list is used to communicate any information related to the cFS product such as current releases, bug findings and fixes, enhancement requests, community meeting notifications, sending out meeting minutes, etc. 40 | 41 | If you wish to report a cybersecurity incident or concern, please contact the NASA Security Operations Center either by phone at 1-877-627-2732 or via email address soc@nasa.gov. 42 | -------------------------------------------------------------------------------- /fsw/src/to_lab_version.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 | * The TO Lab Application header file containing version information 22 | */ 23 | #ifndef TO_LAB_VERSION_H 24 | #define TO_LAB_VERSION_H 25 | 26 | /* Development Build Macro Definitions */ 27 | #define TO_LAB_BUILD_NUMBER 62 /*!< Development Build: Number of commits since baseline */ 28 | #define TO_LAB_BUILD_BASELINE "equuleus-rc1" /*!< Development Build: git tag that is the base for the current development */ 29 | #define TO_LAB_BUILD_DEV_CYCLE "equuleus-rc2" /**< @brief Development: Release name for current development cycle */ 30 | #define TO_LAB_BUILD_CODENAME "Equuleus" /**< @brief: Development: Code name for the current build */ 31 | 32 | /* 33 | * Version Macros, see \ref cfsversions for definitions. 34 | */ 35 | #define TO_LAB_MAJOR_VERSION 2 /*!< @brief Major version number */ 36 | #define TO_LAB_MINOR_VERSION 3 /*!< @brief Minor version number */ 37 | #define TO_LAB_REVISION 0 /*!< @brief Revision version number. Value of 0 indicates a development version.*/ 38 | 39 | /** 40 | * @brief Last official release. 41 | */ 42 | #define TO_LAB_LAST_OFFICIAL "v2.3.0" 43 | 44 | /*! 45 | * @brief Mission revision. 46 | * 47 | * Reserved for mission use to denote patches/customizations as needed. 48 | * Values 1-254 are reserved for mission use to denote patches/customizations as needed. NOTE: Reserving 0 and 0xFF for 49 | * cFS open-source development use (pending resolution of nasa/cFS#440) 50 | */ 51 | #define TO_LAB_MISSION_REV 0xFF 52 | 53 | #define TO_LAB_STR_HELPER(x) #x /*!< @brief Helper function to concatenate strings from integer macros */ 54 | #define TO_LAB_STR(x) TO_LAB_STR_HELPER(x) /*!< @brief Helper function to concatenate strings from integer macros */ 55 | 56 | /*! @brief Development Build Version Number. 57 | * @details Baseline git tag + Number of commits since baseline. @n 58 | * See @ref cfsversions for format differences between development and release versions. 59 | */ 60 | #define TO_LAB_VERSION TO_LAB_BUILD_BASELINE "+dev" TO_LAB_STR(TO_LAB_BUILD_NUMBER) 61 | 62 | /** 63 | * @brief Max Version String length. 64 | * 65 | * Maximum length that a TO_LAB version string can be. 66 | * 67 | */ 68 | #define TO_LAB_CFG_MAX_VERSION_STR_LEN 256 69 | 70 | #endif 71 | -------------------------------------------------------------------------------- /fsw/src/to_lab_eds_encode.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 | * This file contains the source code for the TO lab application 22 | */ 23 | 24 | #include "cfe_config.h" 25 | #include "cfe_sb.h" 26 | #include "cfe_msg.h" 27 | #include "cfe_error.h" 28 | 29 | #include "to_lab_app.h" 30 | #include "to_lab_encode.h" 31 | 32 | #include "edslib_datatypedb.h" 33 | #include "cfe_missionlib_api.h" 34 | #include "cfe_missionlib_runtime.h" 35 | #include "cfe_mission_eds_parameters.h" 36 | #include "cfe_mission_eds_interface_parameters.h" 37 | 38 | #include "cfe_hdr_eds_datatypes.h" 39 | 40 | CFE_Status_t TO_LAB_EncodeOutputMessage(const CFE_SB_Buffer_t *SourceBuffer, const void **DestBufferOut, 41 | size_t *DestSizeOut) 42 | { 43 | EdsLib_Id_t EdsId; 44 | EdsLib_DataTypeDB_TypeInfo_t TypeInfo; 45 | CFE_SB_SoftwareBus_PubSub_Interface_t PubSubParams; 46 | CFE_SB_Publisher_Component_t PublisherParams; 47 | uint16 TopicId; 48 | int32 EdsStatus; 49 | CFE_Status_t ResultStatus; 50 | size_t SourceBufferSize; 51 | 52 | static EdsPackedBuffer_CFE_HDR_TelemetryHeader_t NetworkBuffer; 53 | 54 | const EdsLib_DatabaseObject_t *EDS_DB = CFE_Config_GetObjPointer(CFE_CONFIGID_MISSION_EDS_DB); 55 | 56 | ResultStatus = CFE_MSG_GetSize(&SourceBuffer->Msg, &SourceBufferSize); 57 | if (ResultStatus != CFE_SUCCESS) 58 | { 59 | return ResultStatus; 60 | } 61 | 62 | CFE_MissionLib_Get_PubSub_Parameters(&PubSubParams, &SourceBuffer->Msg.BaseMsg); 63 | CFE_MissionLib_UnmapPublisherComponent(&PublisherParams, &PubSubParams); 64 | TopicId = PublisherParams.Telemetry.TopicId; 65 | 66 | EdsStatus = CFE_MissionLib_GetArgumentType(&CFE_SOFTWAREBUS_INTERFACE, EDS_INTERFACE_ID(CFE_SB_Telemetry), TopicId, 67 | 1, 1, &EdsId); 68 | if (EdsStatus != CFE_MISSIONLIB_SUCCESS) 69 | { 70 | return CFE_STATUS_UNKNOWN_MSG_ID; 71 | } 72 | 73 | EdsStatus = EdsLib_DataTypeDB_PackCompleteObject(EDS_DB, &EdsId, NetworkBuffer, SourceBuffer, 74 | 8 * sizeof(NetworkBuffer), SourceBufferSize); 75 | if (EdsStatus != EDSLIB_SUCCESS) 76 | { 77 | return CFE_SB_INTERNAL_ERR; 78 | } 79 | 80 | EdsStatus = EdsLib_DataTypeDB_GetTypeInfo(EDS_DB, EdsId, &TypeInfo); 81 | if (EdsStatus != EDSLIB_SUCCESS) 82 | { 83 | return CFE_SB_INTERNAL_ERR; 84 | } 85 | 86 | *DestSizeOut = (TypeInfo.Size.Bits + 7) / 8; 87 | *DestBufferOut = NetworkBuffer; 88 | 89 | return CFE_SUCCESS; 90 | } 91 | -------------------------------------------------------------------------------- /config/default_to_lab_msgstruct.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 TO_LAB command and telemetry 22 | * message data types. 23 | * 24 | * @note 25 | * Constants and enumerated types related to these message structures 26 | * are defined in to_lab_msgdefs.h. 27 | */ 28 | #ifndef TO_LAB_MSGSTRUCT_H 29 | #define TO_LAB_MSGSTRUCT_H 30 | 31 | /************************************************************************ 32 | * Includes 33 | ************************************************************************/ 34 | 35 | #include "to_lab_mission_cfg.h" 36 | #include "to_lab_msgdefs.h" 37 | #include "cfe_msg_hdr.h" 38 | 39 | /******************************************************************************/ 40 | 41 | typedef struct 42 | { 43 | CFE_MSG_TelemetryHeader_t TelemetryHeader; /**< \brief Telemetry header */ 44 | TO_LAB_HkTlm_Payload_t Payload; /**< \brief Telemetry payload */ 45 | } TO_LAB_HkTlm_t; 46 | 47 | /******************************************************************************/ 48 | 49 | typedef struct 50 | { 51 | CFE_MSG_TelemetryHeader_t TelemetryHeader; /**< \brief Telemetry header */ 52 | TO_LAB_DataTypes_Payload_t Payload; /**< \brief Telemetry payload */ 53 | } TO_LAB_DataTypesTlm_t; 54 | 55 | /******************************************************************************/ 56 | 57 | /* 58 | * The following commands do not have any payload, 59 | * but should still "reserve" a unique structure type to 60 | * employ a consistent handler pattern. 61 | * 62 | * This matches the pattern in CFE core and other modules. 63 | */ 64 | typedef struct 65 | { 66 | CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command header */ 67 | } TO_LAB_SendHkCmd_t; 68 | 69 | typedef struct 70 | { 71 | CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command header */ 72 | } TO_LAB_NoopCmd_t; 73 | 74 | typedef struct 75 | { 76 | CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command header */ 77 | } TO_LAB_ResetCountersCmd_t; 78 | 79 | typedef struct 80 | { 81 | CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command header */ 82 | } TO_LAB_RemoveAllCmd_t; 83 | 84 | typedef struct 85 | { 86 | CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command header */ 87 | } TO_LAB_SendDataTypesCmd_t; 88 | 89 | typedef struct 90 | { 91 | CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command header */ 92 | TO_LAB_AddPacket_Payload_t Payload; /**< \brief Command payload */ 93 | } TO_LAB_AddPacketCmd_t; 94 | 95 | typedef struct 96 | { 97 | CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command header */ 98 | TO_LAB_RemovePacket_Payload_t Payload; /**< \brief Command payload */ 99 | } TO_LAB_RemovePacketCmd_t; 100 | 101 | typedef struct 102 | { 103 | CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command header */ 104 | TO_LAB_EnableOutput_Payload_t Payload; /**< \brief Command payload */ 105 | } TO_LAB_EnableOutputCmd_t; 106 | 107 | #endif /* TO_LAB_MSGSTRUCT_H */ 108 | -------------------------------------------------------------------------------- /fsw/src/to_lab_dispatch.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 | * This file contains the source code for the TO lab application 22 | */ 23 | 24 | #include "cfe.h" 25 | 26 | #include "to_lab_app.h" 27 | #include "to_lab_dispatch.h" 28 | #include "to_lab_cmds.h" 29 | #include "to_lab_msg.h" 30 | #include "to_lab_eventids.h" 31 | #include "to_lab_msgids.h" 32 | 33 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 34 | /* */ 35 | /* TO_LAB_ProcessGroundCommand() -- Process local message */ 36 | /* */ 37 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 38 | void TO_LAB_ProcessGroundCommand(const CFE_SB_Buffer_t *SBBufPtr) 39 | { 40 | CFE_MSG_FcnCode_t FcnCode = 0; 41 | 42 | CFE_MSG_GetFcnCode(&SBBufPtr->Msg, &FcnCode); 43 | 44 | switch (FcnCode) 45 | { 46 | case TO_LAB_NOOP_CC: 47 | TO_LAB_NoopCmd((const TO_LAB_NoopCmd_t *)SBBufPtr); 48 | break; 49 | 50 | case TO_LAB_RESET_STATUS_CC: 51 | TO_LAB_ResetCountersCmd((const TO_LAB_ResetCountersCmd_t *)SBBufPtr); 52 | break; 53 | 54 | case TO_LAB_SEND_DATA_TYPES_CC: 55 | TO_LAB_SendDataTypesCmd((const TO_LAB_SendDataTypesCmd_t *)SBBufPtr); 56 | break; 57 | 58 | case TO_LAB_ADD_PKT_CC: 59 | TO_LAB_AddPacketCmd((const TO_LAB_AddPacketCmd_t *)SBBufPtr); 60 | break; 61 | 62 | case TO_LAB_REMOVE_PKT_CC: 63 | TO_LAB_RemovePacketCmd((const TO_LAB_RemovePacketCmd_t *)SBBufPtr); 64 | break; 65 | 66 | case TO_LAB_REMOVE_ALL_PKT_CC: 67 | TO_LAB_RemoveAllCmd((const TO_LAB_RemoveAllCmd_t *)SBBufPtr); 68 | break; 69 | 70 | case TO_LAB_OUTPUT_ENABLE_CC: 71 | TO_LAB_EnableOutputCmd((const TO_LAB_EnableOutputCmd_t *)SBBufPtr); 72 | break; 73 | 74 | default: 75 | CFE_EVS_SendEvent(TO_LAB_FNCODE_ERR_EID, CFE_EVS_EventType_ERROR, 76 | "L%d TO: Invalid Function Code Rcvd In Ground Command 0x%x", __LINE__, 77 | (unsigned int)FcnCode); 78 | ++TO_LAB_Global.HkTlm.Payload.CommandErrorCounter; 79 | break; 80 | } 81 | } 82 | 83 | void TO_LAB_TaskPipe(const CFE_SB_Buffer_t *SBBufPtr) 84 | { 85 | CFE_SB_MsgId_t MsgId; 86 | 87 | CFE_MSG_GetMsgId(&SBBufPtr->Msg, &MsgId); 88 | 89 | /* For SB return statuses that imply a message: process it. */ 90 | switch (CFE_SB_MsgIdToValue(MsgId)) 91 | { 92 | case TO_LAB_CMD_MID: 93 | TO_LAB_ProcessGroundCommand(SBBufPtr); 94 | break; 95 | 96 | case TO_LAB_SEND_HK_MID: 97 | TO_LAB_SendHkCmd((const TO_LAB_SendHkCmd_t *)SBBufPtr); 98 | break; 99 | 100 | default: 101 | CFE_EVS_SendEvent(TO_LAB_MID_ERR_EID, CFE_EVS_EventType_ERROR, "L%d TO: Invalid Msg ID Rcvd 0x%x", 102 | __LINE__, (unsigned int)CFE_SB_MsgIdToValue(MsgId)); 103 | break; 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /fsw/src/to_lab_eds_dispatch.c: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | ** 3 | ** GSC-18128-1, "Core Flight Executive Version 6.7" 4 | ** 5 | ** Copyright (c) 2006-2019 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 | ** File: to_lab_app.c 22 | ** 23 | ** Purpose: 24 | ** his file contains the source code for the TO lab application 25 | ** 26 | ** Notes: 27 | ** 28 | *************************************************************************/ 29 | 30 | #include "to_lab_app.h" 31 | #include "to_lab_eventids.h" 32 | #include "to_lab_dispatch.h" 33 | #include "to_lab_cmds.h" 34 | 35 | #include "to_lab_eds_dictionary.h" 36 | #include "to_lab_eds_dispatcher.h" 37 | 38 | static const EdsDispatchTable_TO_LAB_Application_CFE_SB_Telecommand_t TO_LAB_TC_DISPATCH_TABLE = { 39 | .CMD = {.AddPacketCmd_indication = TO_LAB_AddPacketCmd, 40 | .NoopCmd_indication = TO_LAB_NoopCmd, 41 | .EnableOutputCmd_indication = TO_LAB_EnableOutputCmd, 42 | .RemoveAllCmd_indication = TO_LAB_RemoveAllCmd, 43 | .RemovePacketCmd_indication = TO_LAB_RemovePacketCmd, 44 | .ResetCountersCmd_indication = TO_LAB_ResetCountersCmd, 45 | .SendDataTypesCmd_indication = TO_LAB_SendDataTypesCmd}, 46 | .SEND_HK = {.indication = TO_LAB_SendHkCmd}}; 47 | 48 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 49 | /* */ 50 | /* TO_LAB_TaskPipe() -- Process command pipe message */ 51 | /* */ 52 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 53 | void TO_LAB_TaskPipe(const CFE_SB_Buffer_t *SbBufPtr) 54 | { 55 | CFE_Status_t status; 56 | CFE_SB_MsgId_t MsgId; 57 | CFE_MSG_Size_t MsgSize; 58 | CFE_MSG_FcnCode_t MsgFc; 59 | 60 | status = EdsDispatch_TO_LAB_Application_Telecommand(SbBufPtr, &TO_LAB_TC_DISPATCH_TABLE); 61 | 62 | if (status != CFE_SUCCESS) 63 | { 64 | CFE_MSG_GetMsgId(&SbBufPtr->Msg, &MsgId); 65 | ++TO_LAB_Global.HkTlm.Payload.CommandErrorCounter; 66 | 67 | if (status == CFE_STATUS_UNKNOWN_MSG_ID) 68 | { 69 | CFE_EVS_SendEvent(TO_LAB_MID_ERR_EID, CFE_EVS_EventType_ERROR, 70 | "L%d TO: Invalid Msg ID Rcvd 0x%x status=0x%08x", __LINE__, 71 | (unsigned int)CFE_SB_MsgIdToValue(MsgId), (unsigned int)status); 72 | } 73 | else if (status == CFE_STATUS_WRONG_MSG_LENGTH) 74 | { 75 | CFE_MSG_GetSize(&SbBufPtr->Msg, &MsgSize); 76 | CFE_MSG_GetFcnCode(&SbBufPtr->Msg, &MsgFc); 77 | CFE_EVS_SendEvent(TO_LAB_MID_ERR_EID, CFE_EVS_EventType_ERROR, 78 | "Invalid length for command: ID = 0x%X, CC = %d, length = %u", 79 | (unsigned int)CFE_SB_MsgIdToValue(MsgId), (int)MsgFc, (unsigned int)MsgSize); 80 | } 81 | else 82 | { 83 | CFE_MSG_GetFcnCode(&SbBufPtr->Msg, &MsgFc); 84 | CFE_EVS_SendEvent(TO_LAB_FNCODE_ERR_EID, CFE_EVS_EventType_ERROR, 85 | "L%d TO: Invalid Function Code Rcvd In Ground Command 0x%x", __LINE__, 86 | (unsigned int)MsgFc); 87 | ++TO_LAB_Global.HkTlm.Payload.CommandErrorCounter; 88 | } 89 | } 90 | } /* End of TO_LAB_TaskPipe() */ 91 | -------------------------------------------------------------------------------- /fsw/tables/to_lab_sub.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 | * Define TO Lab CPU specific subscription table 22 | */ 23 | 24 | #include "cfe_tbl_filedef.h" /* Required to obtain the CFE_TBL_FILEDEF macro definition */ 25 | #include "cfe_sb_api_typedefs.h" 26 | #include "to_lab_tbl.h" 27 | #include "cfe_msgids.h" 28 | 29 | /* 30 | ** Add the proper include file for the message IDs below 31 | */ 32 | #include "to_lab_msgids.h" 33 | 34 | #ifdef HAVE_CI_LAB 35 | #include "ci_lab_msgids.h" 36 | #endif 37 | 38 | #ifdef HAVE_SAMPLE_APP 39 | #include "sample_app_msgids.h" 40 | #endif 41 | 42 | #ifdef HAVE_HS 43 | #include "hs_msgids.h" 44 | #endif 45 | 46 | #ifdef HAVE_FM 47 | #include "fm_msgids.h" 48 | #endif 49 | 50 | #ifdef HAVE_SC 51 | #include "sc_msgids.h" 52 | #endif 53 | 54 | #ifdef HAVE_DS 55 | #include "ds_msgids.h" 56 | #endif 57 | 58 | #ifdef HAVE_LC 59 | #include "lc_msgids.h" 60 | #endif 61 | 62 | TO_LAB_Subs_t TO_LAB_Subs = {.Subs = {/* CFS App Subscriptions */ 63 | {CFE_SB_MSGID_WRAP_VALUE(TO_LAB_HK_TLM_MID), {0, 0}, 4}, 64 | {CFE_SB_MSGID_WRAP_VALUE(TO_LAB_DATA_TYPES_MID), {0, 0}, 4}, 65 | 66 | /* cFE Core subscriptions */ 67 | {CFE_SB_MSGID_WRAP_VALUE(CFE_ES_HK_TLM_MID), {0, 0}, 4}, 68 | {CFE_SB_MSGID_WRAP_VALUE(CFE_EVS_HK_TLM_MID), {0, 0}, 4}, 69 | {CFE_SB_MSGID_WRAP_VALUE(CFE_SB_HK_TLM_MID), {0, 0}, 4}, 70 | {CFE_SB_MSGID_WRAP_VALUE(CFE_TBL_HK_TLM_MID), {0, 0}, 4}, 71 | {CFE_SB_MSGID_WRAP_VALUE(CFE_TIME_HK_TLM_MID), {0, 0}, 4}, 72 | {CFE_SB_MSGID_WRAP_VALUE(CFE_TIME_DIAG_TLM_MID), {0, 0}, 4}, 73 | {CFE_SB_MSGID_WRAP_VALUE(CFE_SB_STATS_TLM_MID), {0, 0}, 4}, 74 | {CFE_SB_MSGID_WRAP_VALUE(CFE_TBL_REG_TLM_MID), {0, 0}, 4}, 75 | {CFE_SB_MSGID_WRAP_VALUE(CFE_EVS_LONG_EVENT_MSG_MID), {0, 0}, 32}, 76 | {CFE_SB_MSGID_WRAP_VALUE(CFE_EVS_SHORT_EVENT_MSG_MID), {0, 0}, 32}, 77 | {CFE_SB_MSGID_WRAP_VALUE(CFE_ES_APP_TLM_MID), {0, 0}, 4}, 78 | {CFE_SB_MSGID_WRAP_VALUE(CFE_ES_MEMSTATS_TLM_MID), {0, 0}, 4}, 79 | 80 | #ifdef HAVE_CI_LAB 81 | {CFE_SB_MSGID_WRAP_VALUE(CI_LAB_HK_TLM_MID), {0, 0}, 4}, 82 | #endif 83 | #ifdef HAVE_SAMPLE_APP 84 | {CFE_SB_MSGID_WRAP_VALUE(SAMPLE_APP_HK_TLM_MID), {0, 0}, 4}, 85 | #endif 86 | #ifdef HAVE_HS 87 | {CFE_SB_MSGID_WRAP_VALUE(HS_HK_TLM_MID), {0, 0}, 4}, 88 | #endif 89 | #ifdef HAVE_FM 90 | {CFE_SB_MSGID_WRAP_VALUE(FM_HK_TLM_MID), {0, 0}, 4}, 91 | #endif 92 | #ifdef HAVE_SC 93 | {CFE_SB_MSGID_WRAP_VALUE(SC_HK_TLM_MID), {0, 0}, 4}, 94 | #endif 95 | #ifdef HAVE_DS 96 | {CFE_SB_MSGID_WRAP_VALUE(DS_HK_TLM_MID), {0, 0}, 4}, 97 | #endif 98 | #ifdef HAVE_LC 99 | {CFE_SB_MSGID_WRAP_VALUE(LC_HK_TLM_MID), {0, 0}, 4}, 100 | #endif 101 | 102 | /* CFE_SB_MSGID_RESERVED entry to mark the end of valid MsgIds */ 103 | {CFE_SB_MSGID_RESERVED, {0, 0}, 0}}}; 104 | 105 | CFE_TBL_FILEDEF(TO_LAB_Subs, TO_LAB_APP.TO_LAB_Subs, TO Lab Sub Tbl, to_lab_sub.tbl) 106 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## Development Build: equuleus-rc1+dev62 4 | - Rename CommandCode variable to Fcncode 5 | - Light initialization logic refactor + remove multiple returns 6 | - See and 7 | 8 | ## Development Build: equuleus-rc1+dev56 9 | - Add CFE_EVS_SHORT_EVENT_MSG_MID to to_lab_sub.c 10 | - See 11 | 12 | ## Development Build: equuleus-rc1+dev52 13 | - Zero-out global data during init + set RunStatus to APP_ERROR if init fails 14 | - See 15 | 16 | ## Development Build: equuleus-rc1+dev48 17 | - apply name changes to EDS dispatcher 18 | - See 19 | 20 | ## Development Build: equuleus-rc1+dev44 21 | - Add an event for ResetCountersCmd 22 | - Add version information to NOOP event 23 | - See and 24 | 25 | ## Development Build: equuleus-rc1+dev38 26 | - updating to_lab to use new versioning system 27 | - See 28 | 29 | ## Development Build: v2.5.0-rc4+dev75 30 | - define msgids via topicids 31 | - See 32 | 33 | ## Development Build: v2.5.0-rc4+dev71 34 | - Add timeout and packet limit on sending telemetry 35 | - See 36 | 37 | ## Development Build: v2.5.0-rc4+dev66 38 | - reorganize source files 39 | - Apply consistent Event ID names to common events 40 | - Refactor mutually exclusive logic in if, else if block 41 | - Add check for failure of CFE_EVS_Register() during initialization 42 | - Convert int32 return codes and variables to CFE_Status_t 43 | - Move function prototypes to header file 44 | - Update misnamed CmdHeader variable in to_lab_msg.h 45 | - See , , , , , , and 46 | 47 | ## Development Build: v2.5.0-rc4+dev49 48 | - Remove unused/unnecessary TO_LAB_UNUSED 49 | - See 50 | 51 | ## Development Build: v2.5.0-rc4+dev45 52 | - adjust subscription table based on apps present 53 | - See 54 | 55 | ## Development Build: v2.5.0-rc4+dev41 56 | - update cmake recipe 57 | - See 58 | 59 | ## Development Build: v2.5.0-rc4+dev35 60 | - Adds format changes in to_lab_app.c 61 | - See 62 | 63 | ## Development Build: v2.5.0-rc4+dev31 64 | - Remove unused PktSize variable. 65 | - Standardize naming of TO_LAB functions/macros etc. 66 | - Create CHANGELOG.md 67 | - See , , and 68 | 69 | ## Development Build: v2.5.0-rc4+dev23 70 | - Update cmake mimimum required to something more recent 71 | - See 72 | 73 | ## Development Build: v2.5.0-rc4+dev21 74 | 75 | - Remove registration of empty EVS filters 76 | - Update codeql workflow for reusable updates 77 | - See 78 | 79 | 80 | ## Development Build: v2.5.0-rc4+dev16 81 | 82 | - Update Copyright Headers 83 | - Standardize version.h 84 | - See and 85 | 86 | ## Development Build: v2.5.0-rc4+dev9 87 | 88 | - Apply header guard standard 89 | - See 90 | 91 | ## Development Build: v2.5.0-rc4+dev4 92 | 93 | - Use CFE_MSG_PTR conversion macro 94 | - Set new baseline for cFS-Caelum-rc4: v2.5.0-rc4 95 | - See and 96 | 97 | ## Development Build: v2.4.0-rc1+dev58 98 | 99 | - Apply CFE_SB_ValueToMsgId where required 100 | - See and 101 | 102 | ## Development Build: v2.4.0-rc1+dev49 103 | 104 | - Implement Coding Standard in CodeQL workflow 105 | - See and 106 | 107 | ## Development Build: v2.4.0-rc1+dev47 108 | 109 | - Removes app registration call, `CFE_ES_RegisterApp()` since applications do not need to register themselves. 110 | - See 111 | 112 | ## Development Build: v2.4.0-rc1+dev41 113 | 114 | - Use `cfe.h` header file 115 | - See 116 | 117 | ## Development Build: v2.4.0-rc1+dev38 118 | 119 | - Remove numeric pipe ID from event printf 120 | - Add Testing Tools to the Security Policy 121 | - See 122 | 123 | ## Development Build: v.2.4.0-rc1+dev32 124 | 125 | - Removes end-of-function comments in `to_lab_app.c` 126 | - Adds static analysis and code format check to continuous integration workflow. Updates workflow status badges in ReadMe 127 | - Adds CodeQL analysis to continuous integration workflow 128 | - See 129 | 130 | ## Development Build: v.2.4.0-rc1+dev21 131 | 132 | - TO remains command-able after a "remove all subscriptions" command; the command now only removes all subscriptions to the Tlm_pipe 133 | - See 134 | 135 | ## Development Build: v.2.4.0-rc1+dev17 136 | 137 | - Aligns messages according to changes in cFE . Uses the "raw" message cmd/tlm types in definition 138 | - See 139 | 140 | ## Development Build: v.2.4.0-rc1+dev13 141 | 142 | - Replaces deprecated SB API's with MSG 143 | - See 144 | 145 | ## Development Build: v.2.4.0-rc1+dev9 146 | 147 | - Update the TLMsockid field to be `osal_id_t` instead of uint32 148 | - Set revision number to 99 to indicate development status in telemetry 149 | - See 150 | 151 | ## Development Build: v.2.4.0-rc1+dev6 152 | 153 | - Adds header guard to `to_lab_sub_table.h` 154 | - See 155 | 156 | ## Development Build: v.2.4.0-rc1+dev3 157 | 158 | - Remove reference to deprecated `CFE_ES_SHELL_TLM_MID`. 159 | - See 160 | 161 | ## Development Build: v2.3.0+dev45 162 | 163 | - Fixes bug where an unset address values caused subscriptions to MsgId 0 over 200 times. Added a `TO_UNUSED` entry at the end of the subscription list and a break in the subscription loop when `TO_UNUSED` found. No more subscriptions on the unused table slots (no MsgId 0 subscriptions). 164 | - Corrects return value of `TO_LAB_init()` to be `int32` instead of `int`. Declaration now matches definition, and app builds without errors. 165 | - Add build number and baseline to version reporting. 166 | - See 167 | 168 | ## Development Build: v2.3.7 169 | 170 | - Makes the `TO_LAB_Subs` table into a CFE_TBL-managed table. 171 | - See 172 | 173 | 174 | ## Development Build: v2.3.6 175 | 176 | - Replace references to `ccsds.h` types with the `cfe_sb.h`-provided type. 177 | - See 178 | 179 | ## Development Build: v2.3.5 180 | 181 | - Apply code style 182 | - See 183 | 184 | ## Development Build: v2.3.4 185 | 186 | - Configure the maximum depth supported by OSAL, rather than a hard coded 64. 187 | - See 188 | 189 | ## Development Build: v2.3.3 190 | 191 | - Apply the CFE_SB_MsgIdToValue() and CFE_SB_ValueToMsgId() routines where compatibility with an integer MsgId is necessary - syslog prints, events, compile-time MID #define values. 192 | - Deprecates shell tlm subscription 193 | - Changes to documentation 194 | - See 195 | 196 | ## Development Build: v2.3.2 197 | 198 | - Use OSAL socket API instead of BSD Sockets 199 | 200 | - Use global namespace to isolate variables 201 | 202 | - Minor updates (see ) 203 | 204 | ## Development Build: v2.3.1 205 | 206 | - Fix for a clean build with OMIT_DEPRECATED 207 | - Minor updates (see ) 208 | 209 | ## _**OFFICIAL RELEASE: 2.3.0 - Aquila**_ 210 | 211 | - Minor updates (see ) 212 | 213 | - Not backwards compatible with OSAL 4.2.1 214 | 215 | - Released as part of cFE 6.7.0, Apache 2.0 216 | 217 | ## _**OFFICIAL RELEASE: 2.2.0a**_ 218 | 219 | - Released as part of cFE 6.6.0a, Apache 2.0 220 | 221 | ## Known issues 222 | 223 | As a lab application, extensive testing is not performed prior to release and only minimal functionality is included. 224 | 225 | ## Getting Help 226 | 227 | For best results, submit issues:questions or issues:help wanted requests at . 228 | 229 | Official cFS page: 230 | -------------------------------------------------------------------------------- /eds/to_lab.xml: -------------------------------------------------------------------------------- 1 | 2 | 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 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | -------------------------------------------------------------------------------- /fsw/src/to_lab_cmds.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 | * This file contains the source code for the TO lab application 22 | */ 23 | 24 | #include "cfe.h" 25 | #include "cfe_config.h" // For CFE_Config_GetVersionString 26 | 27 | #include "to_lab_app.h" 28 | #include "to_lab_cmds.h" 29 | #include "to_lab_msg.h" 30 | #include "to_lab_eventids.h" 31 | #include "to_lab_msgids.h" 32 | #include "to_lab_version.h" 33 | 34 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 35 | /* */ 36 | /* TO_LAB_EnableOutput() -- TLM output enabled */ 37 | /* */ 38 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 39 | CFE_Status_t TO_LAB_EnableOutputCmd(const TO_LAB_EnableOutputCmd_t *data) 40 | { 41 | const TO_LAB_EnableOutput_Payload_t *pCmd = &data->Payload; 42 | 43 | (void)CFE_SB_MessageStringGet(TO_LAB_Global.tlm_dest_IP, pCmd->dest_IP, "", sizeof(TO_LAB_Global.tlm_dest_IP), 44 | sizeof(pCmd->dest_IP)); 45 | TO_LAB_Global.suppress_sendto = false; 46 | CFE_EVS_SendEvent(TO_LAB_TLMOUTENA_INF_EID, CFE_EVS_EventType_INFORMATION, "TO telemetry output enabled for IP %s", 47 | TO_LAB_Global.tlm_dest_IP); 48 | 49 | if (!TO_LAB_Global.downlink_on) /* Then turn it on, otherwise we will just switch destination addresses*/ 50 | { 51 | TO_LAB_openTLM(); 52 | TO_LAB_Global.downlink_on = true; 53 | } 54 | 55 | ++TO_LAB_Global.HkTlm.Payload.CommandCounter; 56 | return CFE_SUCCESS; 57 | } 58 | 59 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 60 | /* */ 61 | /* TO_LAB_Noop() -- Noop Handler */ 62 | /* */ 63 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 64 | CFE_Status_t TO_LAB_NoopCmd(const TO_LAB_NoopCmd_t *data) 65 | { 66 | char VersionString[TO_LAB_CFG_MAX_VERSION_STR_LEN]; 67 | 68 | CFE_Config_GetVersionString(VersionString, TO_LAB_CFG_MAX_VERSION_STR_LEN, "TO Lab", 69 | TO_LAB_VERSION, TO_LAB_BUILD_CODENAME, TO_LAB_LAST_OFFICIAL); 70 | 71 | CFE_EVS_SendEvent(TO_LAB_NOOP_INF_EID, CFE_EVS_EventType_INFORMATION, "TO: NOOP command. %s", VersionString); 72 | 73 | ++TO_LAB_Global.HkTlm.Payload.CommandCounter; 74 | return CFE_SUCCESS; 75 | } 76 | 77 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 78 | /* */ 79 | /* TO_LAB_ResetCounters() -- Reset counters */ 80 | /* */ 81 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 82 | CFE_Status_t TO_LAB_ResetCountersCmd(const TO_LAB_ResetCountersCmd_t *data) 83 | { 84 | TO_LAB_Global.HkTlm.Payload.CommandErrorCounter = 0; 85 | TO_LAB_Global.HkTlm.Payload.CommandCounter = 0; 86 | 87 | CFE_EVS_SendEvent(TO_LAB_RESET_INF_EID, CFE_EVS_EventType_INFORMATION, "Reset counters command"); 88 | 89 | return CFE_SUCCESS; 90 | } 91 | 92 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 93 | /* */ 94 | /* TO_LAB_SendDataTypes() -- Output data types */ 95 | /* */ 96 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 97 | CFE_Status_t TO_LAB_SendDataTypesCmd(const TO_LAB_SendDataTypesCmd_t *data) 98 | { 99 | int16 i; 100 | char string_variable[10] = "ABCDEFGHIJ"; 101 | 102 | /* initialize data types packet */ 103 | CFE_MSG_Init(CFE_MSG_PTR(TO_LAB_Global.DataTypesTlm.TelemetryHeader), CFE_SB_ValueToMsgId(TO_LAB_DATA_TYPES_MID), 104 | sizeof(TO_LAB_Global.DataTypesTlm)); 105 | 106 | CFE_SB_TimeStampMsg(CFE_MSG_PTR(TO_LAB_Global.DataTypesTlm.TelemetryHeader)); 107 | 108 | /* initialize the packet data */ 109 | TO_LAB_Global.DataTypesTlm.Payload.synch = 0x6969; 110 | #if 0 111 | TO_LAB_Global.DataTypesTlm.Payload.bit1 = 1; 112 | TO_LAB_Global.DataTypesTlm.Payload.bit2 = 0; 113 | TO_LAB_Global.DataTypesTlm.Payload.bit34 = 2; 114 | TO_LAB_Global.DataTypesTlm.Payload.bit56 = 3; 115 | TO_LAB_Global.DataTypesTlm.Payload.bit78 = 1; 116 | TO_LAB_Global.DataTypesTlm.Payload.nibble1 = 0xA; 117 | TO_LAB_Global.DataTypesTlm.Payload.nibble2 = 0x4; 118 | #endif 119 | TO_LAB_Global.DataTypesTlm.Payload.bl1 = false; 120 | TO_LAB_Global.DataTypesTlm.Payload.bl2 = true; 121 | TO_LAB_Global.DataTypesTlm.Payload.b1 = 16; 122 | TO_LAB_Global.DataTypesTlm.Payload.b2 = 127; 123 | TO_LAB_Global.DataTypesTlm.Payload.b3 = 0x7F; 124 | TO_LAB_Global.DataTypesTlm.Payload.b4 = 0x45; 125 | TO_LAB_Global.DataTypesTlm.Payload.w1 = 0x2468; 126 | TO_LAB_Global.DataTypesTlm.Payload.w2 = 0x7FFF; 127 | TO_LAB_Global.DataTypesTlm.Payload.dw1 = 0x12345678; 128 | TO_LAB_Global.DataTypesTlm.Payload.dw2 = 0x87654321; 129 | TO_LAB_Global.DataTypesTlm.Payload.f1 = 90.01; 130 | TO_LAB_Global.DataTypesTlm.Payload.f2 = .0000045; 131 | TO_LAB_Global.DataTypesTlm.Payload.df1 = 99.9; 132 | TO_LAB_Global.DataTypesTlm.Payload.df2 = .4444; 133 | 134 | for (i = 0; i < 10; i++) 135 | TO_LAB_Global.DataTypesTlm.Payload.str[i] = string_variable[i]; 136 | 137 | CFE_SB_TransmitMsg(CFE_MSG_PTR(TO_LAB_Global.DataTypesTlm.TelemetryHeader), true); 138 | 139 | ++TO_LAB_Global.HkTlm.Payload.CommandCounter; 140 | return CFE_SUCCESS; 141 | } 142 | 143 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 144 | /* */ 145 | /* TO_LAB_SendHousekeeping() -- HK status */ 146 | /* Does not increment CommandCounter */ 147 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 148 | CFE_Status_t TO_LAB_SendHkCmd(const TO_LAB_SendHkCmd_t *data) 149 | { 150 | CFE_SB_TimeStampMsg(CFE_MSG_PTR(TO_LAB_Global.HkTlm.TelemetryHeader)); 151 | CFE_SB_TransmitMsg(CFE_MSG_PTR(TO_LAB_Global.HkTlm.TelemetryHeader), true); 152 | return CFE_SUCCESS; 153 | } 154 | 155 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 156 | /* */ 157 | /* TO_LAB_AddPacket() -- Add packets */ 158 | /* */ 159 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 160 | CFE_Status_t TO_LAB_AddPacketCmd(const TO_LAB_AddPacketCmd_t *data) 161 | { 162 | const TO_LAB_AddPacket_Payload_t *pCmd = &data->Payload; 163 | int32 status; 164 | 165 | status = CFE_SB_SubscribeEx(pCmd->Stream, TO_LAB_Global.Tlm_pipe, pCmd->Flags, pCmd->BufLimit); 166 | 167 | if (status != CFE_SUCCESS) 168 | CFE_EVS_SendEvent(TO_LAB_ADDPKT_ERR_EID, CFE_EVS_EventType_ERROR, "L%d TO Can't subscribe 0x%x status %i", 169 | __LINE__, (unsigned int)CFE_SB_MsgIdToValue(pCmd->Stream), (int)status); 170 | else 171 | CFE_EVS_SendEvent(TO_LAB_ADDPKT_INF_EID, CFE_EVS_EventType_INFORMATION, 172 | "L%d TO AddPkt 0x%x, QoS %d.%d, limit %d", __LINE__, 173 | (unsigned int)CFE_SB_MsgIdToValue(pCmd->Stream), pCmd->Flags.Priority, 174 | pCmd->Flags.Reliability, pCmd->BufLimit); 175 | 176 | ++TO_LAB_Global.HkTlm.Payload.CommandCounter; 177 | return CFE_SUCCESS; 178 | } 179 | 180 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 181 | /* */ 182 | /* TO_LAB_RemovePacket() -- Remove Packet */ 183 | /* */ 184 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 185 | CFE_Status_t TO_LAB_RemovePacketCmd(const TO_LAB_RemovePacketCmd_t *data) 186 | { 187 | const TO_LAB_RemovePacket_Payload_t *pCmd = &data->Payload; 188 | int32 status; 189 | 190 | status = CFE_SB_Unsubscribe(pCmd->Stream, TO_LAB_Global.Tlm_pipe); 191 | if (status != CFE_SUCCESS) 192 | CFE_EVS_SendEvent(TO_LAB_REMOVEPKT_ERR_EID, CFE_EVS_EventType_ERROR, 193 | "L%d TO Can't Unsubscribe to Stream 0x%x, status %i", __LINE__, 194 | (unsigned int)CFE_SB_MsgIdToValue(pCmd->Stream), (int)status); 195 | else 196 | CFE_EVS_SendEvent(TO_LAB_REMOVEPKT_INF_EID, CFE_EVS_EventType_INFORMATION, "L%d TO RemovePkt 0x%x", __LINE__, 197 | (unsigned int)CFE_SB_MsgIdToValue(pCmd->Stream)); 198 | ++TO_LAB_Global.HkTlm.Payload.CommandCounter; 199 | return CFE_SUCCESS; 200 | } 201 | 202 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 203 | /* */ 204 | /* TO_LAB_RemoveAll() -- Remove All Packets */ 205 | /* */ 206 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 207 | CFE_Status_t TO_LAB_RemoveAllCmd(const TO_LAB_RemoveAllCmd_t *data) 208 | { 209 | int32 status; 210 | int i; 211 | TO_LAB_Sub_t *SubEntry; 212 | 213 | SubEntry = TO_LAB_Global.SubsTblPtr->Subs; 214 | for (i = 0; i < TO_LAB_MAX_SUBSCRIPTIONS; i++) 215 | { 216 | if (CFE_SB_IsValidMsgId(SubEntry->Stream)) 217 | { 218 | status = CFE_SB_Unsubscribe(SubEntry->Stream, TO_LAB_Global.Tlm_pipe); 219 | 220 | if (status != CFE_SUCCESS) 221 | CFE_EVS_SendEvent(TO_LAB_REMOVEALLPTKS_ERR_EID, CFE_EVS_EventType_ERROR, 222 | "L%d TO Can't Unsubscribe to stream 0x%x status %i", __LINE__, 223 | (unsigned int)CFE_SB_MsgIdToValue(SubEntry->Stream), (int)status); 224 | } 225 | } 226 | 227 | CFE_EVS_SendEvent(TO_LAB_REMOVEALLPKTS_INF_EID, CFE_EVS_EventType_INFORMATION, 228 | "L%d TO Unsubscribed to all Commands and Telemetry", __LINE__); 229 | 230 | ++TO_LAB_Global.HkTlm.Payload.CommandCounter; 231 | return CFE_SUCCESS; 232 | } 233 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /fsw/src/to_lab_app.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 | * This file contains the source code for the TO lab application 22 | */ 23 | 24 | #include "cfe.h" 25 | #include "cfe_config.h" 26 | 27 | #include "to_lab_app.h" 28 | #include "to_lab_encode.h" 29 | #include "to_lab_eventids.h" 30 | #include "to_lab_msgids.h" 31 | #include "to_lab_perfids.h" 32 | #include "to_lab_version.h" 33 | #include "to_lab_msg.h" 34 | #include "to_lab_tbl.h" 35 | 36 | /* 37 | ** TO Global Data Section 38 | */ 39 | TO_LAB_GlobalData_t TO_LAB_Global; 40 | 41 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 42 | /* */ 43 | /* TO_LAB_AppMain() -- Application entry point and main process loop */ 44 | /* */ 45 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 46 | void TO_LAB_AppMain(void) 47 | { 48 | uint32 RunStatus = CFE_ES_RunStatus_APP_RUN; 49 | CFE_Status_t status; 50 | 51 | CFE_ES_PerfLogEntry(TO_LAB_MAIN_TASK_PERF_ID); 52 | 53 | status = TO_LAB_init(); 54 | 55 | if (status != CFE_SUCCESS) 56 | { 57 | /* 58 | ** Set request to terminate main loop... 59 | */ 60 | RunStatus = CFE_ES_RunStatus_APP_ERROR; 61 | } 62 | 63 | /* 64 | ** TO RunLoop 65 | */ 66 | while (CFE_ES_RunLoop(&RunStatus) == true) 67 | { 68 | CFE_ES_PerfLogExit(TO_LAB_MAIN_TASK_PERF_ID); 69 | 70 | OS_TaskDelay(TO_LAB_TASK_MSEC); 71 | 72 | CFE_ES_PerfLogEntry(TO_LAB_MAIN_TASK_PERF_ID); 73 | 74 | TO_LAB_forward_telemetry(); 75 | 76 | TO_LAB_process_commands(); 77 | } 78 | 79 | CFE_ES_ExitApp(RunStatus); 80 | } 81 | 82 | /* 83 | ** TO delete callback function. 84 | ** This function will be called in the event that the TO app is killed. 85 | ** It will close the network socket for TO 86 | */ 87 | void TO_LAB_delete_callback(void) 88 | { 89 | OS_printf("TO delete callback -- Closing TO Network socket.\n"); 90 | if (TO_LAB_Global.downlink_on) 91 | { 92 | OS_close(TO_LAB_Global.TLMsockid); 93 | } 94 | } 95 | 96 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 97 | /* */ 98 | /* TO_LAB_init() -- TO initialization */ 99 | /* */ 100 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 101 | CFE_Status_t TO_LAB_init(void) 102 | { 103 | CFE_Status_t status; 104 | char PipeName[16]; 105 | uint16 PipeDepth; 106 | uint16 i; 107 | char ToTlmPipeName[16]; 108 | uint16 ToTlmPipeDepth; 109 | void *TblPtr; 110 | TO_LAB_Sub_t *SubEntry; 111 | char VersionString[TO_LAB_CFG_MAX_VERSION_STR_LEN]; 112 | 113 | /* Zero out the global data structure */ 114 | memset(&TO_LAB_Global, 0, sizeof(TO_LAB_Global)); 115 | 116 | TO_LAB_Global.downlink_on = false; 117 | PipeDepth = TO_LAB_CMD_PIPE_DEPTH; 118 | strcpy(PipeName, "TO_LAB_CMD_PIPE"); 119 | ToTlmPipeDepth = TO_LAB_TLM_PIPE_DEPTH; 120 | strcpy(ToTlmPipeName, "TO_LAB_TLM_PIPE"); 121 | 122 | /* 123 | ** Register with EVS 124 | */ 125 | status = CFE_EVS_Register(NULL, 0, CFE_EVS_EventFilter_BINARY); 126 | if (status != CFE_SUCCESS) 127 | { 128 | CFE_ES_WriteToSysLog("TO_LAB: Error registering for Event Services, RC = 0x%08X\n", (unsigned int)status); 129 | } 130 | 131 | if (status == CFE_SUCCESS) 132 | { 133 | /* 134 | ** Initialize housekeeping packet (clear user data area)... 135 | */ 136 | CFE_MSG_Init(CFE_MSG_PTR(TO_LAB_Global.HkTlm.TelemetryHeader), CFE_SB_ValueToMsgId(TO_LAB_HK_TLM_MID), 137 | sizeof(TO_LAB_Global.HkTlm)); 138 | 139 | status = CFE_TBL_Register(&TO_LAB_Global.SubsTblHandle, "TO_LAB_Subs", sizeof(TO_LAB_Subs_t), 140 | CFE_TBL_OPT_DEFAULT, NULL); 141 | 142 | if (status != CFE_SUCCESS) 143 | { 144 | CFE_EVS_SendEvent(TO_LAB_TBL_ERR_EID, CFE_EVS_EventType_ERROR, "L%d TO Can't register table status %i", 145 | __LINE__, (int)status); 146 | } 147 | } 148 | 149 | if (status == CFE_SUCCESS) 150 | { 151 | status = CFE_TBL_Load(TO_LAB_Global.SubsTblHandle, CFE_TBL_SRC_FILE, "/cf/to_lab_sub.tbl"); 152 | 153 | if (status != CFE_SUCCESS) 154 | { 155 | CFE_EVS_SendEvent(TO_LAB_TBL_ERR_EID, CFE_EVS_EventType_ERROR, "L%d TO Can't load table status %i", 156 | __LINE__, (int)status); 157 | } 158 | } 159 | 160 | if (status == CFE_SUCCESS) 161 | { 162 | status = CFE_TBL_GetAddress((void **)&TblPtr, TO_LAB_Global.SubsTblHandle); 163 | 164 | if (status != CFE_SUCCESS && status != CFE_TBL_INFO_UPDATED) 165 | { 166 | CFE_EVS_SendEvent(TO_LAB_TBL_ERR_EID, CFE_EVS_EventType_ERROR, "L%d TO Can't get table addr status %i", 167 | __LINE__, (int)status); 168 | } 169 | } 170 | 171 | if (status == CFE_SUCCESS || status == CFE_TBL_INFO_UPDATED) 172 | { 173 | TO_LAB_Global.SubsTblPtr = TblPtr; /* Save returned address */ 174 | 175 | /* Subscribe to my commands */ 176 | status = CFE_SB_CreatePipe(&TO_LAB_Global.Cmd_pipe, PipeDepth, PipeName); 177 | if (status != CFE_SUCCESS) 178 | { 179 | CFE_EVS_SendEvent(TO_LAB_CR_PIPE_ERR_EID, CFE_EVS_EventType_ERROR, "L%d TO Can't create cmd pipe status %i", 180 | __LINE__, (int)status); 181 | } 182 | } 183 | 184 | if (status == CFE_SUCCESS) 185 | { 186 | 187 | CFE_SB_Subscribe(CFE_SB_ValueToMsgId(TO_LAB_CMD_MID), TO_LAB_Global.Cmd_pipe); 188 | CFE_SB_Subscribe(CFE_SB_ValueToMsgId(TO_LAB_SEND_HK_MID), TO_LAB_Global.Cmd_pipe); 189 | 190 | /* Create TO TLM pipe */ 191 | status = CFE_SB_CreatePipe(&TO_LAB_Global.Tlm_pipe, ToTlmPipeDepth, ToTlmPipeName); 192 | if (status != CFE_SUCCESS) 193 | { 194 | CFE_EVS_SendEvent(TO_LAB_TLMPIPE_ERR_EID, CFE_EVS_EventType_ERROR, "L%d TO Can't create Tlm pipe status %i", 195 | __LINE__, (int)status); 196 | } 197 | } 198 | 199 | if (status == CFE_SUCCESS) 200 | { 201 | /* Subscriptions for TLM pipe*/ 202 | SubEntry = TO_LAB_Global.SubsTblPtr->Subs; 203 | for (i = 0; i < TO_LAB_MAX_SUBSCRIPTIONS; i++) 204 | { 205 | if (!CFE_SB_IsValidMsgId(SubEntry->Stream)) 206 | { 207 | /* Only process until invalid MsgId is found*/ 208 | break; 209 | } 210 | 211 | status = CFE_SB_SubscribeEx(SubEntry->Stream, TO_LAB_Global.Tlm_pipe, SubEntry->Flags, SubEntry->BufLimit); 212 | if (status != CFE_SUCCESS) 213 | { 214 | CFE_EVS_SendEvent(TO_LAB_SUBSCRIBE_ERR_EID, CFE_EVS_EventType_ERROR, 215 | "L%d TO Can't subscribe to stream 0x%x status %i", __LINE__, 216 | (unsigned int)CFE_SB_MsgIdToValue(SubEntry->Stream), (int)status); 217 | } 218 | 219 | ++SubEntry; 220 | } 221 | 222 | CFE_Config_GetVersionString(VersionString, TO_LAB_CFG_MAX_VERSION_STR_LEN, "TO Lab", TO_LAB_VERSION, 223 | TO_LAB_BUILD_CODENAME, TO_LAB_LAST_OFFICIAL); 224 | 225 | CFE_EVS_SendEvent(TO_LAB_INIT_INF_EID, CFE_EVS_EventType_INFORMATION, 226 | "TO Lab Initialized.%s, Awaiting enable command.", VersionString); 227 | } 228 | 229 | /* 230 | ** Install the delete handler 231 | */ 232 | OS_TaskInstallDeleteHandler(&TO_LAB_delete_callback); 233 | 234 | return status; 235 | } 236 | 237 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 238 | /* */ 239 | /* TO_LAB_process_commands() -- Process command pipe message */ 240 | /* */ 241 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 242 | void TO_LAB_process_commands(void) 243 | { 244 | CFE_SB_Buffer_t *SBBufPtr; 245 | CFE_Status_t Status; 246 | 247 | /* Exit command processing loop if no message received. */ 248 | while (1) 249 | { 250 | Status = CFE_SB_ReceiveBuffer(&SBBufPtr, TO_LAB_Global.Cmd_pipe, CFE_SB_POLL); 251 | if (Status != CFE_SUCCESS) 252 | { 253 | break; 254 | } 255 | 256 | TO_LAB_TaskPipe(SBBufPtr); 257 | } 258 | } 259 | 260 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 261 | /* */ 262 | /* TO_LAB_openTLM() -- Open TLM */ 263 | /* */ 264 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 265 | void TO_LAB_openTLM(void) 266 | { 267 | int32 status; 268 | 269 | status = OS_SocketOpen(&TO_LAB_Global.TLMsockid, OS_SocketDomain_INET, OS_SocketType_DATAGRAM); 270 | if (status != OS_SUCCESS) 271 | { 272 | CFE_EVS_SendEvent(TO_LAB_TLMOUTSOCKET_ERR_EID, CFE_EVS_EventType_ERROR, "L%d, TO TLM socket error: %d", 273 | __LINE__, (int)status); 274 | } 275 | 276 | /*---------------- Add static arp entries ----------------*/ 277 | } 278 | 279 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 280 | /* */ 281 | /* TO_LAB_forward_telemetry() -- Forward telemetry */ 282 | /* */ 283 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 284 | void TO_LAB_forward_telemetry(void) 285 | { 286 | OS_SockAddr_t d_addr; 287 | int32 OsStatus; 288 | CFE_Status_t CfeStatus; 289 | CFE_SB_Buffer_t *SBBufPtr; 290 | const void *NetBufPtr; 291 | size_t NetBufSize; 292 | uint32 PktCount = 0; 293 | 294 | OS_SocketAddrInit(&d_addr, OS_SocketDomain_INET); 295 | OS_SocketAddrSetPort(&d_addr, TO_LAB_TLM_PORT); 296 | OS_SocketAddrFromString(&d_addr, TO_LAB_Global.tlm_dest_IP); 297 | OsStatus = 0; 298 | 299 | do 300 | { 301 | CfeStatus = CFE_SB_ReceiveBuffer(&SBBufPtr, TO_LAB_Global.Tlm_pipe, TO_LAB_TLM_PIPE_TIMEOUT); 302 | 303 | if ((CfeStatus == CFE_SUCCESS) && (TO_LAB_Global.suppress_sendto == false)) 304 | { 305 | OsStatus = OS_SUCCESS; 306 | 307 | if (TO_LAB_Global.downlink_on == true) 308 | { 309 | CFE_ES_PerfLogEntry(TO_LAB_SOCKET_SEND_PERF_ID); 310 | 311 | CfeStatus = TO_LAB_EncodeOutputMessage(SBBufPtr, &NetBufPtr, &NetBufSize); 312 | 313 | if (CfeStatus != CFE_SUCCESS) 314 | { 315 | CFE_EVS_SendEvent(TO_LAB_ENCODE_ERR_EID, CFE_EVS_EventType_ERROR, "Error packing output: %d\n", 316 | (int)CfeStatus); 317 | } 318 | else 319 | { 320 | OsStatus = OS_SocketSendTo(TO_LAB_Global.TLMsockid, NetBufPtr, NetBufSize, &d_addr); 321 | } 322 | 323 | CFE_ES_PerfLogExit(TO_LAB_SOCKET_SEND_PERF_ID); 324 | } 325 | 326 | if (OsStatus < 0) 327 | { 328 | CFE_EVS_SendEvent(TO_LAB_TLMOUTSTOP_ERR_EID, CFE_EVS_EventType_ERROR, 329 | "L%d TO sendto error %d. Tlm output suppressed\n", __LINE__, (int)OsStatus); 330 | TO_LAB_Global.suppress_sendto = true; 331 | } 332 | } 333 | /* If CFE_SB_status != CFE_SUCCESS, then no packet was received from CFE_SB_ReceiveBuffer() */ 334 | 335 | PktCount++; 336 | } while (CfeStatus == CFE_SUCCESS && PktCount < TO_LAB_MAX_TLM_PKTS); 337 | } 338 | 339 | /************************/ 340 | /* End of File Comment */ 341 | /************************/ 342 | --------------------------------------------------------------------------------