From 4d8fa843d39bdfb740389805bd72f4c19dc4377b Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Wed, 25 Oct 2023 10:03:25 -0400 Subject: [PATCH] Fix #166, reorganize source files Organize source files into a directory and naming pattern that is compliant with the CFE current recommended practice. Configurable items are moved to the respective header files and documentation is added to indicate what they do. --- CMakeLists.txt | 7 +- arch_build.cmake | 27 ++ config/default_to_lab_fcncodes.h | 46 +++ config/default_to_lab_interface_cfg.h | 45 +++ config/default_to_lab_internal_cfg.h | 49 +++ config/default_to_lab_mission_cfg.h | 36 ++ config/default_to_lab_msg.h | 38 ++ config/default_to_lab_msgdefs.h | 69 ++++ .../default_to_lab_msgids.h | 2 +- config/default_to_lab_msgstruct.h | 107 ++++++ .../default_to_lab_perfids.h | 0 config/default_to_lab_platform_cfg.h | 41 ++ config/default_to_lab_tbl.h | 33 ++ config/default_to_lab_tbldefs.h | 48 +++ config/default_to_lab_tblstruct.h | 50 +++ .../to_lab_events.h => inc/to_lab_eventids.h} | 4 +- fsw/src/to_lab_app.c | 358 ++---------------- fsw/src/to_lab_app.h | 49 ++- fsw/src/to_lab_cmds.c | 221 +++++++++++ fsw/src/to_lab_cmds.h | 47 +++ fsw/src/to_lab_dispatch.c | 104 +++++ .../to_lab_dispatch.h} | 28 +- fsw/src/to_lab_msg.h | 148 -------- fsw/tables/to_lab_sub.c | 4 +- mission_build.cmake | 51 +++ 25 files changed, 1093 insertions(+), 519 deletions(-) create mode 100644 arch_build.cmake create mode 100644 config/default_to_lab_fcncodes.h create mode 100644 config/default_to_lab_interface_cfg.h create mode 100644 config/default_to_lab_internal_cfg.h create mode 100644 config/default_to_lab_mission_cfg.h create mode 100644 config/default_to_lab_msg.h create mode 100644 config/default_to_lab_msgdefs.h rename fsw/platform_inc/to_lab_msgids.h => config/default_to_lab_msgids.h (97%) create mode 100644 config/default_to_lab_msgstruct.h rename fsw/mission_inc/to_lab_perfids.h => config/default_to_lab_perfids.h (100%) create mode 100644 config/default_to_lab_platform_cfg.h create mode 100644 config/default_to_lab_tbl.h create mode 100644 config/default_to_lab_tbldefs.h create mode 100644 config/default_to_lab_tblstruct.h rename fsw/{src/to_lab_events.h => inc/to_lab_eventids.h} (97%) create mode 100644 fsw/src/to_lab_cmds.c create mode 100644 fsw/src/to_lab_cmds.h create mode 100644 fsw/src/to_lab_dispatch.c rename fsw/{platform_inc/to_lab_sub_table.h => src/to_lab_dispatch.h} (71%) delete mode 100644 fsw/src/to_lab_msg.h create mode 100644 mission_build.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index f3fa9a8..bb68567 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,13 +18,12 @@ endforeach() set(APP_SRC_FILES fsw/src/to_lab_app.c + fsw/src/to_lab_cmds.c + fsw/src/to_lab_dispatch.c ) # Create the app module add_cfe_app(to_lab ${APP_SRC_FILES}) add_cfe_tables(to_lab fsw/tables/to_lab_sub.c) -target_include_directories(to_lab PUBLIC - fsw/mission_inc - fsw/platform_inc -) +target_include_directories(to_lab PUBLIC fsw/inc) diff --git a/arch_build.cmake b/arch_build.cmake new file mode 100644 index 0000000..306476b --- /dev/null +++ b/arch_build.cmake @@ -0,0 +1,27 @@ +########################################################### +# +# TO_LAB platform build setup +# +# This file is evaluated as part of the "prepare" stage +# and can be used to set up prerequisites for the build, +# such as generating header files +# +########################################################### + +# The list of header files that control the TO_LAB configuration +set(TO_LAB_PLATFORM_CONFIG_FILE_LIST + to_lab_internal_cfg.h + to_lab_platform_cfg.h + to_lab_perfids.h + to_lab_msgids.h +) + +# Create wrappers around the all the config header files +# This makes them individually overridable by the missions, without modifying +# the distribution default copies +foreach(TO_LAB_CFGFILE ${TO_LAB_PLATFORM_CONFIG_FILE_LIST}) + generate_config_includefile( + FILE_NAME "${TO_LAB_CFGFILE}" + FALLBACK_FILE "${CMAKE_CURRENT_LIST_DIR}/config/default_${TO_LAB_CFGFILE}" + ) +endforeach() diff --git a/config/default_to_lab_fcncodes.h b/config/default_to_lab_fcncodes.h new file mode 100644 index 0000000..686ab3e --- /dev/null +++ b/config/default_to_lab_fcncodes.h @@ -0,0 +1,46 @@ +/************************************************************************ + * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes” + * + * Copyright (c) 2020 United States Government as represented by the + * Administrator of the National Aeronautics and Space Administration. + * All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. You may obtain + * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ************************************************************************/ + +/** + * @file + * Specification for the TO_LAB command function codes + * + * @note + * This file should be strictly limited to the command/function code (CC) + * macro definitions. Other definitions such as enums, typedefs, or other + * macros should be placed in the msgdefs.h or msg.h files. + */ +#ifndef TO_LAB_FCNCODES_H +#define TO_LAB_FCNCODES_H + +/************************************************************************ + * Macro Definitions + ************************************************************************/ + +/* +** TO_LAB command codes +*/ +#define TO_LAB_NOOP_CC 0 /* no-op command */ +#define TO_LAB_RESET_STATUS_CC 1 /* reset status */ +#define TO_LAB_ADD_PKT_CC 2 /* add packet */ +#define TO_LAB_SEND_DATA_TYPES_CC 3 /* send data types */ +#define TO_LAB_REMOVE_PKT_CC 4 /* remove packet */ +#define TO_LAB_REMOVE_ALL_PKT_CC 5 /* remove all packet */ +#define TO_LAB_OUTPUT_ENABLE_CC 6 /* output enable */ + +#endif diff --git a/config/default_to_lab_interface_cfg.h b/config/default_to_lab_interface_cfg.h new file mode 100644 index 0000000..210bdfd --- /dev/null +++ b/config/default_to_lab_interface_cfg.h @@ -0,0 +1,45 @@ +/************************************************************************ + * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes” + * + * Copyright (c) 2020 United States Government as represented by the + * Administrator of the National Aeronautics and Space Administration. + * All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. You may obtain + * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ************************************************************************/ + +/** + * @file + * TO_LAB Application Public Definitions + * + * This provides default values for configurable items that affect + * the interface(s) of this module. This includes the CMD/TLM message + * interface, tables definitions, and any other data products that + * serve to exchange information with other entities. + * + * @note This file may be overridden/superceded by mission-provided defintions + * either by overriding this header or by generating definitions from a command/data + * dictionary tool. + */ +#ifndef TO_LAB_INTERFACE_CFG_H +#define TO_LAB_INTERFACE_CFG_H + +/** + * @brief The base UDP port number that TO_LAB will send to + */ +#define TO_LAB_TLM_PORT 1235 + +/** + * @brief The maximum number of subscriptions that TO_LAB can subscribe to + */ +#define TO_LAB_MAX_SUBSCRIPTIONS 32 + +#endif diff --git a/config/default_to_lab_internal_cfg.h b/config/default_to_lab_internal_cfg.h new file mode 100644 index 0000000..99f7e68 --- /dev/null +++ b/config/default_to_lab_internal_cfg.h @@ -0,0 +1,49 @@ +/************************************************************************ + * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes” + * + * Copyright (c) 2020 United States Government as represented by the + * Administrator of the National Aeronautics and Space Administration. + * All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. You may obtain + * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ************************************************************************/ + +/** + * @file + * TO_LAB Application Private Config Definitions + * + * This provides default values for configurable items that are internal + * to this module and do NOT affect the interface(s) of this module. Changes + * to items in this file only affect the local module and will be transparent + * to external entities that are using the public interface(s). + * + * @note This file may be overridden/superceded by mission-provided defintions + * either by overriding this header or by generating definitions from a command/data + * dictionary tool. + */ +#ifndef TO_LAB_INTERNAL_CFG_H +#define TO_LAB_INTERNAL_CFG_H + +/*****************************************************************************/ + +#define TO_LAB_TASK_MSEC 500 /* run at 2 Hz */ + +/** + * Depth of pipe for commands to the TO_LAB application itself + */ +#define TO_LAB_CMD_PIPE_DEPTH 8 + +/** + * Depth of pipe for telemetry forwarded through the TO_LAB application + */ +#define TO_LAB_TLM_PIPE_DEPTH OS_QUEUE_MAX_DEPTH + +#endif diff --git a/config/default_to_lab_mission_cfg.h b/config/default_to_lab_mission_cfg.h new file mode 100644 index 0000000..2a1b0f7 --- /dev/null +++ b/config/default_to_lab_mission_cfg.h @@ -0,0 +1,36 @@ +/************************************************************************ + * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes” + * + * Copyright (c) 2020 United States Government as represented by the + * Administrator of the National Aeronautics and Space Administration. + * All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. You may obtain + * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ************************************************************************/ + +/** + * @file + * + * TO_LAB Application Mission Configuration Header File + * + * This is a compatibility header for the "mission_cfg.h" file that has + * traditionally provided public config definitions for each CFS app. + * + * @note This file may be overridden/superceded by mission-provided defintions + * either by overriding this header or by generating definitions from a command/data + * dictionary tool. + */ +#ifndef TO_LAB_MISSION_CFG_H +#define TO_LAB_MISSION_CFG_H + +#include "to_lab_interface_cfg.h" + +#endif diff --git a/config/default_to_lab_msg.h b/config/default_to_lab_msg.h new file mode 100644 index 0000000..3f4999d --- /dev/null +++ b/config/default_to_lab_msg.h @@ -0,0 +1,38 @@ +/************************************************************************ + * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes” + * + * Copyright (c) 2020 United States Government as represented by the + * Administrator of the National Aeronautics and Space Administration. + * All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. You may obtain + * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ************************************************************************/ + +/** + * @file + * Specification for the TO_LAB command and telemetry + * message data types. + * + * This is a compatibility header for the "to_lab_msg.h" file that has + * traditionally provided the message definitions for cFS apps. + * + * @note This file may be overridden/superceded by mission-provided defintions + * either by overriding this header or by generating definitions from a command/data + * dictionary tool. + */ +#ifndef TO_LAB_MSG_H +#define TO_LAB_MSG_H + +#include "to_lab_interface_cfg.h" +#include "to_lab_msgdefs.h" +#include "to_lab_msgstruct.h" + +#endif diff --git a/config/default_to_lab_msgdefs.h b/config/default_to_lab_msgdefs.h new file mode 100644 index 0000000..b614eb7 --- /dev/null +++ b/config/default_to_lab_msgdefs.h @@ -0,0 +1,69 @@ +/************************************************************************ + * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes” + * + * Copyright (c) 2020 United States Government as represented by the + * Administrator of the National Aeronautics and Space Administration. + * All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. You may obtain + * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ************************************************************************/ + +/** + * @file + * Specification for the TO_LAB command and telemetry + * message constant definitions. + * + * For TO_LAB this is only the function/command code definitions + */ +#ifndef TO_LAB_MSGDEFS_H +#define TO_LAB_MSGDEFS_H + +#include "common_types.h" +#include "cfe_sb_extern_typedefs.h" +#include "to_lab_fcncodes.h" + +typedef struct +{ + uint8 CommandCounter; + uint8 CommandErrorCounter; + uint8 spareToAlign[2]; +} TO_LAB_HkTlm_Payload_t; + +typedef struct +{ + uint16 synch; + uint8 bl1, bl2; /* boolean */ + int8 b1, b2, b3, b4; + int16 w1, w2; + int32 dw1, dw2; + float f1, f2; + double df1, df2; + char str[10]; +} TO_LAB_DataTypes_Payload_t; + +typedef struct +{ + CFE_SB_MsgId_t Stream; + CFE_SB_Qos_t Flags; + uint8 BufLimit; +} TO_LAB_AddPacket_Payload_t; + +typedef struct +{ + CFE_SB_MsgId_t Stream; +} TO_LAB_RemovePacket_Payload_t; + +typedef struct +{ + char dest_IP[16]; +} TO_LAB_EnableOutput_Payload_t; + +#endif diff --git a/fsw/platform_inc/to_lab_msgids.h b/config/default_to_lab_msgids.h similarity index 97% rename from fsw/platform_inc/to_lab_msgids.h rename to config/default_to_lab_msgids.h index 4c3609c..1efc360 100644 --- a/fsw/platform_inc/to_lab_msgids.h +++ b/config/default_to_lab_msgids.h @@ -18,7 +18,7 @@ /** * @file - * Define TO Lab Message IDs + * TO_LAB Application Message IDs */ #ifndef TO_LAB_MSGIDS_H #define TO_LAB_MSGIDS_H diff --git a/config/default_to_lab_msgstruct.h b/config/default_to_lab_msgstruct.h new file mode 100644 index 0000000..1550186 --- /dev/null +++ b/config/default_to_lab_msgstruct.h @@ -0,0 +1,107 @@ +/************************************************************************ + * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes” + * + * Copyright (c) 2020 United States Government as represented by the + * Administrator of the National Aeronautics and Space Administration. + * All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. You may obtain + * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ************************************************************************/ + +/** + * @file + * Specification for the TO_LAB command and telemetry + * message data types. + * + * @note + * Constants and enumerated types related to these message structures + * are defined in to_lab_msgdefs.h. + */ +#ifndef TO_LAB_MSGSTRUCT_H +#define TO_LAB_MSGSTRUCT_H + +/************************************************************************ + * Includes + ************************************************************************/ + +#include "to_lab_mission_cfg.h" +#include "to_lab_msgdefs.h" +#include "cfe_msg_hdr.h" + +/******************************************************************************/ + +typedef struct +{ + CFE_MSG_TelemetryHeader_t TelemetryHeader; /**< \brief Telemetry header */ + TO_LAB_HkTlm_Payload_t Payload; /**< \brief Telemetry payload */ +} TO_LAB_HkTlm_t; + +/******************************************************************************/ + +typedef struct +{ + CFE_MSG_TelemetryHeader_t TelemetryHeader; /**< \brief Telemetry header */ + TO_LAB_DataTypes_Payload_t Payload; /**< \brief Telemetry payload */ +} TO_LAB_DataTypesTlm_t; + +/******************************************************************************/ + +/* + * The following commands do not have any payload, + * but should still "reserve" a unique structure type to + * employ a consistent handler pattern. + * + * This matches the pattern in CFE core and other modules. + */ +typedef struct +{ + CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command header */ +} TO_LAB_SendHkCmd_t; + +typedef struct +{ + CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command header */ +} TO_LAB_NoopCmd_t; + +typedef struct +{ + CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command header */ +} TO_LAB_ResetCountersCmd_t; + +typedef struct +{ + CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command header */ +} TO_LAB_RemoveAllCmd_t; + +typedef struct +{ + CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command header */ +} TO_LAB_SendDataTypesCmd_t; + +typedef struct +{ + CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command header */ + TO_LAB_AddPacket_Payload_t Payload; /**< \brief Command payload */ +} TO_LAB_AddPacketCmd_t; + +typedef struct +{ + CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command header */ + TO_LAB_RemovePacket_Payload_t Payload; /**< \brief Command payload */ +} TO_LAB_RemovePacketCmd_t; + +typedef struct +{ + CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command header */ + TO_LAB_EnableOutput_Payload_t Payload; /**< \brief Command payload */ +} TO_LAB_EnableOutputCmd_t; + +#endif /* TO_LAB_MSGSTRUCT_H */ diff --git a/fsw/mission_inc/to_lab_perfids.h b/config/default_to_lab_perfids.h similarity index 100% rename from fsw/mission_inc/to_lab_perfids.h rename to config/default_to_lab_perfids.h diff --git a/config/default_to_lab_platform_cfg.h b/config/default_to_lab_platform_cfg.h new file mode 100644 index 0000000..0e16e5f --- /dev/null +++ b/config/default_to_lab_platform_cfg.h @@ -0,0 +1,41 @@ +/************************************************************************ + * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes” + * + * Copyright (c) 2020 United States Government as represented by the + * Administrator of the National Aeronautics and Space Administration. + * All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. You may obtain + * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ************************************************************************/ + +/** + * @file + * + * TO_LAB Application Platform Configuration Header File + * + * This is a compatibility header for the "platform_cfg.h" file that has + * traditionally provided both public and private config definitions + * for each CFS app. + * + * These definitions are now provided in two separate files, one for + * the public/mission scope and one for internal scope. + * + * @note This file may be overridden/superceded by mission-provided defintions + * either by overriding this header or by generating definitions from a command/data + * dictionary tool. + */ +#ifndef TO_LAB_PLATFORM_CFG_H +#define TO_LAB_PLATFORM_CFG_H + +#include "to_lab_mission_cfg.h" +#include "to_lab_internal_cfg.h" + +#endif diff --git a/config/default_to_lab_tbl.h b/config/default_to_lab_tbl.h new file mode 100644 index 0000000..521116a --- /dev/null +++ b/config/default_to_lab_tbl.h @@ -0,0 +1,33 @@ +/************************************************************************ + * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes” + * + * Copyright (c) 2020 United States Government as represented by the + * Administrator of the National Aeronautics and Space Administration. + * All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. You may obtain + * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ************************************************************************/ + +/** + * @file + * Specification for the TO_LAB table structures + * + * @note + * Constants and enumerated types related to these table structures + * are defined in to_lab_tbldefs.h. + */ +#ifndef TO_LAB_TBL_H +#define TO_LAB_TBL_H + +#include "to_lab_tbldefs.h" +#include "to_lab_tblstruct.h" + +#endif diff --git a/config/default_to_lab_tbldefs.h b/config/default_to_lab_tbldefs.h new file mode 100644 index 0000000..4aa1510 --- /dev/null +++ b/config/default_to_lab_tbldefs.h @@ -0,0 +1,48 @@ +/************************************************************************ + * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes” + * + * Copyright (c) 2020 United States Government as represented by the + * Administrator of the National Aeronautics and Space Administration. + * All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. You may obtain + * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ************************************************************************/ + +/** + * @file + * Specification for the TO_LAB table related + * constant definitions. + * + * @note + * These Macro definitions have been put in this file (instead of + * to_lab_tbl.h). DO NOT PUT ANY TYPEDEFS OR + * STRUCTURE DEFINITIONS IN THIS FILE! + * ADD THEM TO to_lab_tbl.h IF NEEDED! + */ +#ifndef TO_LAB_TBLDEFS_H +#define TO_LAB_TBLDEFS_H + +#include "common_types.h" +#include "to_lab_mission_cfg.h" +#include "cfe_sb_extern_typedefs.h" + +/************************************************************************ + * Macro Definitions + ************************************************************************/ + +typedef struct +{ + CFE_SB_MsgId_t Stream; + CFE_SB_Qos_t Flags; + uint16 BufLimit; +} TO_LAB_Sub_t; + +#endif diff --git a/config/default_to_lab_tblstruct.h b/config/default_to_lab_tblstruct.h new file mode 100644 index 0000000..17e3ba1 --- /dev/null +++ b/config/default_to_lab_tblstruct.h @@ -0,0 +1,50 @@ +/************************************************************************ + * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes” + * + * Copyright (c) 2020 United States Government as represented by the + * Administrator of the National Aeronautics and Space Administration. + * All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. You may obtain + * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ************************************************************************/ + +/** + * @file + * Specification for the TO_LAB table structures + * + * Provides default definitions for TO_LAB table structures + * + * @note This file may be overridden/superceded by mission-provided defintions + * either by overriding this header or by generating definitions from a command/data + * dictionary tool. + */ +#ifndef TO_LAB_TBLSTRUCT_H +#define TO_LAB_TBLSTRUCT_H + +/************************************************************************* + * Includes + *************************************************************************/ +#include "to_lab_tbldefs.h" + +/************************************************************************ + * Macro Definitions + ************************************************************************/ + +/************************************************************************* + * Type Definitions + *************************************************************************/ + +typedef struct +{ + TO_LAB_Sub_t Subs[TO_LAB_MAX_SUBSCRIPTIONS]; +} TO_LAB_Subs_t; + +#endif diff --git a/fsw/src/to_lab_events.h b/fsw/inc/to_lab_eventids.h similarity index 97% rename from fsw/src/to_lab_events.h rename to fsw/inc/to_lab_eventids.h index 44369fa..72a7ac4 100644 --- a/fsw/src/to_lab_events.h +++ b/fsw/inc/to_lab_eventids.h @@ -20,8 +20,8 @@ * @file * Define TO Lab Event messages */ -#ifndef TO_LAB_EVENTS_H -#define TO_LAB_EVENTS_H +#ifndef TO_LAB_EVENTIDS_H +#define TO_LAB_EVENTIDS_H /*****************************************************************************/ diff --git a/fsw/src/to_lab_app.c b/fsw/src/to_lab_app.c index 7a47b7e..bcb3523 100644 --- a/fsw/src/to_lab_app.c +++ b/fsw/src/to_lab_app.c @@ -21,56 +21,21 @@ * This file contains the source code for the TO lab application */ +#include "cfe.h" + #include "to_lab_app.h" -#include "to_lab_msg.h" -#include "to_lab_events.h" +#include "to_lab_eventids.h" #include "to_lab_msgids.h" #include "to_lab_perfids.h" #include "to_lab_version.h" -#include "to_lab_sub_table.h" +#include "to_lab_msg.h" +#include "to_lab_tbl.h" /* ** Global Data Section */ -typedef struct -{ - CFE_SB_PipeId_t Tlm_pipe; - CFE_SB_PipeId_t Cmd_pipe; - osal_id_t TLMsockid; - bool downlink_on; - char tlm_dest_IP[17]; - bool suppress_sendto; - - TO_LAB_HkTlm_t HkTlm; - TO_LAB_DataTypesTlm_t DataTypesTlm; -} TO_LAB_GlobalData_t; - TO_LAB_GlobalData_t TO_LAB_Global; -TO_LAB_Subs_t * TO_LAB_Subs; -CFE_TBL_Handle_t TO_SubTblHandle; - -/* -** Prototypes Section -*/ -void TO_LAB_openTLM(void); -int32 TO_LAB_init(void); -void TO_LAB_exec_local_command(CFE_SB_Buffer_t *SBBufPtr); -void TO_LAB_process_commands(void); -void TO_LAB_forward_telemetry(void); - -/* - * Individual Command Handler prototypes - */ -int32 TO_LAB_AddPacket(const TO_LAB_AddPacketCmd_t *data); -int32 TO_LAB_Noop(const TO_LAB_NoopCmd_t *data); -int32 TO_LAB_EnableOutput(const TO_LAB_EnableOutputCmd_t *data); -int32 TO_LAB_RemoveAll(const TO_LAB_RemoveAllCmd_t *data); -int32 TO_LAB_RemovePacket(const TO_LAB_RemovePacketCmd_t *data); -int32 TO_LAB_ResetCounters(const TO_LAB_ResetCountersCmd_t *data); -int32 TO_LAB_SendDataTypes(const TO_LAB_SendDataTypesCmd_t *data); -int32 TO_LAB_SendHousekeeping(const CFE_MSG_CommandHeader_t *data); - /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* */ /* TO_LAB_AppMain() -- Application entry point and main process loop */ @@ -130,12 +95,14 @@ void TO_LAB_delete_callback(void) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ int32 TO_LAB_init(void) { - int32 status; - char PipeName[16]; - uint16 PipeDepth; - uint16 i; - char ToTlmPipeName[16]; - uint16 ToTlmPipeDepth; + int32 status; + char PipeName[16]; + uint16 PipeDepth; + uint16 i; + char ToTlmPipeName[16]; + uint16 ToTlmPipeDepth; + void * TblPtr; + TO_LAB_Sub_t *SubEntry; TO_LAB_Global.downlink_on = false; PipeDepth = TO_LAB_CMD_PIPE_DEPTH; @@ -153,7 +120,8 @@ int32 TO_LAB_init(void) CFE_MSG_Init(CFE_MSG_PTR(TO_LAB_Global.HkTlm.TelemetryHeader), CFE_SB_ValueToMsgId(TO_LAB_HK_TLM_MID), sizeof(TO_LAB_Global.HkTlm)); - status = CFE_TBL_Register(&TO_SubTblHandle, "TO_LAB_Subs", sizeof(*TO_LAB_Subs), CFE_TBL_OPT_DEFAULT, NULL); + status = + CFE_TBL_Register(&TO_LAB_Global.SubsTblHandle, "TO_LAB_Subs", sizeof(TO_LAB_Subs_t), CFE_TBL_OPT_DEFAULT, NULL); if (status != CFE_SUCCESS) { @@ -162,7 +130,7 @@ int32 TO_LAB_init(void) return status; } - status = CFE_TBL_Load(TO_SubTblHandle, CFE_TBL_SRC_FILE, "/cf/to_lab_sub.tbl"); + status = CFE_TBL_Load(TO_LAB_Global.SubsTblHandle, CFE_TBL_SRC_FILE, "/cf/to_lab_sub.tbl"); if (status != CFE_SUCCESS) { @@ -171,7 +139,7 @@ int32 TO_LAB_init(void) return status; } - status = CFE_TBL_GetAddress((void *)&TO_LAB_Subs, TO_SubTblHandle); + status = CFE_TBL_GetAddress((void **)&TblPtr, TO_LAB_Global.SubsTblHandle); if (status != CFE_SUCCESS && status != CFE_TBL_INFO_UPDATED) { @@ -180,6 +148,8 @@ int32 TO_LAB_init(void) return status; } + TO_LAB_Global.SubsTblPtr = TblPtr; /* Save returned address */ + /* Subscribe to my commands */ status = CFE_SB_CreatePipe(&TO_LAB_Global.Cmd_pipe, PipeDepth, PipeName); if (status == CFE_SUCCESS) @@ -200,23 +170,24 @@ int32 TO_LAB_init(void) } /* Subscriptions for TLM pipe*/ - for (i = 0; (i < (sizeof(TO_LAB_Subs->Subs) / sizeof(TO_LAB_Subs->Subs[0]))); i++) + SubEntry = TO_LAB_Global.SubsTblPtr->Subs; + for (i = 0; i < TO_LAB_MAX_SUBSCRIPTIONS; i++) { - if (!CFE_SB_IsValidMsgId(TO_LAB_Subs->Subs[i].Stream)) + if (!CFE_SB_IsValidMsgId(SubEntry->Stream)) { /* Only process until invalid MsgId is found*/ break; } - else if (CFE_SB_IsValidMsgId(TO_LAB_Subs->Subs[i].Stream)) - { - status = CFE_SB_SubscribeEx(TO_LAB_Subs->Subs[i].Stream, TO_LAB_Global.Tlm_pipe, TO_LAB_Subs->Subs[i].Flags, - TO_LAB_Subs->Subs[i].BufLimit); - } + status = CFE_SB_SubscribeEx(SubEntry->Stream, TO_LAB_Global.Tlm_pipe, SubEntry->Flags, SubEntry->BufLimit); if (status != CFE_SUCCESS) + { CFE_EVS_SendEvent(TO_LAB_SUBSCRIBE_ERR_EID, CFE_EVS_EventType_ERROR, "L%d TO Can't subscribe to stream 0x%x status %i", __LINE__, - (unsigned int)CFE_SB_MsgIdToValue(TO_LAB_Subs->Subs[i].Stream), (int)status); + (unsigned int)CFE_SB_MsgIdToValue(SubEntry->Stream), (int)status); + } + + ++SubEntry; } /* @@ -230,31 +201,6 @@ int32 TO_LAB_init(void) return CFE_SUCCESS; } -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* TO_LAB_EnableOutput() -- TLM output enabled */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -int32 TO_LAB_EnableOutput(const TO_LAB_EnableOutputCmd_t *data) -{ - const TO_LAB_EnableOutput_Payload_t *pCmd = &data->Payload; - - (void)CFE_SB_MessageStringGet(TO_LAB_Global.tlm_dest_IP, pCmd->dest_IP, "", sizeof(TO_LAB_Global.tlm_dest_IP), - sizeof(pCmd->dest_IP)); - TO_LAB_Global.suppress_sendto = false; - CFE_EVS_SendEvent(TO_LAB_TLMOUTENA_INF_EID, CFE_EVS_EventType_INFORMATION, "TO telemetry output enabled for IP %s", - TO_LAB_Global.tlm_dest_IP); - - if (!TO_LAB_Global.downlink_on) /* Then turn it on, otherwise we will just switch destination addresses*/ - { - TO_LAB_openTLM(); - TO_LAB_Global.downlink_on = true; - } - - ++TO_LAB_Global.HkTlm.Payload.CommandCounter; - return CFE_SUCCESS; -} - /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* */ /* TO_LAB_process_commands() -- Process command pipe message */ @@ -263,177 +209,14 @@ int32 TO_LAB_EnableOutput(const TO_LAB_EnableOutputCmd_t *data) void TO_LAB_process_commands(void) { CFE_SB_Buffer_t *SBBufPtr; - CFE_SB_MsgId_t MsgId = CFE_SB_INVALID_MSG_ID; - while (1) + /* Exit command processing loop if no message received. */ + while (CFE_SB_ReceiveBuffer(&SBBufPtr, TO_LAB_Global.Cmd_pipe, CFE_SB_POLL) == CFE_SUCCESS) { - switch (CFE_SB_ReceiveBuffer(&SBBufPtr, TO_LAB_Global.Cmd_pipe, CFE_SB_POLL)) - { - case CFE_SUCCESS: - - CFE_MSG_GetMsgId(&SBBufPtr->Msg, &MsgId); - - /* For SB return statuses that imply a message: process it. */ - switch (CFE_SB_MsgIdToValue(MsgId)) - { - case TO_LAB_CMD_MID: - TO_LAB_exec_local_command(SBBufPtr); - break; - - case TO_LAB_SEND_HK_MID: - TO_LAB_SendHousekeeping((const CFE_MSG_CommandHeader_t *)SBBufPtr); - break; - - default: - CFE_EVS_SendEvent(TO_LAB_MSGID_ERR_EID, CFE_EVS_EventType_ERROR, - "L%d TO: Invalid Msg ID Rcvd 0x%x", __LINE__, - (unsigned int)CFE_SB_MsgIdToValue(MsgId)); - break; - } - break; - default: - /* Exit command processing loop if no message received. */ - return; - } + TO_LAB_TaskPipe(SBBufPtr); } } -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* TO_LAB_exec_local_command() -- Process local message */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -void TO_LAB_exec_local_command(CFE_SB_Buffer_t *SBBufPtr) -{ - CFE_MSG_FcnCode_t CommandCode = 0; - - CFE_MSG_GetFcnCode(&SBBufPtr->Msg, &CommandCode); - - switch (CommandCode) - { - case TO_LAB_NOOP_CC: - TO_LAB_Noop((const TO_LAB_NoopCmd_t *)SBBufPtr); - break; - - case TO_LAB_RESET_STATUS_CC: - TO_LAB_ResetCounters((const TO_LAB_ResetCountersCmd_t *)SBBufPtr); - break; - - case TO_LAB_SEND_DATA_TYPES_CC: - TO_LAB_SendDataTypes((const TO_LAB_SendDataTypesCmd_t *)SBBufPtr); - break; - - case TO_LAB_ADD_PKT_CC: - TO_LAB_AddPacket((const TO_LAB_AddPacketCmd_t *)SBBufPtr); - break; - - case TO_LAB_REMOVE_PKT_CC: - TO_LAB_RemovePacket((const TO_LAB_RemovePacketCmd_t *)SBBufPtr); - break; - - case TO_LAB_REMOVE_ALL_PKT_CC: - TO_LAB_RemoveAll((const TO_LAB_RemoveAllCmd_t *)SBBufPtr); - break; - - case TO_LAB_OUTPUT_ENABLE_CC: - TO_LAB_EnableOutput((const TO_LAB_EnableOutputCmd_t *)SBBufPtr); - break; - - default: - CFE_EVS_SendEvent(TO_LAB_FNCODE_ERR_EID, CFE_EVS_EventType_ERROR, - "L%d TO: Invalid Function Code Rcvd In Ground Command 0x%x", __LINE__, - (unsigned int)CommandCode); - ++TO_LAB_Global.HkTlm.Payload.CommandErrorCounter; - } -} - -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* TO_LAB_Noop() -- Noop Handler */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -int32 TO_LAB_Noop(const TO_LAB_NoopCmd_t *data) -{ - CFE_EVS_SendEvent(TO_LAB_NOOP_INF_EID, CFE_EVS_EventType_INFORMATION, "No-op command"); - ++TO_LAB_Global.HkTlm.Payload.CommandCounter; - return CFE_SUCCESS; -} - -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* TO_LAB_ResetCounters() -- Reset counters */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -int32 TO_LAB_ResetCounters(const TO_LAB_ResetCountersCmd_t *data) -{ - TO_LAB_Global.HkTlm.Payload.CommandErrorCounter = 0; - TO_LAB_Global.HkTlm.Payload.CommandCounter = 0; - return CFE_SUCCESS; -} - -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* TO_LAB_SendDataTypes() -- Output data types */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -int32 TO_LAB_SendDataTypes(const TO_LAB_SendDataTypesCmd_t *data) -{ - int16 i; - char string_variable[10] = "ABCDEFGHIJ"; - - /* initialize data types packet */ - CFE_MSG_Init(CFE_MSG_PTR(TO_LAB_Global.DataTypesTlm.TelemetryHeader), CFE_SB_ValueToMsgId(TO_LAB_DATA_TYPES_MID), - sizeof(TO_LAB_Global.DataTypesTlm)); - - CFE_SB_TimeStampMsg(CFE_MSG_PTR(TO_LAB_Global.DataTypesTlm.TelemetryHeader)); - - /* initialize the packet data */ - TO_LAB_Global.DataTypesTlm.Payload.synch = 0x6969; -#if 0 - TO_LAB_Global.DataTypesTlm.Payload.bit1 = 1; - TO_LAB_Global.DataTypesTlm.Payload.bit2 = 0; - TO_LAB_Global.DataTypesTlm.Payload.bit34 = 2; - TO_LAB_Global.DataTypesTlm.Payload.bit56 = 3; - TO_LAB_Global.DataTypesTlm.Payload.bit78 = 1; - TO_LAB_Global.DataTypesTlm.Payload.nibble1 = 0xA; - TO_LAB_Global.DataTypesTlm.Payload.nibble2 = 0x4; -#endif - TO_LAB_Global.DataTypesTlm.Payload.bl1 = false; - TO_LAB_Global.DataTypesTlm.Payload.bl2 = true; - TO_LAB_Global.DataTypesTlm.Payload.b1 = 16; - TO_LAB_Global.DataTypesTlm.Payload.b2 = 127; - TO_LAB_Global.DataTypesTlm.Payload.b3 = 0x7F; - TO_LAB_Global.DataTypesTlm.Payload.b4 = 0x45; - TO_LAB_Global.DataTypesTlm.Payload.w1 = 0x2468; - TO_LAB_Global.DataTypesTlm.Payload.w2 = 0x7FFF; - TO_LAB_Global.DataTypesTlm.Payload.dw1 = 0x12345678; - TO_LAB_Global.DataTypesTlm.Payload.dw2 = 0x87654321; - TO_LAB_Global.DataTypesTlm.Payload.f1 = 90.01; - TO_LAB_Global.DataTypesTlm.Payload.f2 = .0000045; - TO_LAB_Global.DataTypesTlm.Payload.df1 = 99.9; - TO_LAB_Global.DataTypesTlm.Payload.df2 = .4444; - - for (i = 0; i < 10; i++) - TO_LAB_Global.DataTypesTlm.Payload.str[i] = string_variable[i]; - - CFE_SB_TransmitMsg(CFE_MSG_PTR(TO_LAB_Global.DataTypesTlm.TelemetryHeader), true); - - ++TO_LAB_Global.HkTlm.Payload.CommandCounter; - return CFE_SUCCESS; -} - -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* TO_LAB_SendHousekeeping() -- HK status */ -/* Does not increment CommandCounter */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -int32 TO_LAB_SendHousekeeping(const CFE_MSG_CommandHeader_t *data) -{ - CFE_SB_TimeStampMsg(CFE_MSG_PTR(TO_LAB_Global.HkTlm.TelemetryHeader)); - CFE_SB_TransmitMsg(CFE_MSG_PTR(TO_LAB_Global.HkTlm.TelemetryHeader), true); - return CFE_SUCCESS; -} - /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* */ /* TO_LAB_openTLM() -- Open TLM */ @@ -453,83 +236,6 @@ void TO_LAB_openTLM(void) /*---------------- Add static arp entries ----------------*/ } -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* TO_LAB_AddPacket() -- Add packets */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -int32 TO_LAB_AddPacket(const TO_LAB_AddPacketCmd_t *data) -{ - const TO_LAB_AddPacket_Payload_t *pCmd = &data->Payload; - int32 status; - - status = CFE_SB_SubscribeEx(pCmd->Stream, TO_LAB_Global.Tlm_pipe, pCmd->Flags, pCmd->BufLimit); - - if (status != CFE_SUCCESS) - CFE_EVS_SendEvent(TO_LAB_ADDPKT_ERR_EID, CFE_EVS_EventType_ERROR, "L%d TO Can't subscribe 0x%x status %i", - __LINE__, (unsigned int)CFE_SB_MsgIdToValue(pCmd->Stream), (int)status); - else - CFE_EVS_SendEvent(TO_LAB_ADDPKT_INF_EID, CFE_EVS_EventType_INFORMATION, - "L%d TO AddPkt 0x%x, QoS %d.%d, limit %d", __LINE__, - (unsigned int)CFE_SB_MsgIdToValue(pCmd->Stream), pCmd->Flags.Priority, - pCmd->Flags.Reliability, pCmd->BufLimit); - - ++TO_LAB_Global.HkTlm.Payload.CommandCounter; - return CFE_SUCCESS; -} - -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* TO_LAB_RemovePacket() -- Remove Packet */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -int32 TO_LAB_RemovePacket(const TO_LAB_RemovePacketCmd_t *data) -{ - const TO_LAB_RemovePacket_Payload_t *pCmd = &data->Payload; - int32 status; - - status = CFE_SB_Unsubscribe(pCmd->Stream, TO_LAB_Global.Tlm_pipe); - if (status != CFE_SUCCESS) - CFE_EVS_SendEvent(TO_LAB_REMOVEPKT_ERR_EID, CFE_EVS_EventType_ERROR, - "L%d TO Can't Unsubscribe to Stream 0x%x, status %i", __LINE__, - (unsigned int)CFE_SB_MsgIdToValue(pCmd->Stream), (int)status); - else - CFE_EVS_SendEvent(TO_LAB_REMOVEPKT_INF_EID, CFE_EVS_EventType_INFORMATION, "L%d TO RemovePkt 0x%x", __LINE__, - (unsigned int)CFE_SB_MsgIdToValue(pCmd->Stream)); - ++TO_LAB_Global.HkTlm.Payload.CommandCounter; - return CFE_SUCCESS; -} - -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* TO_LAB_RemoveAll() -- Remove All Packets */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -int32 TO_LAB_RemoveAll(const TO_LAB_RemoveAllCmd_t *data) -{ - int32 status; - int i; - - for (i = 0; (i < (sizeof(TO_LAB_Subs->Subs) / sizeof(TO_LAB_Subs->Subs[0]))); i++) - { - if (CFE_SB_IsValidMsgId(TO_LAB_Subs->Subs[i].Stream)) - { - status = CFE_SB_Unsubscribe(TO_LAB_Subs->Subs[i].Stream, TO_LAB_Global.Tlm_pipe); - - if (status != CFE_SUCCESS) - CFE_EVS_SendEvent(TO_LAB_REMOVEALLPTKS_ERR_EID, CFE_EVS_EventType_ERROR, - "L%d TO Can't Unsubscribe to stream 0x%x status %i", __LINE__, - (unsigned int)CFE_SB_MsgIdToValue(TO_LAB_Subs->Subs[i].Stream), (int)status); - } - } - - CFE_EVS_SendEvent(TO_LAB_REMOVEALLPKTS_INF_EID, CFE_EVS_EventType_INFORMATION, - "L%d TO Unsubscribed to all Commands and Telemetry", __LINE__); - - ++TO_LAB_Global.HkTlm.Payload.CommandCounter; - return CFE_SUCCESS; -} - /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* */ /* TO_LAB_forward_telemetry() -- Forward telemetry */ @@ -544,7 +250,7 @@ void TO_LAB_forward_telemetry(void) CFE_SB_Buffer_t *SBBufPtr; OS_SocketAddrInit(&d_addr, OS_SocketDomain_INET); - OS_SocketAddrSetPort(&d_addr, cfgTLM_PORT); + OS_SocketAddrSetPort(&d_addr, TO_LAB_TLM_PORT); OS_SocketAddrFromString(&d_addr, TO_LAB_Global.tlm_dest_IP); status = 0; diff --git a/fsw/src/to_lab_app.h b/fsw/src/to_lab_app.h index 4cfb2b1..7c74661 100644 --- a/fsw/src/to_lab_app.h +++ b/fsw/src/to_lab_app.h @@ -24,40 +24,49 @@ #ifndef TO_LAB_APP_H #define TO_LAB_APP_H -#include "cfe.h" - -#include -#include -#include - #include "common_types.h" #include "osapi.h" +#include "cfe.h" -/*****************************************************************************/ +#include "to_lab_mission_cfg.h" +#include "to_lab_platform_cfg.h" +#include "to_lab_cmds.h" +#include "to_lab_dispatch.h" +#include "to_lab_msg.h" +#include "to_lab_tbl.h" -#define TO_LAB_TASK_MSEC 500 /* run at 2 Hz */ +/******************************************************************************/ -/** - * Depth of pipe for commands to the TO_LAB application itself - */ -#define TO_LAB_CMD_PIPE_DEPTH 8 +typedef struct +{ + CFE_SB_PipeId_t Tlm_pipe; + CFE_SB_PipeId_t Cmd_pipe; + osal_id_t TLMsockid; + bool downlink_on; + char tlm_dest_IP[17]; + bool suppress_sendto; -/** - * Depth of pipe for telemetry forwarded through the TO_LAB application - */ -#define TO_LAB_TLM_PIPE_DEPTH OS_QUEUE_MAX_DEPTH + TO_LAB_HkTlm_t HkTlm; + TO_LAB_DataTypesTlm_t DataTypesTlm; -#define cfgTLM_ADDR "192.168.1.81" -#define cfgTLM_PORT 1235 -#define TO_LAB_VERSION_NUM "5.1.0" + TO_LAB_Subs_t * SubsTblPtr; + CFE_TBL_Handle_t SubsTblHandle; -/******************************************************************************/ +} TO_LAB_GlobalData_t; /* ** Prototypes Section */ void TO_LAB_AppMain(void); +void TO_LAB_openTLM(void); +int32 TO_LAB_init(void); +void TO_LAB_process_commands(void); +void TO_LAB_forward_telemetry(void); + /******************************************************************************/ +/* Global State Object */ +extern TO_LAB_GlobalData_t TO_LAB_Global; + #endif diff --git a/fsw/src/to_lab_cmds.c b/fsw/src/to_lab_cmds.c new file mode 100644 index 0000000..3798a6a --- /dev/null +++ b/fsw/src/to_lab_cmds.c @@ -0,0 +1,221 @@ +/************************************************************************ + * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes” + * + * Copyright (c) 2020 United States Government as represented by the + * Administrator of the National Aeronautics and Space Administration. + * All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. You may obtain + * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ************************************************************************/ + +/** + * \file + * This file contains the source code for the TO lab application + */ + +#include "cfe.h" + +#include "to_lab_app.h" +#include "to_lab_cmds.h" +#include "to_lab_msg.h" +#include "to_lab_eventids.h" +#include "to_lab_msgids.h" + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* */ +/* TO_LAB_EnableOutput() -- TLM output enabled */ +/* */ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +int32 TO_LAB_EnableOutputCmd(const TO_LAB_EnableOutputCmd_t *data) +{ + const TO_LAB_EnableOutput_Payload_t *pCmd = &data->Payload; + + (void)CFE_SB_MessageStringGet(TO_LAB_Global.tlm_dest_IP, pCmd->dest_IP, "", sizeof(TO_LAB_Global.tlm_dest_IP), + sizeof(pCmd->dest_IP)); + TO_LAB_Global.suppress_sendto = false; + CFE_EVS_SendEvent(TO_LAB_TLMOUTENA_INF_EID, CFE_EVS_EventType_INFORMATION, "TO telemetry output enabled for IP %s", + TO_LAB_Global.tlm_dest_IP); + + if (!TO_LAB_Global.downlink_on) /* Then turn it on, otherwise we will just switch destination addresses*/ + { + TO_LAB_openTLM(); + TO_LAB_Global.downlink_on = true; + } + + ++TO_LAB_Global.HkTlm.Payload.CommandCounter; + return CFE_SUCCESS; +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* */ +/* TO_LAB_Noop() -- Noop Handler */ +/* */ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +int32 TO_LAB_NoopCmd(const TO_LAB_NoopCmd_t *data) +{ + CFE_EVS_SendEvent(TO_LAB_NOOP_INF_EID, CFE_EVS_EventType_INFORMATION, "No-op command"); + ++TO_LAB_Global.HkTlm.Payload.CommandCounter; + return CFE_SUCCESS; +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* */ +/* TO_LAB_ResetCounters() -- Reset counters */ +/* */ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +int32 TO_LAB_ResetCountersCmd(const TO_LAB_ResetCountersCmd_t *data) +{ + TO_LAB_Global.HkTlm.Payload.CommandErrorCounter = 0; + TO_LAB_Global.HkTlm.Payload.CommandCounter = 0; + return CFE_SUCCESS; +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* */ +/* TO_LAB_SendDataTypes() -- Output data types */ +/* */ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +int32 TO_LAB_SendDataTypesCmd(const TO_LAB_SendDataTypesCmd_t *data) +{ + int16 i; + char string_variable[10] = "ABCDEFGHIJ"; + + /* initialize data types packet */ + CFE_MSG_Init(CFE_MSG_PTR(TO_LAB_Global.DataTypesTlm.TelemetryHeader), CFE_SB_ValueToMsgId(TO_LAB_DATA_TYPES_MID), + sizeof(TO_LAB_Global.DataTypesTlm)); + + CFE_SB_TimeStampMsg(CFE_MSG_PTR(TO_LAB_Global.DataTypesTlm.TelemetryHeader)); + + /* initialize the packet data */ + TO_LAB_Global.DataTypesTlm.Payload.synch = 0x6969; +#if 0 + TO_LAB_Global.DataTypesTlm.Payload.bit1 = 1; + TO_LAB_Global.DataTypesTlm.Payload.bit2 = 0; + TO_LAB_Global.DataTypesTlm.Payload.bit34 = 2; + TO_LAB_Global.DataTypesTlm.Payload.bit56 = 3; + TO_LAB_Global.DataTypesTlm.Payload.bit78 = 1; + TO_LAB_Global.DataTypesTlm.Payload.nibble1 = 0xA; + TO_LAB_Global.DataTypesTlm.Payload.nibble2 = 0x4; +#endif + TO_LAB_Global.DataTypesTlm.Payload.bl1 = false; + TO_LAB_Global.DataTypesTlm.Payload.bl2 = true; + TO_LAB_Global.DataTypesTlm.Payload.b1 = 16; + TO_LAB_Global.DataTypesTlm.Payload.b2 = 127; + TO_LAB_Global.DataTypesTlm.Payload.b3 = 0x7F; + TO_LAB_Global.DataTypesTlm.Payload.b4 = 0x45; + TO_LAB_Global.DataTypesTlm.Payload.w1 = 0x2468; + TO_LAB_Global.DataTypesTlm.Payload.w2 = 0x7FFF; + TO_LAB_Global.DataTypesTlm.Payload.dw1 = 0x12345678; + TO_LAB_Global.DataTypesTlm.Payload.dw2 = 0x87654321; + TO_LAB_Global.DataTypesTlm.Payload.f1 = 90.01; + TO_LAB_Global.DataTypesTlm.Payload.f2 = .0000045; + TO_LAB_Global.DataTypesTlm.Payload.df1 = 99.9; + TO_LAB_Global.DataTypesTlm.Payload.df2 = .4444; + + for (i = 0; i < 10; i++) + TO_LAB_Global.DataTypesTlm.Payload.str[i] = string_variable[i]; + + CFE_SB_TransmitMsg(CFE_MSG_PTR(TO_LAB_Global.DataTypesTlm.TelemetryHeader), true); + + ++TO_LAB_Global.HkTlm.Payload.CommandCounter; + return CFE_SUCCESS; +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* */ +/* TO_LAB_SendHousekeeping() -- HK status */ +/* Does not increment CommandCounter */ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +int32 TO_LAB_SendHkCmd(const TO_LAB_SendHkCmd_t *data) +{ + CFE_SB_TimeStampMsg(CFE_MSG_PTR(TO_LAB_Global.HkTlm.TelemetryHeader)); + CFE_SB_TransmitMsg(CFE_MSG_PTR(TO_LAB_Global.HkTlm.TelemetryHeader), true); + return CFE_SUCCESS; +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* */ +/* TO_LAB_AddPacket() -- Add packets */ +/* */ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +int32 TO_LAB_AddPacketCmd(const TO_LAB_AddPacketCmd_t *data) +{ + const TO_LAB_AddPacket_Payload_t *pCmd = &data->Payload; + int32 status; + + status = CFE_SB_SubscribeEx(pCmd->Stream, TO_LAB_Global.Tlm_pipe, pCmd->Flags, pCmd->BufLimit); + + if (status != CFE_SUCCESS) + CFE_EVS_SendEvent(TO_LAB_ADDPKT_ERR_EID, CFE_EVS_EventType_ERROR, "L%d TO Can't subscribe 0x%x status %i", + __LINE__, (unsigned int)CFE_SB_MsgIdToValue(pCmd->Stream), (int)status); + else + CFE_EVS_SendEvent(TO_LAB_ADDPKT_INF_EID, CFE_EVS_EventType_INFORMATION, + "L%d TO AddPkt 0x%x, QoS %d.%d, limit %d", __LINE__, + (unsigned int)CFE_SB_MsgIdToValue(pCmd->Stream), pCmd->Flags.Priority, + pCmd->Flags.Reliability, pCmd->BufLimit); + + ++TO_LAB_Global.HkTlm.Payload.CommandCounter; + return CFE_SUCCESS; +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* */ +/* TO_LAB_RemovePacket() -- Remove Packet */ +/* */ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +int32 TO_LAB_RemovePacketCmd(const TO_LAB_RemovePacketCmd_t *data) +{ + const TO_LAB_RemovePacket_Payload_t *pCmd = &data->Payload; + int32 status; + + status = CFE_SB_Unsubscribe(pCmd->Stream, TO_LAB_Global.Tlm_pipe); + if (status != CFE_SUCCESS) + CFE_EVS_SendEvent(TO_LAB_REMOVEPKT_ERR_EID, CFE_EVS_EventType_ERROR, + "L%d TO Can't Unsubscribe to Stream 0x%x, status %i", __LINE__, + (unsigned int)CFE_SB_MsgIdToValue(pCmd->Stream), (int)status); + else + CFE_EVS_SendEvent(TO_LAB_REMOVEPKT_INF_EID, CFE_EVS_EventType_INFORMATION, "L%d TO RemovePkt 0x%x", __LINE__, + (unsigned int)CFE_SB_MsgIdToValue(pCmd->Stream)); + ++TO_LAB_Global.HkTlm.Payload.CommandCounter; + return CFE_SUCCESS; +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* */ +/* TO_LAB_RemoveAll() -- Remove All Packets */ +/* */ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +int32 TO_LAB_RemoveAllCmd(const TO_LAB_RemoveAllCmd_t *data) +{ + int32 status; + int i; + TO_LAB_Sub_t *SubEntry; + + SubEntry = TO_LAB_Global.SubsTblPtr->Subs; + for (i = 0; i < TO_LAB_MAX_SUBSCRIPTIONS; i++) + { + if (CFE_SB_IsValidMsgId(SubEntry->Stream)) + { + status = CFE_SB_Unsubscribe(SubEntry->Stream, TO_LAB_Global.Tlm_pipe); + + if (status != CFE_SUCCESS) + CFE_EVS_SendEvent(TO_LAB_REMOVEALLPTKS_ERR_EID, CFE_EVS_EventType_ERROR, + "L%d TO Can't Unsubscribe to stream 0x%x status %i", __LINE__, + (unsigned int)CFE_SB_MsgIdToValue(SubEntry->Stream), (int)status); + } + } + + CFE_EVS_SendEvent(TO_LAB_REMOVEALLPKTS_INF_EID, CFE_EVS_EventType_INFORMATION, + "L%d TO Unsubscribed to all Commands and Telemetry", __LINE__); + + ++TO_LAB_Global.HkTlm.Payload.CommandCounter; + return CFE_SUCCESS; +} diff --git a/fsw/src/to_lab_cmds.h b/fsw/src/to_lab_cmds.h new file mode 100644 index 0000000..f9c0cd1 --- /dev/null +++ b/fsw/src/to_lab_cmds.h @@ -0,0 +1,47 @@ +/************************************************************************ + * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes” + * + * Copyright (c) 2020 United States Government as represented by the + * Administrator of the National Aeronautics and Space Administration. + * All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. You may obtain + * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ************************************************************************/ + +/** + * @file + * Define TO Lab Application header file + */ + +#ifndef TO_LAB_CMDS_H +#define TO_LAB_CMDS_H + +#include "common_types.h" +#include "cfe_error.h" +#include "to_lab_msg.h" + +/******************************************************************************/ + +/* +** Prototypes Section +*/ +CFE_Status_t TO_LAB_AddPacketCmd(const TO_LAB_AddPacketCmd_t *data); +CFE_Status_t TO_LAB_NoopCmd(const TO_LAB_NoopCmd_t *data); +CFE_Status_t TO_LAB_EnableOutputCmd(const TO_LAB_EnableOutputCmd_t *data); +CFE_Status_t TO_LAB_RemoveAllCmd(const TO_LAB_RemoveAllCmd_t *data); +CFE_Status_t TO_LAB_RemovePacketCmd(const TO_LAB_RemovePacketCmd_t *data); +CFE_Status_t TO_LAB_ResetCountersCmd(const TO_LAB_ResetCountersCmd_t *data); +CFE_Status_t TO_LAB_SendDataTypesCmd(const TO_LAB_SendDataTypesCmd_t *data); +CFE_Status_t TO_LAB_SendHkCmd(const TO_LAB_SendHkCmd_t *data); + +/******************************************************************************/ + +#endif diff --git a/fsw/src/to_lab_dispatch.c b/fsw/src/to_lab_dispatch.c new file mode 100644 index 0000000..42cc7b7 --- /dev/null +++ b/fsw/src/to_lab_dispatch.c @@ -0,0 +1,104 @@ +/************************************************************************ + * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes” + * + * Copyright (c) 2020 United States Government as represented by the + * Administrator of the National Aeronautics and Space Administration. + * All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. You may obtain + * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ************************************************************************/ + +/** + * \file + * This file contains the source code for the TO lab application + */ + +#include "cfe.h" + +#include "to_lab_app.h" +#include "to_lab_dispatch.h" +#include "to_lab_cmds.h" +#include "to_lab_msg.h" +#include "to_lab_eventids.h" +#include "to_lab_msgids.h" + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* */ +/* TO_LAB_ProcessGroundCommand() -- Process local message */ +/* */ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +void TO_LAB_ProcessGroundCommand(const CFE_SB_Buffer_t *SBBufPtr) +{ + CFE_MSG_FcnCode_t CommandCode = 0; + + CFE_MSG_GetFcnCode(&SBBufPtr->Msg, &CommandCode); + + switch (CommandCode) + { + case TO_LAB_NOOP_CC: + TO_LAB_NoopCmd((const TO_LAB_NoopCmd_t *)SBBufPtr); + break; + + case TO_LAB_RESET_STATUS_CC: + TO_LAB_ResetCountersCmd((const TO_LAB_ResetCountersCmd_t *)SBBufPtr); + break; + + case TO_LAB_SEND_DATA_TYPES_CC: + TO_LAB_SendDataTypesCmd((const TO_LAB_SendDataTypesCmd_t *)SBBufPtr); + break; + + case TO_LAB_ADD_PKT_CC: + TO_LAB_AddPacketCmd((const TO_LAB_AddPacketCmd_t *)SBBufPtr); + break; + + case TO_LAB_REMOVE_PKT_CC: + TO_LAB_RemovePacketCmd((const TO_LAB_RemovePacketCmd_t *)SBBufPtr); + break; + + case TO_LAB_REMOVE_ALL_PKT_CC: + TO_LAB_RemoveAllCmd((const TO_LAB_RemoveAllCmd_t *)SBBufPtr); + break; + + case TO_LAB_OUTPUT_ENABLE_CC: + TO_LAB_EnableOutputCmd((const TO_LAB_EnableOutputCmd_t *)SBBufPtr); + break; + + default: + CFE_EVS_SendEvent(TO_LAB_FNCODE_ERR_EID, CFE_EVS_EventType_ERROR, + "L%d TO: Invalid Function Code Rcvd In Ground Command 0x%x", __LINE__, + (unsigned int)CommandCode); + ++TO_LAB_Global.HkTlm.Payload.CommandErrorCounter; + } +} + +void TO_LAB_TaskPipe(const CFE_SB_Buffer_t *SBBufPtr) +{ + CFE_SB_MsgId_t MsgId; + + CFE_MSG_GetMsgId(&SBBufPtr->Msg, &MsgId); + + /* For SB return statuses that imply a message: process it. */ + switch (CFE_SB_MsgIdToValue(MsgId)) + { + case TO_LAB_CMD_MID: + TO_LAB_ProcessGroundCommand(SBBufPtr); + break; + + case TO_LAB_SEND_HK_MID: + TO_LAB_SendHkCmd((const TO_LAB_SendHkCmd_t *)SBBufPtr); + break; + + default: + CFE_EVS_SendEvent(TO_LAB_MSGID_ERR_EID, CFE_EVS_EventType_ERROR, "L%d TO: Invalid Msg ID Rcvd 0x%x", + __LINE__, (unsigned int)CFE_SB_MsgIdToValue(MsgId)); + break; + } +} diff --git a/fsw/platform_inc/to_lab_sub_table.h b/fsw/src/to_lab_dispatch.h similarity index 71% rename from fsw/platform_inc/to_lab_sub_table.h rename to fsw/src/to_lab_dispatch.h index 7df5d94..286ca0e 100644 --- a/fsw/platform_inc/to_lab_sub_table.h +++ b/fsw/src/to_lab_dispatch.h @@ -18,25 +18,21 @@ /** * @file - * Define TO Lab CPU specific subscription table + * Define TO Lab Application header file */ -#ifndef TO_LAB_SUB_TABLE_H -#define TO_LAB_SUB_TABLE_H -#include "cfe_msgids.h" -#include "cfe_platform_cfg.h" -#include "cfe_sb.h" +#ifndef TO_LAB_DISPATCH_H +#define TO_LAB_DISPATCH_H -typedef struct -{ - CFE_SB_MsgId_t Stream; - CFE_SB_Qos_t Flags; - uint16 BufLimit; -} TO_LAB_Sub_t; +#include "common_types.h" -typedef struct -{ - TO_LAB_Sub_t Subs[CFE_PLATFORM_SB_MAX_MSG_IDS]; -} TO_LAB_Subs_t; +/******************************************************************************/ + +/* +** Prototypes Section +*/ +void TO_LAB_TaskPipe(const CFE_SB_Buffer_t *SBBufPtr); + +/******************************************************************************/ #endif diff --git a/fsw/src/to_lab_msg.h b/fsw/src/to_lab_msg.h deleted file mode 100644 index 09bd1df..0000000 --- a/fsw/src/to_lab_msg.h +++ /dev/null @@ -1,148 +0,0 @@ -/************************************************************************ - * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes” - * - * Copyright (c) 2020 United States Government as represented by the - * Administrator of the National Aeronautics and Space Administration. - * All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. You may obtain - * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ************************************************************************/ - -/** - * @file - * Define TO Lab Messages and info - */ -#ifndef TO_LAB_MSG_H -#define TO_LAB_MSG_H - -#define TO_LAB_NOOP_CC 0 /* no-op command */ -#define TO_LAB_RESET_STATUS_CC 1 /* reset status */ -#define TO_LAB_ADD_PKT_CC 2 /* add packet */ -#define TO_LAB_SEND_DATA_TYPES_CC 3 /* send data types */ -#define TO_LAB_REMOVE_PKT_CC 4 /* remove packet */ -#define TO_LAB_REMOVE_ALL_PKT_CC 5 /* remove all packet */ -#define TO_LAB_OUTPUT_ENABLE_CC 6 /* output enable */ - -/******************************************************************************/ - -typedef struct -{ - uint8 CommandCounter; - uint8 CommandErrorCounter; - uint8 spareToAlign[2]; -} TO_LAB_HkTlm_Payload_t; - -typedef struct -{ - CFE_MSG_TelemetryHeader_t TelemetryHeader; /**< \brief Telemetry header */ - TO_LAB_HkTlm_Payload_t Payload; /**< \brief Telemetry payload */ -} TO_LAB_HkTlm_t; - -/******************************************************************************/ - -typedef struct -{ - uint16 synch; -#if 0 - bit_field bit1:1; - bit_field bit2:1; - bit_field bit34:2; - bit_field bit56:2; - bit_field bit78:2; - - bit_field nibble1:4; - bit_field nibble2:4; -#endif - uint8 bl1, bl2; /* boolean */ - int8 b1, b2, b3, b4; - int16 w1, w2; - int32 dw1, dw2; - float f1, f2; - double df1, df2; - char str[10]; -} TO_LAB_DataTypes_Payload_t; - -typedef struct -{ - CFE_MSG_TelemetryHeader_t TelemetryHeader; /**< \brief Telemetry header */ - TO_LAB_DataTypes_Payload_t Payload; /**< \brief Telemetry payload */ -} TO_LAB_DataTypesTlm_t; - -/******************************************************************************/ - -typedef struct -{ - CFE_MSG_CommandHeader_t CmdHeade; /**< \brief Command header */ -} TO_LAB_NoArgsCmd_t; - -/* - * The following commands do not have any payload, - * but should still "reserve" a unique structure type to - * employ a consistent handler pattern. - * - * This matches the pattern in CFE core and other modules. - */ -typedef TO_LAB_NoArgsCmd_t TO_LAB_NoopCmd_t; -typedef TO_LAB_NoArgsCmd_t TO_LAB_ResetCountersCmd_t; -typedef TO_LAB_NoArgsCmd_t TO_LAB_RemoveAllCmd_t; -typedef TO_LAB_NoArgsCmd_t TO_LAB_SendDataTypesCmd_t; - -typedef struct -{ - CFE_SB_MsgId_t Stream; - CFE_SB_Qos_t Flags; - uint8 BufLimit; -} TO_LAB_AddPacket_Payload_t; - -typedef struct -{ - CFE_MSG_CommandHeader_t CmdHeader; /**< \brief Command header */ - TO_LAB_AddPacket_Payload_t Payload; /**< \brief Command payload */ -} TO_LAB_AddPacketCmd_t; - -/*****************************************************************************/ - -typedef struct -{ - CFE_SB_MsgId_t Stream; - CFE_SB_Qos_t Flags; - uint16 BufLimit; -} TO_LAB_subscription_t; - -/******************************************************************************/ - -typedef struct -{ - CFE_SB_MsgId_t Stream; -} TO_LAB_RemovePacket_Payload_t; - -typedef struct -{ - CFE_MSG_CommandHeader_t CmdHeader; /**< \brief Command header */ - TO_LAB_RemovePacket_Payload_t Payload; /**< \brief Command payload */ -} TO_LAB_RemovePacketCmd_t; - -/******************************************************************************/ - -typedef struct -{ - char dest_IP[16]; -} TO_LAB_EnableOutput_Payload_t; - -typedef struct -{ - CFE_MSG_CommandHeader_t CmdHeader; /**< \brief Command header */ - TO_LAB_EnableOutput_Payload_t Payload; /**< \brief Command payload */ -} TO_LAB_EnableOutputCmd_t; - -/******************************************************************************/ - -#endif diff --git a/fsw/tables/to_lab_sub.c b/fsw/tables/to_lab_sub.c index 1fc926f..c839cb8 100644 --- a/fsw/tables/to_lab_sub.c +++ b/fsw/tables/to_lab_sub.c @@ -22,8 +22,8 @@ */ #include "cfe_tbl_filedef.h" /* Required to obtain the CFE_TBL_FILEDEF macro definition */ - -#include "to_lab_sub_table.h" +#include "cfe_sb_api_typedefs.h" +#include "to_lab_tbl.h" /* ** Add the proper include file for the message IDs below diff --git a/mission_build.cmake b/mission_build.cmake new file mode 100644 index 0000000..16344b3 --- /dev/null +++ b/mission_build.cmake @@ -0,0 +1,51 @@ +########################################################### +# +# TO_LAB mission build setup +# +# This file is evaluated as part of the "prepare" stage +# and can be used to set up prerequisites for the build, +# such as generating header files +# +########################################################### + +# The list of header files that control the TO_LAB configuration +set(TO_LAB_MISSION_CONFIG_FILE_LIST + to_lab_fcncodes.h + to_lab_interface_cfg.h + to_lab_mission_cfg.h + to_lab_perfids.h + to_lab_msg.h + to_lab_msgdefs.h + to_lab_msgstruct.h + to_lab_tbl.h + to_lab_tbldefs.h + to_lab_tblstruct.h +) + +if (CFE_EDS_ENABLED_BUILD) + + # In an EDS-based build, these files come generated from the EDS tool + set(TO_LAB_CFGFILE_SRC_to_lab_interface_cfg "to_lab_eds_designparameters.h") + set(TO_LAB_CFGFILE_SRC_to_lab_tbldefs "to_lab_eds_typedefs.h") + set(TO_LAB_CFGFILE_SRC_to_lab_tblstruct "to_lab_eds_typedefs.h") + set(TO_LAB_CFGFILE_SRC_to_lab_msgdefs "to_lab_eds_typedefs.h") + set(TO_LAB_CFGFILE_SRC_to_lab_msgstruct "to_lab_eds_typedefs.h") + set(TO_LAB_CFGFILE_SRC_to_lab_fcncodes "to_lab_eds_cc.h") + +endif(CFE_EDS_ENABLED_BUILD) + +# Create wrappers around the all the config header files +# This makes them individually overridable by the missions, without modifying +# the distribution default copies +foreach(TO_LAB_CFGFILE ${TO_LAB_MISSION_CONFIG_FILE_LIST}) + get_filename_component(CFGKEY "${TO_LAB_CFGFILE}" NAME_WE) + if (DEFINED TO_LAB_CFGFILE_SRC_${CFGKEY}) + set(DEFAULT_SOURCE GENERATED_FILE "${TO_LAB_CFGFILE_SRC_${CFGKEY}}") + else() + set(DEFAULT_SOURCE FALLBACK_FILE "${CMAKE_CURRENT_LIST_DIR}/config/default_${TO_LAB_CFGFILE}") + endif() + generate_config_includefile( + FILE_NAME "${TO_LAB_CFGFILE}" + ${DEFAULT_SOURCE} + ) +endforeach()