From 04e089e48653c4bcb60eb1eb8881a677882895b9 Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Wed, 25 Oct 2023 09:22:08 -0400 Subject: [PATCH 01/11] Fix #147, 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_ci_lab_fcncodes.h | 41 ++++ config/default_ci_lab_interface_cfg.h | 50 +++++ config/default_ci_lab_internal_cfg.h | 50 +++++ config/default_ci_lab_mission_cfg.h | 36 ++++ config/default_ci_lab_msg.h | 38 ++++ config/default_ci_lab_msgdefs.h | 48 +++++ .../default_ci_lab_msgids.h | 2 +- .../default_ci_lab_msgstruct.h | 55 +++--- .../default_ci_lab_perfids.h | 0 config/default_ci_lab_platform_cfg.h | 41 ++++ .../ci_lab_events.h => inc/ci_lab_eventids.h} | 4 +- fsw/src/ci_lab_app.c | 180 +----------------- fsw/src/ci_lab_app.h | 29 ++- fsw/src/ci_lab_cmds.c | 75 ++++++++ fsw/src/ci_lab_cmds.h | 62 ++++++ fsw/src/ci_lab_dispatch.c | 131 +++++++++++++ fsw/src/ci_lab_dispatch.h | 39 ++++ mission_build.cmake | 46 +++++ 20 files changed, 738 insertions(+), 223 deletions(-) create mode 100644 arch_build.cmake create mode 100644 config/default_ci_lab_fcncodes.h create mode 100644 config/default_ci_lab_interface_cfg.h create mode 100644 config/default_ci_lab_internal_cfg.h create mode 100644 config/default_ci_lab_mission_cfg.h create mode 100644 config/default_ci_lab_msg.h create mode 100644 config/default_ci_lab_msgdefs.h rename fsw/platform_inc/ci_lab_msgids.h => config/default_ci_lab_msgids.h (96%) rename fsw/src/ci_lab_msg.h => config/default_ci_lab_msgstruct.h (69%) rename fsw/mission_inc/ci_lab_perfids.h => config/default_ci_lab_perfids.h (100%) create mode 100644 config/default_ci_lab_platform_cfg.h rename fsw/{src/ci_lab_events.h => inc/ci_lab_eventids.h} (96%) create mode 100644 fsw/src/ci_lab_cmds.c create mode 100644 fsw/src/ci_lab_cmds.h create mode 100644 fsw/src/ci_lab_dispatch.c create mode 100644 fsw/src/ci_lab_dispatch.h create mode 100644 mission_build.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index e4b2e8d..bbcfb05 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,12 +3,11 @@ project(CFS_CI_LAB C) set(APP_SRC_FILES fsw/src/ci_lab_app.c + fsw/src/ci_lab_cmds.c + fsw/src/ci_lab_dispatch.c ) # Create the app module add_cfe_app(ci_lab ${APP_SRC_FILES}) -target_include_directories(ci_lab PUBLIC - fsw/mission_inc - fsw/platform_inc -) +target_include_directories(ci_lab PUBLIC fsw/inc) diff --git a/arch_build.cmake b/arch_build.cmake new file mode 100644 index 0000000..ac79159 --- /dev/null +++ b/arch_build.cmake @@ -0,0 +1,27 @@ +########################################################### +# +# CI_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 CI_LAB configuration +set(CI_LAB_PLATFORM_CONFIG_FILE_LIST + ci_lab_internal_cfg.h + ci_lab_platform_cfg.h + ci_lab_perfids.h + ci_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(CI_LAB_CFGFILE ${CI_LAB_PLATFORM_CONFIG_FILE_LIST}) + generate_config_includefile( + FILE_NAME "${CI_LAB_CFGFILE}" + FALLBACK_FILE "${CMAKE_CURRENT_LIST_DIR}/config/default_${CI_LAB_CFGFILE}" + ) +endforeach() diff --git a/config/default_ci_lab_fcncodes.h b/config/default_ci_lab_fcncodes.h new file mode 100644 index 0000000..ad1e543 --- /dev/null +++ b/config/default_ci_lab_fcncodes.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 + * Specification for the CI_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 CI_LAB_FCNCODES_H +#define CI_LAB_FCNCODES_H + +/************************************************************************ + * Macro Definitions + ************************************************************************/ + +/* +** CI_LAB command codes +*/ +#define CI_LAB_NOOP_CC 0 +#define CI_LAB_RESET_COUNTERS_CC 1 + +#endif diff --git a/config/default_ci_lab_interface_cfg.h b/config/default_ci_lab_interface_cfg.h new file mode 100644 index 0000000..f2d9d48 --- /dev/null +++ b/config/default_ci_lab_interface_cfg.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 + * CI_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 CI_LAB_INTERFACE_CFG_H +#define CI_LAB_INTERFACE_CFG_H + +/** + * @brief The base UDP port where CI_LAB will listen for incoming messages + * + * In order to allow multiple instances of CFE to run on the same host, the + * processor number - 1 is added to this value. This, if this is set to + * "1234", then the following ports will be used at runtime: + * + * Processor 1: port 1234 + * Processor 2: port 1235 + * Processor 3: port 1236 + * + * And so forth for however many processor numbers exist in the system + */ +#define CI_LAB_BASE_UDP_PORT 1234 + +#endif diff --git a/config/default_ci_lab_internal_cfg.h b/config/default_ci_lab_internal_cfg.h new file mode 100644 index 0000000..114aeb8 --- /dev/null +++ b/config/default_ci_lab_internal_cfg.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 + * CI_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 CI_LAB_INTERNAL_CFG_H +#define CI_LAB_INTERNAL_CFG_H + +/** + * @brief The size of the input buffer + * + * This definition controls the maximum size message that can be ingested + * from the UDP socket + */ +#define CI_LAB_MAX_INGEST 768 + +/** + * @brief The depth of the command input pipe + * + * This controls the depth of the SB input pipe + */ +#define CI_LAB_PIPE_DEPTH 32 + +#endif diff --git a/config/default_ci_lab_mission_cfg.h b/config/default_ci_lab_mission_cfg.h new file mode 100644 index 0000000..60c0a43 --- /dev/null +++ b/config/default_ci_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 + * + * CI_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 CI_LAB_MISSION_CFG_H +#define CI_LAB_MISSION_CFG_H + +#include "ci_lab_interface_cfg.h" + +#endif diff --git a/config/default_ci_lab_msg.h b/config/default_ci_lab_msg.h new file mode 100644 index 0000000..1f90517 --- /dev/null +++ b/config/default_ci_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 CI_LAB command and telemetry + * message data types. + * + * This is a compatibility header for the "ci_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 CI_LAB_MSG_H +#define CI_LAB_MSG_H + +#include "ci_lab_interface_cfg.h" +#include "ci_lab_msgdefs.h" +#include "ci_lab_msgstruct.h" + +#endif diff --git a/config/default_ci_lab_msgdefs.h b/config/default_ci_lab_msgdefs.h new file mode 100644 index 0000000..c3005e6 --- /dev/null +++ b/config/default_ci_lab_msgdefs.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 CI_LAB command and telemetry + * message constant definitions. + * + * For CI_LAB this is only the function/command code definitions + */ +#ifndef CI_LAB_MSGDEFS_H +#define CI_LAB_MSGDEFS_H + +#include "ci_lab_fcncodes.h" + +/*************************************************************************/ +/* +** Payload definition (CI_LAB housekeeping)... +*/ +typedef struct +{ + uint8 CommandErrorCounter; + uint8 CommandCounter; + uint8 EnableChecksums; + uint8 SocketConnected; + uint8 Spare1[8]; + uint32 IngestPackets; + uint32 IngestErrors; + uint32 Spare2; + +} CI_LAB_HkTlm_Payload_t; + +#endif diff --git a/fsw/platform_inc/ci_lab_msgids.h b/config/default_ci_lab_msgids.h similarity index 96% rename from fsw/platform_inc/ci_lab_msgids.h rename to config/default_ci_lab_msgids.h index 45bc205..feefb97 100644 --- a/fsw/platform_inc/ci_lab_msgids.h +++ b/config/default_ci_lab_msgids.h @@ -18,7 +18,7 @@ /** * @file - * Define CI Lab Message IDs + * CI_LAB Application Message IDs */ #ifndef CI_LAB_MSGIDS_H #define CI_LAB_MSGIDS_H diff --git a/fsw/src/ci_lab_msg.h b/config/default_ci_lab_msgstruct.h similarity index 69% rename from fsw/src/ci_lab_msg.h rename to config/default_ci_lab_msgstruct.h index c72335e..9680039 100644 --- a/fsw/src/ci_lab_msg.h +++ b/config/default_ci_lab_msgstruct.h @@ -18,26 +18,28 @@ /** * @file - * Define CI Lab Messages and info + * Specification for the CI_LAB command and telemetry + * message data types. + * + * @note + * Constants and enumerated types related to these message structures + * are defined in ci_lab_msgdefs.h. */ -#ifndef CI_LAB_MSG_H -#define CI_LAB_MSG_H +#ifndef CI_LAB_MSGSTRUCT_H +#define CI_LAB_MSGSTRUCT_H -/* -** CI_LAB command codes -*/ -#define CI_LAB_NOOP_CC 0 -#define CI_LAB_RESET_COUNTERS_CC 1 +/************************************************************************ + * Includes + ************************************************************************/ + +#include "ci_lab_mission_cfg.h" +#include "ci_lab_msgdefs.h" +#include "cfe_msg_hdr.h" /*************************************************************************/ /* ** Type definition (generic "no arguments" command) */ -typedef struct -{ - CFE_MSG_CommandHeader_t CmdHeader; - -} CI_LAB_NoArgsCmd_t; /* * Neither the Noop nor ResetCounters command @@ -46,25 +48,20 @@ typedef struct * * This matches the pattern in CFE core and other modules. */ -typedef CI_LAB_NoArgsCmd_t CI_LAB_NoopCmd_t; -typedef CI_LAB_NoArgsCmd_t CI_LAB_ResetCountersCmd_t; +typedef struct +{ + CFE_MSG_CommandHeader_t CommandHeader; +} CI_LAB_NoopCmd_t; -/*************************************************************************/ -/* -** Type definition (CI_LAB housekeeping)... -*/ typedef struct { - uint8 CommandErrorCounter; - uint8 CommandCounter; - uint8 EnableChecksums; - uint8 SocketConnected; - uint8 Spare1[8]; - uint32 IngestPackets; - uint32 IngestErrors; - uint32 Spare2; + CFE_MSG_CommandHeader_t CommandHeader; +} CI_LAB_ResetCountersCmd_t; -} CI_LAB_HkTlm_Payload_t; +typedef struct +{ + CFE_MSG_CommandHeader_t CommandHeader; +} CI_LAB_SendHkCmd_t; typedef struct { @@ -72,4 +69,4 @@ typedef struct CI_LAB_HkTlm_Payload_t Payload; } CI_LAB_HkTlm_t; -#endif +#endif /* CI_LAB_MSGSTRUCT_H */ diff --git a/fsw/mission_inc/ci_lab_perfids.h b/config/default_ci_lab_perfids.h similarity index 100% rename from fsw/mission_inc/ci_lab_perfids.h rename to config/default_ci_lab_perfids.h diff --git a/config/default_ci_lab_platform_cfg.h b/config/default_ci_lab_platform_cfg.h new file mode 100644 index 0000000..f179cbe --- /dev/null +++ b/config/default_ci_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 + * + * CI_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 CI_LAB_PLATFORM_CFG_H +#define CI_LAB_PLATFORM_CFG_H + +#include "ci_lab_mission_cfg.h" +#include "ci_lab_internal_cfg.h" + +#endif diff --git a/fsw/src/ci_lab_events.h b/fsw/inc/ci_lab_eventids.h similarity index 96% rename from fsw/src/ci_lab_events.h rename to fsw/inc/ci_lab_eventids.h index 6ddf651..7380bd4 100644 --- a/fsw/src/ci_lab_events.h +++ b/fsw/inc/ci_lab_eventids.h @@ -20,8 +20,8 @@ * @file * Define CI Lab Events IDs */ -#ifndef CI_LAB_EVENTS_H -#define CI_LAB_EVENTS_H +#ifndef CI_LAB_EVENTIDS_H +#define CI_LAB_EVENTIDS_H #define CI_LAB_RESERVED_EID 0 #define CI_LAB_SOCKETCREATE_ERR_EID 1 diff --git a/fsw/src/ci_lab_app.c b/fsw/src/ci_lab_app.c index 909c8c8..11c9d0a 100644 --- a/fsw/src/ci_lab_app.c +++ b/fsw/src/ci_lab_app.c @@ -28,42 +28,13 @@ #include "ci_lab_app.h" #include "ci_lab_perfids.h" #include "ci_lab_msgids.h" -#include "ci_lab_msg.h" -#include "ci_lab_events.h" #include "ci_lab_version.h" /* ** CI global data... */ - -typedef struct -{ - bool SocketConnected; - CFE_SB_PipeId_t CommandPipe; - osal_id_t SocketID; - OS_SockAddr_t SocketAddress; - - CI_LAB_HkTlm_t HkTlm; - - CFE_SB_Buffer_t *NextIngestBufPtr; - -} CI_LAB_GlobalData_t; - CI_LAB_GlobalData_t CI_LAB_Global; -/* - * Individual message handler function prototypes - * - * Per the recommended code pattern, these should accept a const pointer - * to a structure type which matches the message, and return an int32 - * where CFE_SUCCESS (0) indicates successful handling of the message. - */ -int32 CI_LAB_Noop(const CI_LAB_NoopCmd_t *data); -int32 CI_LAB_ResetCounters(const CI_LAB_ResetCountersCmd_t *data); - -/* Housekeeping message handler */ -int32 CI_LAB_ReportHousekeeping(const CFE_MSG_CommandHeader_t *data); - /** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* */ /* Application entry point and main process loop */ @@ -99,7 +70,7 @@ void CI_Lab_AppMain(void) if (status == CFE_SUCCESS) { - CI_LAB_ProcessCommandPacket(SBBufPtr); + CI_LAB_TaskPipe(SBBufPtr); } /* Regardless of packet vs timeout, always process uplink queue */ @@ -181,122 +152,6 @@ void CI_LAB_TaskInit(void) CI_LAB_VERSION_STRING); } -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ -/* */ -/* Purpose: */ -/* This routine will process any packet that is received on the CI command*/ -/* pipe. The packets received on the CI command pipe are listed here: */ -/* */ -/* 1. NOOP command (from ground) */ -/* 2. Request to reset telemetry counters (from ground) */ -/* 3. Request for housekeeping telemetry packet (from HS task) */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -void CI_LAB_ProcessCommandPacket(CFE_SB_Buffer_t *SBBufPtr) -{ - CFE_SB_MsgId_t MsgId = CFE_SB_INVALID_MSG_ID; - - CFE_MSG_GetMsgId(&SBBufPtr->Msg, &MsgId); - - switch (CFE_SB_MsgIdToValue(MsgId)) - { - case CI_LAB_CMD_MID: - CI_LAB_ProcessGroundCommand(SBBufPtr); - break; - - case CI_LAB_SEND_HK_MID: - CI_LAB_ReportHousekeeping((const CFE_MSG_CommandHeader_t *)SBBufPtr); - break; - - default: - CI_LAB_Global.HkTlm.Payload.CommandErrorCounter++; - CFE_EVS_SendEvent(CI_LAB_COMMAND_ERR_EID, CFE_EVS_EventType_ERROR, "CI: invalid command packet,MID = 0x%x", - (unsigned int)CFE_SB_MsgIdToValue(MsgId)); - break; - } -} - -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ -/* */ -/* CI ground commands */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ - -void CI_LAB_ProcessGroundCommand(CFE_SB_Buffer_t *SBBufPtr) -{ - CFE_MSG_FcnCode_t CommandCode = 0; - - CFE_MSG_GetFcnCode(&SBBufPtr->Msg, &CommandCode); - - /* Process "known" CI task ground commands */ - switch (CommandCode) - { - case CI_LAB_NOOP_CC: - if (CI_LAB_VerifyCmdLength(&SBBufPtr->Msg, sizeof(CI_LAB_NoopCmd_t))) - { - CI_LAB_Noop((const CI_LAB_NoopCmd_t *)SBBufPtr); - } - break; - - case CI_LAB_RESET_COUNTERS_CC: - if (CI_LAB_VerifyCmdLength(&SBBufPtr->Msg, sizeof(CI_LAB_ResetCountersCmd_t))) - { - CI_LAB_ResetCounters((const CI_LAB_ResetCountersCmd_t *)SBBufPtr); - } - break; - - /* default case already found during FC vs length test */ - default: - break; - } -} - -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* Purpose: */ -/* Handle NOOP command packets */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -int32 CI_LAB_Noop(const CI_LAB_NoopCmd_t *data) -{ - /* Does everything the name implies */ - CI_LAB_Global.HkTlm.Payload.CommandCounter++; - - CFE_EVS_SendEvent(CI_LAB_COMMANDNOP_INF_EID, CFE_EVS_EventType_INFORMATION, "CI: NOOP command"); - - return CFE_SUCCESS; -} - -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* Purpose: */ -/* Handle ResetCounters command packets */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -int32 CI_LAB_ResetCounters(const CI_LAB_ResetCountersCmd_t *data) -{ - CFE_EVS_SendEvent(CI_LAB_COMMANDRST_INF_EID, CFE_EVS_EventType_INFORMATION, "CI: RESET command"); - CI_LAB_ResetCounters_Internal(); - return CFE_SUCCESS; -} - -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ -/* */ -/* Purpose: */ -/* This function is triggered in response to a task telemetry request */ -/* from the housekeeping task. This function will gather the CI task */ -/* telemetry, packetize it and send it to the housekeeping task via */ -/* the software bus */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -int32 CI_LAB_ReportHousekeeping(const CFE_MSG_CommandHeader_t *data) -{ - CI_LAB_Global.HkTlm.Payload.SocketConnected = CI_LAB_Global.SocketConnected; - CFE_SB_TimeStampMsg(CFE_MSG_PTR(CI_LAB_Global.HkTlm.TelemetryHeader)); - CFE_SB_TransmitMsg(CFE_MSG_PTR(CI_LAB_Global.HkTlm.TelemetryHeader), true); - return CFE_SUCCESS; -} - /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ /* */ /* Purpose: */ @@ -375,36 +230,3 @@ void CI_LAB_ReadUpLink(void) } } } - -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ -/* */ -/* Verify command packet length */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ -bool CI_LAB_VerifyCmdLength(CFE_MSG_Message_t *MsgPtr, size_t ExpectedLength) -{ - bool result = true; - size_t ActualLength = 0; - CFE_MSG_FcnCode_t FcnCode = 0; - CFE_SB_MsgId_t MsgId = CFE_SB_INVALID_MSG_ID; - - CFE_MSG_GetSize(MsgPtr, &ActualLength); - - /* - ** Verify the command packet length... - */ - if (ExpectedLength != ActualLength) - { - CFE_MSG_GetMsgId(MsgPtr, &MsgId); - CFE_MSG_GetFcnCode(MsgPtr, &FcnCode); - - CFE_EVS_SendEvent(CI_LAB_LEN_ERR_EID, CFE_EVS_EventType_ERROR, - "Invalid msg length: ID = 0x%X, CC = %u, Len = %u, Expected = %u", - (unsigned int)CFE_SB_MsgIdToValue(MsgId), (unsigned int)FcnCode, (unsigned int)ActualLength, - (unsigned int)ExpectedLength); - result = false; - CI_LAB_Global.HkTlm.Payload.CommandErrorCounter++; - } - - return result; -} diff --git a/fsw/src/ci_lab_app.h b/fsw/src/ci_lab_app.h index 16e245f..d196a70 100644 --- a/fsw/src/ci_lab_app.h +++ b/fsw/src/ci_lab_app.h @@ -27,9 +27,14 @@ ** Required header files... */ #include "common_types.h" +#include "osapi.h" #include "cfe.h" -#include "osapi.h" +#include "ci_lab_mission_cfg.h" +#include "ci_lab_platform_cfg.h" +#include "ci_lab_eventids.h" +#include "ci_lab_dispatch.h" +#include "ci_lab_cmds.h" #include #include @@ -37,14 +42,23 @@ /****************************************************************************/ -#define CI_LAB_BASE_UDP_PORT 1234 -#define CI_LAB_MAX_INGEST 768 -#define CI_LAB_PIPE_DEPTH 32 - /************************************************************************ ** Type Definitions *************************************************************************/ +typedef struct +{ + bool SocketConnected; + CFE_SB_PipeId_t CommandPipe; + osal_id_t SocketID; + OS_SockAddr_t SocketAddress; + + CI_LAB_HkTlm_t HkTlm; + + CFE_SB_Buffer_t *NextIngestBufPtr; + +} CI_LAB_GlobalData_t; + /****************************************************************************/ /* ** Local function prototypes... @@ -54,11 +68,10 @@ */ void CI_Lab_AppMain(void); void CI_LAB_TaskInit(void); -void CI_LAB_ProcessCommandPacket(CFE_SB_Buffer_t *SBBufPtr); -void CI_LAB_ProcessGroundCommand(CFE_SB_Buffer_t *SBBufPtr); void CI_LAB_ResetCounters_Internal(void); void CI_LAB_ReadUpLink(void); -bool CI_LAB_VerifyCmdLength(CFE_MSG_Message_t *MsgPtr, size_t ExpectedLength); +/* Global State Object */ +extern CI_LAB_GlobalData_t CI_LAB_Global; #endif diff --git a/fsw/src/ci_lab_cmds.c b/fsw/src/ci_lab_cmds.c new file mode 100644 index 0000000..8910108 --- /dev/null +++ b/fsw/src/ci_lab_cmds.c @@ -0,0 +1,75 @@ +/************************************************************************ + * 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 command handler functions for the Command Ingest task. + */ + +/* +** Include Files: +*/ + +#include "ci_lab_app.h" +#include "ci_lab_cmds.h" + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* */ +/* Purpose: */ +/* Handle NOOP command packets */ +/* */ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +CFE_Status_t CI_LAB_NoopCmd(const CI_LAB_NoopCmd_t *cmd) +{ + /* Does everything the name implies */ + CI_LAB_Global.HkTlm.Payload.CommandCounter++; + + CFE_EVS_SendEvent(CI_LAB_COMMANDNOP_INF_EID, CFE_EVS_EventType_INFORMATION, "CI: NOOP command"); + + return CFE_SUCCESS; +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* */ +/* Purpose: */ +/* Handle ResetCounters command packets */ +/* */ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +CFE_Status_t CI_LAB_ResetCountersCmd(const CI_LAB_ResetCountersCmd_t *cmd) +{ + CFE_EVS_SendEvent(CI_LAB_COMMANDRST_INF_EID, CFE_EVS_EventType_INFORMATION, "CI: RESET command"); + CI_LAB_ResetCounters_Internal(); + return CFE_SUCCESS; +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ +/* */ +/* Purpose: */ +/* This function is triggered in response to a task telemetry request */ +/* from the housekeeping task. This function will gather the CI task */ +/* telemetry, packetize it and send it to the housekeeping task via */ +/* the software bus */ +/* */ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +CFE_Status_t CI_LAB_SendHkCmd(const CI_LAB_SendHkCmd_t *cmd) +{ + CI_LAB_Global.HkTlm.Payload.SocketConnected = CI_LAB_Global.SocketConnected; + CFE_SB_TimeStampMsg(CFE_MSG_PTR(CI_LAB_Global.HkTlm.TelemetryHeader)); + CFE_SB_TransmitMsg(CFE_MSG_PTR(CI_LAB_Global.HkTlm.TelemetryHeader), true); + return CFE_SUCCESS; +} diff --git a/fsw/src/ci_lab_cmds.h b/fsw/src/ci_lab_cmds.h new file mode 100644 index 0000000..b399ee4 --- /dev/null +++ b/fsw/src/ci_lab_cmds.h @@ -0,0 +1,62 @@ +/************************************************************************ + * 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 command handler functions for the Command Ingest task. + */ +#ifndef CI_LAB_CMDS_H +#define CI_LAB_CMDS_H + +#include "common_types.h" +#include "cfe_error.h" +#include "ci_lab_msg.h" + +/** + * @brief Handle NOOP command packets + * + * @param cmd Input message pointer + * @returns CFE Status code + * @retval #CFE_SUCCESS on successful processing + */ +CFE_Status_t CI_LAB_NoopCmd(const CI_LAB_NoopCmd_t *cmd); + +/** + * @brief Handle ResetCounters command packets + * + * @param cmd Input message pointer + * @returns CFE Status code + * @retval #CFE_SUCCESS on successful processing + */ +CFE_Status_t CI_LAB_ResetCountersCmd(const CI_LAB_ResetCountersCmd_t *cmd); + +/** + * @brief Handle Send HK command packets + * + * This function is triggered in response to a task telemetry request + * from the housekeeping task. This function will gather the CI task + * telemetry, packetize it and send it to the housekeeping task via + * the software bus + * + * @param cmd Input message pointer + * @returns CFE Status code + * @retval #CFE_SUCCESS on successful processing + */ +CFE_Status_t CI_LAB_SendHkCmd(const CI_LAB_SendHkCmd_t *cmd); + +#endif diff --git a/fsw/src/ci_lab_dispatch.c b/fsw/src/ci_lab_dispatch.c new file mode 100644 index 0000000..d242db9 --- /dev/null +++ b/fsw/src/ci_lab_dispatch.c @@ -0,0 +1,131 @@ +/************************************************************************ + * 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 command dispatch logic for the CI_LAB app + */ + +#include "cfe.h" +#include "ci_lab_app.h" +#include "ci_lab_dispatch.h" +#include "ci_lab_cmds.h" +#include "ci_lab_msgids.h" + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ +/* */ +/* Verify command packet length */ +/* */ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ +bool CI_LAB_VerifyCmdLength(const CFE_MSG_Message_t *MsgPtr, size_t ExpectedLength) +{ + bool result = true; + size_t ActualLength = 0; + CFE_MSG_FcnCode_t FcnCode = 0; + CFE_SB_MsgId_t MsgId = CFE_SB_INVALID_MSG_ID; + + CFE_MSG_GetSize(MsgPtr, &ActualLength); + + /* + ** Verify the command packet length... + */ + if (ExpectedLength != ActualLength) + { + CFE_MSG_GetMsgId(MsgPtr, &MsgId); + CFE_MSG_GetFcnCode(MsgPtr, &FcnCode); + + CFE_EVS_SendEvent(CI_LAB_LEN_ERR_EID, CFE_EVS_EventType_ERROR, + "Invalid msg length: ID = 0x%X, CC = %u, Len = %u, Expected = %u", + (unsigned int)CFE_SB_MsgIdToValue(MsgId), (unsigned int)FcnCode, (unsigned int)ActualLength, + (unsigned int)ExpectedLength); + result = false; + CI_LAB_Global.HkTlm.Payload.CommandErrorCounter++; + } + + return result; +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ +/* */ +/* CI ground commands */ +/* */ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ + +void CI_LAB_ProcessGroundCommand(const CFE_SB_Buffer_t *SBBufPtr) +{ + CFE_MSG_FcnCode_t CommandCode = 0; + + CFE_MSG_GetFcnCode(&SBBufPtr->Msg, &CommandCode); + + /* Process "known" CI task ground commands */ + switch (CommandCode) + { + case CI_LAB_NOOP_CC: + if (CI_LAB_VerifyCmdLength(&SBBufPtr->Msg, sizeof(CI_LAB_NoopCmd_t))) + { + CI_LAB_NoopCmd((const CI_LAB_NoopCmd_t *)SBBufPtr); + } + break; + + case CI_LAB_RESET_COUNTERS_CC: + if (CI_LAB_VerifyCmdLength(&SBBufPtr->Msg, sizeof(CI_LAB_ResetCountersCmd_t))) + { + CI_LAB_ResetCountersCmd((const CI_LAB_ResetCountersCmd_t *)SBBufPtr); + } + break; + + /* default case already found during FC vs length test */ + default: + break; + } +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ +/* */ +/* Purpose: */ +/* This routine will process any packet that is received on the CI command*/ +/* pipe. The packets received on the CI command pipe are listed here: */ +/* */ +/* 1. NOOP command (from ground) */ +/* 2. Request to reset telemetry counters (from ground) */ +/* 3. Request for housekeeping telemetry packet (from HS task) */ +/* */ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +void CI_LAB_TaskPipe(const CFE_SB_Buffer_t *SBBufPtr) +{ + CFE_SB_MsgId_t MsgId = CFE_SB_INVALID_MSG_ID; + + CFE_MSG_GetMsgId(&SBBufPtr->Msg, &MsgId); + + switch (CFE_SB_MsgIdToValue(MsgId)) + { + case CI_LAB_CMD_MID: + CI_LAB_ProcessGroundCommand(SBBufPtr); + break; + + case CI_LAB_SEND_HK_MID: + CI_LAB_SendHkCmd((const CI_LAB_SendHkCmd_t *)SBBufPtr); + break; + + default: + CI_LAB_Global.HkTlm.Payload.CommandErrorCounter++; + CFE_EVS_SendEvent(CI_LAB_COMMAND_ERR_EID, CFE_EVS_EventType_ERROR, "CI: invalid command packet,MID = 0x%x", + (unsigned int)CFE_SB_MsgIdToValue(MsgId)); + break; + } +} diff --git a/fsw/src/ci_lab_dispatch.h b/fsw/src/ci_lab_dispatch.h new file mode 100644 index 0000000..be18fb8 --- /dev/null +++ b/fsw/src/ci_lab_dispatch.h @@ -0,0 +1,39 @@ +/************************************************************************ + * 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 is the dispatch hdr file for the Command Ingest lab application. + */ +#ifndef CI_LAB_DISPATCH_H +#define CI_LAB_DISPATCH_H + +/* +** Required header files... +*/ +#include "common_types.h" +#include "cfe_sb_api_typedefs.h" + +/** + * @brief Process a message/packet received from the Software Bus + * + * @param SBBufPtr Pointer to buffer received from the pipe + */ +void CI_LAB_TaskPipe(const CFE_SB_Buffer_t *SBBufPtr); + +#endif diff --git a/mission_build.cmake b/mission_build.cmake new file mode 100644 index 0000000..c851706 --- /dev/null +++ b/mission_build.cmake @@ -0,0 +1,46 @@ +########################################################### +# +# CI_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 CI_LAB configuration +set(CI_LAB_MISSION_CONFIG_FILE_LIST + ci_lab_fcncodes.h + ci_lab_interface_cfg.h + ci_lab_mission_cfg.h + ci_lab_perfids.h + ci_lab_msgdefs.h + ci_lab_msg.h + ci_lab_msgstruct.h +) + +if (CFE_EDS_ENABLED_BUILD) + + # In an EDS-based build, these files come generated from the EDS tool + set(CI_LAB_CFGFILE_SRC_ci_lab_interface_cfg "ci_lab_eds_designparameters.h") + set(CI_LAB_CFGFILE_SRC_ci_lab_msgdefs "ci_lab_eds_typedefs.h") + set(CI_LAB_CFGFILE_SRC_ci_lab_msgstruct "ci_lab_eds_typedefs.h") + set(CI_LAB_CFGFILE_SRC_ci_lab_fcncodes "ci_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(CI_LAB_CFGFILE ${CI_LAB_MISSION_CONFIG_FILE_LIST}) + get_filename_component(CFGKEY "${CI_LAB_CFGFILE}" NAME_WE) + if (DEFINED CI_LAB_CFGFILE_SRC_${CFGKEY}) + set(DEFAULT_SOURCE GENERATED_FILE "${CI_LAB_CFGFILE_SRC_${CFGKEY}}") + else() + set(DEFAULT_SOURCE FALLBACK_FILE "${CMAKE_CURRENT_LIST_DIR}/config/default_${CI_LAB_CFGFILE}") + endif() + generate_config_includefile( + FILE_NAME "${CI_LAB_CFGFILE}" + ${DEFAULT_SOURCE} + ) +endforeach() From 7d3eca979efaf7880955b87ca746c0b77a31809b Mon Sep 17 00:00:00 2001 From: Dylan Date: Mon, 30 Oct 2023 12:38:06 -0400 Subject: [PATCH 02/11] Bump to v2.5.0-rc4+dev51 --- CHANGELOG.md | 4 ++++ fsw/src/ci_lab_version.h | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 09f90b3..2895d28 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## Development Build: v2.5.0-rc4+dev51 +- reorganize source files +- See + ## Development Build: v2.5.0-rc4+dev47 - Create Workflow for IC Bundle Generation - See diff --git a/fsw/src/ci_lab_version.h b/fsw/src/ci_lab_version.h index 0ff55d2..c242a62 100644 --- a/fsw/src/ci_lab_version.h +++ b/fsw/src/ci_lab_version.h @@ -25,7 +25,7 @@ /* Development Build Macro Definitions */ -#define CI_LAB_BUILD_NUMBER 47 /*!< Development Build: Number of commits since baseline */ +#define CI_LAB_BUILD_NUMBER 51 /*!< Development Build: Number of commits since baseline */ #define CI_LAB_BUILD_BASELINE \ "v2.5.0-rc4" /*!< Development Build: git tag that is the base for the current development */ From 60626f1aa209fddcff585458214710e3d6d77c59 Mon Sep 17 00:00:00 2001 From: Avi Date: Fri, 21 Oct 2022 20:15:09 +1000 Subject: [PATCH 03/11] Fix #129, Apply consistent Event ID names to common events --- fsw/inc/ci_lab_eventids.h | 10 +++++----- fsw/src/ci_lab_app.c | 2 +- fsw/src/ci_lab_cmds.c | 4 ++-- fsw/src/ci_lab_dispatch.c | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/fsw/inc/ci_lab_eventids.h b/fsw/inc/ci_lab_eventids.h index 7380bd4..6d25c11 100644 --- a/fsw/inc/ci_lab_eventids.h +++ b/fsw/inc/ci_lab_eventids.h @@ -26,14 +26,14 @@ #define CI_LAB_RESERVED_EID 0 #define CI_LAB_SOCKETCREATE_ERR_EID 1 #define CI_LAB_SOCKETBIND_ERR_EID 2 -#define CI_LAB_STARTUP_INF_EID 3 -#define CI_LAB_COMMAND_ERR_EID 4 -#define CI_LAB_COMMANDNOP_INF_EID 5 -#define CI_LAB_COMMANDRST_INF_EID 6 +#define CI_LAB_INIT_INF_EID 3 +#define CI_LAB_MID_ERR_EID 4 +#define CI_LAB_NOOP_INF_EID 5 +#define CI_LAB_RESET_INF_EID 6 #define CI_LAB_INGEST_INF_EID 7 #define CI_LAB_INGEST_LEN_ERR_EID 8 #define CI_LAB_INGEST_ALLOC_ERR_EID 9 #define CI_LAB_INGEST_SEND_ERR_EID 10 -#define CI_LAB_LEN_ERR_EID 16 +#define CI_LAB_CMD_LEN_ERR_EID 16 #endif diff --git a/fsw/src/ci_lab_app.c b/fsw/src/ci_lab_app.c index 11c9d0a..e191e07 100644 --- a/fsw/src/ci_lab_app.c +++ b/fsw/src/ci_lab_app.c @@ -148,7 +148,7 @@ void CI_LAB_TaskInit(void) CFE_MSG_Init(CFE_MSG_PTR(CI_LAB_Global.HkTlm.TelemetryHeader), CFE_SB_ValueToMsgId(CI_LAB_HK_TLM_MID), sizeof(CI_LAB_Global.HkTlm)); - CFE_EVS_SendEvent(CI_LAB_STARTUP_INF_EID, CFE_EVS_EventType_INFORMATION, "CI Lab Initialized.%s", + CFE_EVS_SendEvent(CI_LAB_INIT_INF_EID, CFE_EVS_EventType_INFORMATION, "CI Lab Initialized.%s", CI_LAB_VERSION_STRING); } diff --git a/fsw/src/ci_lab_cmds.c b/fsw/src/ci_lab_cmds.c index 8910108..bda0665 100644 --- a/fsw/src/ci_lab_cmds.c +++ b/fsw/src/ci_lab_cmds.c @@ -39,7 +39,7 @@ CFE_Status_t CI_LAB_NoopCmd(const CI_LAB_NoopCmd_t *cmd) /* Does everything the name implies */ CI_LAB_Global.HkTlm.Payload.CommandCounter++; - CFE_EVS_SendEvent(CI_LAB_COMMANDNOP_INF_EID, CFE_EVS_EventType_INFORMATION, "CI: NOOP command"); + CFE_EVS_SendEvent(CI_LAB_NOOP_INF_EID, CFE_EVS_EventType_INFORMATION, "CI: NOOP command"); return CFE_SUCCESS; } @@ -52,7 +52,7 @@ CFE_Status_t CI_LAB_NoopCmd(const CI_LAB_NoopCmd_t *cmd) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ CFE_Status_t CI_LAB_ResetCountersCmd(const CI_LAB_ResetCountersCmd_t *cmd) { - CFE_EVS_SendEvent(CI_LAB_COMMANDRST_INF_EID, CFE_EVS_EventType_INFORMATION, "CI: RESET command"); + CFE_EVS_SendEvent(CI_LAB_RESET_INF_EID, CFE_EVS_EventType_INFORMATION, "CI: RESET command"); CI_LAB_ResetCounters_Internal(); return CFE_SUCCESS; } diff --git a/fsw/src/ci_lab_dispatch.c b/fsw/src/ci_lab_dispatch.c index d242db9..22fd933 100644 --- a/fsw/src/ci_lab_dispatch.c +++ b/fsw/src/ci_lab_dispatch.c @@ -49,7 +49,7 @@ bool CI_LAB_VerifyCmdLength(const CFE_MSG_Message_t *MsgPtr, size_t ExpectedLeng CFE_MSG_GetMsgId(MsgPtr, &MsgId); CFE_MSG_GetFcnCode(MsgPtr, &FcnCode); - CFE_EVS_SendEvent(CI_LAB_LEN_ERR_EID, CFE_EVS_EventType_ERROR, + CFE_EVS_SendEvent(CI_LAB_CMD_LEN_ERR_EID, CFE_EVS_EventType_ERROR, "Invalid msg length: ID = 0x%X, CC = %u, Len = %u, Expected = %u", (unsigned int)CFE_SB_MsgIdToValue(MsgId), (unsigned int)FcnCode, (unsigned int)ActualLength, (unsigned int)ExpectedLength); @@ -124,7 +124,7 @@ void CI_LAB_TaskPipe(const CFE_SB_Buffer_t *SBBufPtr) default: CI_LAB_Global.HkTlm.Payload.CommandErrorCounter++; - CFE_EVS_SendEvent(CI_LAB_COMMAND_ERR_EID, CFE_EVS_EventType_ERROR, "CI: invalid command packet,MID = 0x%x", + CFE_EVS_SendEvent(CI_LAB_MID_ERR_EID, CFE_EVS_EventType_ERROR, "CI: invalid command packet,MID = 0x%x", (unsigned int)CFE_SB_MsgIdToValue(MsgId)); break; } From 7d29e25521f002add84b4c05d45ec7c4fc2177a4 Mon Sep 17 00:00:00 2001 From: Avi Weiss Date: Tue, 2 May 2023 19:13:50 +1000 Subject: [PATCH 04/11] Fix #140, Move function prototypes to header file --- config/default_ci_lab_msgdefs.h | 1 - fsw/src/ci_lab_app.c | 2 +- fsw/src/ci_lab_app.h | 19 ++++++++++++++++++- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/config/default_ci_lab_msgdefs.h b/config/default_ci_lab_msgdefs.h index c3005e6..04e876a 100644 --- a/config/default_ci_lab_msgdefs.h +++ b/config/default_ci_lab_msgdefs.h @@ -42,7 +42,6 @@ typedef struct uint32 IngestPackets; uint32 IngestErrors; uint32 Spare2; - } CI_LAB_HkTlm_Payload_t; #endif diff --git a/fsw/src/ci_lab_app.c b/fsw/src/ci_lab_app.c index 11c9d0a..f6cf0f3 100644 --- a/fsw/src/ci_lab_app.c +++ b/fsw/src/ci_lab_app.c @@ -31,7 +31,7 @@ #include "ci_lab_version.h" /* -** CI global data... +** CI Global Data */ CI_LAB_GlobalData_t CI_LAB_Global; diff --git a/fsw/src/ci_lab_app.h b/fsw/src/ci_lab_app.h index d196a70..50394e8 100644 --- a/fsw/src/ci_lab_app.h +++ b/fsw/src/ci_lab_app.h @@ -36,11 +36,15 @@ #include "ci_lab_dispatch.h" #include "ci_lab_cmds.h" +#include "ci_lab_msg.h" + #include #include #include -/****************************************************************************/ +/************************************************************************ + * Macro Definitions + ************************************************************************/ /************************************************************************ ** Type Definitions @@ -74,4 +78,17 @@ void CI_LAB_ReadUpLink(void); /* Global State Object */ extern CI_LAB_GlobalData_t CI_LAB_Global; +/* + * Individual message handler function prototypes + * + * Per the recommended code pattern, these should accept a const pointer + * to a structure type which matches the message, and return an int32 + * where CFE_SUCCESS (0) indicates successful handling of the message. + */ +int32 CI_LAB_Noop(const CI_LAB_NoopCmd_t *data); +int32 CI_LAB_ResetCounters(const CI_LAB_ResetCountersCmd_t *data); + +/* Housekeeping message handler */ +int32 CI_LAB_ReportHousekeeping(const CFE_MSG_CommandHeader_t *data); + #endif From 884199a51585f90aa1555f0ac39b55826d6c6c9c Mon Sep 17 00:00:00 2001 From: Avi Weiss Date: Mon, 24 Apr 2023 11:00:17 +1000 Subject: [PATCH 05/11] Fix #138, Convert `int32` return codes and variables to `CFE_Status_t` --- .github/workflows/codeql-build.yml | 4 ++-- fsw/src/ci_lab_app.c | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/codeql-build.yml b/.github/workflows/codeql-build.yml index a364b0b..9e71f60 100644 --- a/.github/workflows/codeql-build.yml +++ b/.github/workflows/codeql-build.yml @@ -3,11 +3,11 @@ name: "CodeQL Analysis" on: push: pull_request: - + jobs: codeql: name: CodeQL Analysis uses: nasa/cFS/.github/workflows/codeql-reusable.yml@main - with: + with: component-path: apps/ci_lab make: 'make -C build/native/default_cpu1/apps/ci_lab' diff --git a/fsw/src/ci_lab_app.c b/fsw/src/ci_lab_app.c index 11c9d0a..5eacb4b 100644 --- a/fsw/src/ci_lab_app.c +++ b/fsw/src/ci_lab_app.c @@ -48,7 +48,7 @@ CI_LAB_GlobalData_t CI_LAB_Global; /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ void CI_Lab_AppMain(void) { - int32 status; + CFE_Status_t status; uint32 RunStatus = CFE_ES_RunStatus_APP_RUN; CFE_SB_Buffer_t *SBBufPtr; @@ -177,9 +177,9 @@ void CI_LAB_ResetCounters_Internal(void) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ void CI_LAB_ReadUpLink(void) { - int i; - int32 status; - uint8 *bytes; + int i; + CFE_Status_t status; + uint8 * bytes; for (i = 0; i <= 10; i++) { From 2c398c0f311fdf1dedb758e56f75b7b7baa8921c Mon Sep 17 00:00:00 2001 From: Avi Weiss Date: Wed, 1 Nov 2023 20:59:48 +0200 Subject: [PATCH 06/11] Fix #127, Rename CommandCode variable to FcnCode --- fsw/src/ci_lab_dispatch.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fsw/src/ci_lab_dispatch.c b/fsw/src/ci_lab_dispatch.c index d242db9..e39042d 100644 --- a/fsw/src/ci_lab_dispatch.c +++ b/fsw/src/ci_lab_dispatch.c @@ -68,12 +68,12 @@ bool CI_LAB_VerifyCmdLength(const CFE_MSG_Message_t *MsgPtr, size_t ExpectedLeng void CI_LAB_ProcessGroundCommand(const CFE_SB_Buffer_t *SBBufPtr) { - CFE_MSG_FcnCode_t CommandCode = 0; + CFE_MSG_FcnCode_t FcnCode = 0; - CFE_MSG_GetFcnCode(&SBBufPtr->Msg, &CommandCode); + CFE_MSG_GetFcnCode(&SBBufPtr->Msg, &FcnCode); /* Process "known" CI task ground commands */ - switch (CommandCode) + switch (FcnCode) { case CI_LAB_NOOP_CC: if (CI_LAB_VerifyCmdLength(&SBBufPtr->Msg, sizeof(CI_LAB_NoopCmd_t))) From 680d07ca4409a8de43c4404376e7b7c08b184f0c Mon Sep 17 00:00:00 2001 From: Avi Date: Mon, 17 Oct 2022 09:02:27 +1000 Subject: [PATCH 07/11] Fix #125, Standardize ci_lab function names --- config/default_ci_lab_fcncodes.h | 9 +++++++-- fsw/src/ci_lab_app.c | 2 +- fsw/src/ci_lab_app.h | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/config/default_ci_lab_fcncodes.h b/config/default_ci_lab_fcncodes.h index ad1e543..8d1c456 100644 --- a/config/default_ci_lab_fcncodes.h +++ b/config/default_ci_lab_fcncodes.h @@ -35,7 +35,12 @@ /* ** CI_LAB command codes */ -#define CI_LAB_NOOP_CC 0 -#define CI_LAB_RESET_COUNTERS_CC 1 +#define CI_LAB_NOOP_CC 0 +#define CI_LAB_RESET_COUNTERS_CC 1 +#define CI_LAB_MODIFY_PDU_FILESIZE_CC 2 +#define CI_LAB_CORRUPT_PDU_CHECKSUM_CC 3 +#define CI_LAB_DROP_PDUS_CC 4 +#define CI_LAB_CAPTURE_PDUS_CC 5 +#define CI_LAB_STOP_PDU_CAPTURE_CC 6 #endif diff --git a/fsw/src/ci_lab_app.c b/fsw/src/ci_lab_app.c index 11c9d0a..368d54f 100644 --- a/fsw/src/ci_lab_app.c +++ b/fsw/src/ci_lab_app.c @@ -46,7 +46,7 @@ CI_LAB_GlobalData_t CI_LAB_Global; /* and acts accordingly to process them. */ /* */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ -void CI_Lab_AppMain(void) +void CI_LAB_AppMain(void) { int32 status; uint32 RunStatus = CFE_ES_RunStatus_APP_RUN; diff --git a/fsw/src/ci_lab_app.h b/fsw/src/ci_lab_app.h index d196a70..752ed75 100644 --- a/fsw/src/ci_lab_app.h +++ b/fsw/src/ci_lab_app.h @@ -66,7 +66,7 @@ typedef struct ** Note: Except for the entry point (CI_LAB_AppMain), these ** functions are not called from any other source module. */ -void CI_Lab_AppMain(void); +void CI_LAB_AppMain(void); void CI_LAB_TaskInit(void); void CI_LAB_ResetCounters_Internal(void); void CI_LAB_ReadUpLink(void); From 5c3d8431a42569af5d018cf50b925e40072d4668 Mon Sep 17 00:00:00 2001 From: Avi Date: Tue, 8 Nov 2022 10:16:19 +1000 Subject: [PATCH 08/11] Fix #96, Check returns from CFE calls during init --- fsw/inc/ci_lab_eventids.h | 27 +++++++++++++++------------ fsw/src/ci_lab_app.c | 31 +++++++++++++++++++++++++++---- 2 files changed, 42 insertions(+), 16 deletions(-) diff --git a/fsw/inc/ci_lab_eventids.h b/fsw/inc/ci_lab_eventids.h index 6d25c11..74b2842 100644 --- a/fsw/inc/ci_lab_eventids.h +++ b/fsw/inc/ci_lab_eventids.h @@ -23,17 +23,20 @@ #ifndef CI_LAB_EVENTIDS_H #define CI_LAB_EVENTIDS_H -#define CI_LAB_RESERVED_EID 0 -#define CI_LAB_SOCKETCREATE_ERR_EID 1 -#define CI_LAB_SOCKETBIND_ERR_EID 2 -#define CI_LAB_INIT_INF_EID 3 -#define CI_LAB_MID_ERR_EID 4 -#define CI_LAB_NOOP_INF_EID 5 -#define CI_LAB_RESET_INF_EID 6 -#define CI_LAB_INGEST_INF_EID 7 -#define CI_LAB_INGEST_LEN_ERR_EID 8 -#define CI_LAB_INGEST_ALLOC_ERR_EID 9 -#define CI_LAB_INGEST_SEND_ERR_EID 10 -#define CI_LAB_CMD_LEN_ERR_EID 16 +#define CI_LAB_RESERVED_EID 0 +#define CI_LAB_SOCKETCREATE_ERR_EID 1 +#define CI_LAB_SOCKETBIND_ERR_EID 2 +#define CI_LAB_INIT_INF_EID 3 +#define CI_LAB_MID_ERR_EID 4 +#define CI_LAB_NOOP_INF_EID 5 +#define CI_LAB_RESET_INF_EID 6 +#define CI_LAB_INGEST_INF_EID 7 +#define CI_LAB_INGEST_LEN_ERR_EID 8 +#define CI_LAB_INGEST_ALLOC_ERR_EID 9 +#define CI_LAB_INGEST_SEND_ERR_EID 10 +#define CI_LAB_CR_PIPE_ERR_EID 11 +#define CI_LAB_SB_SUBSCRIBE_CMD_ERR_EID 12 +#define CI_LAB_SB_SUBSCRIBE_HK_ERR_EID 13 +#define CI_LAB_CMD_LEN_ERR_EID 16 #endif diff --git a/fsw/src/ci_lab_app.c b/fsw/src/ci_lab_app.c index 7e4f193..4b7000a 100644 --- a/fsw/src/ci_lab_app.c +++ b/fsw/src/ci_lab_app.c @@ -106,11 +106,34 @@ void CI_LAB_TaskInit(void) memset(&CI_LAB_Global, 0, sizeof(CI_LAB_Global)); - CFE_EVS_Register(NULL, 0, CFE_EVS_EventFilter_BINARY); + status = CFE_EVS_Register(NULL, 0, CFE_EVS_EventFilter_BINARY); + if (status != CFE_SUCCESS) + { + CFE_ES_WriteToSysLog("CI_LAB: Error registering for Event Services, RC = 0x%08X\n", (unsigned int)status); + } + + status = CFE_SB_CreatePipe(&CI_LAB_Global.CommandPipe, CI_LAB_PIPE_DEPTH, "CI_LAB_CMD_PIPE"); + if (status == CFE_SUCCESS) + { + status = CFE_SB_Subscribe(CFE_SB_ValueToMsgId(CI_LAB_CMD_MID), CI_LAB_Global.CommandPipe); + if (status != CFE_SUCCESS) + { + CFE_EVS_SendEvent(CI_LAB_SB_SUBSCRIBE_CMD_ERR_EID, CFE_EVS_EventType_ERROR, + "Error subscribing to SB Commands, RC = 0x%08X", (unsigned int)status); + } - CFE_SB_CreatePipe(&CI_LAB_Global.CommandPipe, CI_LAB_PIPE_DEPTH, "CI_LAB_CMD_PIPE"); - CFE_SB_Subscribe(CFE_SB_ValueToMsgId(CI_LAB_CMD_MID), CI_LAB_Global.CommandPipe); - CFE_SB_Subscribe(CFE_SB_ValueToMsgId(CI_LAB_SEND_HK_MID), CI_LAB_Global.CommandPipe); + status = CFE_SB_Subscribe(CFE_SB_ValueToMsgId(CI_LAB_SEND_HK_MID), CI_LAB_Global.CommandPipe); + if (status != CFE_SUCCESS) + { + CFE_EVS_SendEvent(CI_LAB_SB_SUBSCRIBE_HK_ERR_EID, CFE_EVS_EventType_ERROR, + "Error subscribing to SB HK Request, RC = 0x%08X", (unsigned int)status); + } + } + else + { + CFE_EVS_SendEvent(CI_LAB_CR_PIPE_ERR_EID, CFE_EVS_EventType_ERROR, + "Error creating SB Command Pipe, RC = 0x%08X", (unsigned int)status); + } status = OS_SocketOpen(&CI_LAB_Global.SocketID, OS_SocketDomain_INET, OS_SocketType_DATAGRAM); if (status != OS_SUCCESS) From a42133568b29f46d67319d4ff29cd65508b9c56f Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Fri, 27 Oct 2023 13:10:55 -0400 Subject: [PATCH 09/11] Fix #149, add decode hooks Add an intermediate step during ingest to allow the buffer to be decoded prior to sending to SB. Initial implementation is just a pass-through, thus matching existing behavior. --- CMakeLists.txt | 1 + fsw/src/ci_lab_app.c | 59 ++++++++-------- fsw/src/ci_lab_app.h | 3 +- fsw/src/ci_lab_decode.h | 35 ++++++++++ fsw/src/ci_lab_passthru_decode.c | 114 +++++++++++++++++++++++++++++++ 5 files changed, 182 insertions(+), 30 deletions(-) create mode 100644 fsw/src/ci_lab_decode.h create mode 100644 fsw/src/ci_lab_passthru_decode.c diff --git a/CMakeLists.txt b/CMakeLists.txt index bbcfb05..cb5b320 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,6 +5,7 @@ set(APP_SRC_FILES fsw/src/ci_lab_app.c fsw/src/ci_lab_cmds.c fsw/src/ci_lab_dispatch.c + fsw/src/ci_lab_passthru_decode.c ) # Create the app module diff --git a/fsw/src/ci_lab_app.c b/fsw/src/ci_lab_app.c index 4b7000a..3a5cdcd 100644 --- a/fsw/src/ci_lab_app.c +++ b/fsw/src/ci_lab_app.c @@ -29,6 +29,7 @@ #include "ci_lab_perfids.h" #include "ci_lab_msgids.h" #include "ci_lab_version.h" +#include "ci_lab_decode.h" /* ** CI Global Data @@ -200,53 +201,53 @@ void CI_LAB_ResetCounters_Internal(void) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ void CI_LAB_ReadUpLink(void) { - int i; - CFE_Status_t status; - uint8 * bytes; + int i; + int32 OsStatus; + + CFE_Status_t CfeStatus; + CFE_SB_Buffer_t *SBBufPtr; for (i = 0; i <= 10; i++) { - if (CI_LAB_Global.NextIngestBufPtr == NULL) + if (CI_LAB_Global.NetBufPtr == NULL) { - CI_LAB_Global.NextIngestBufPtr = CFE_SB_AllocateMessageBuffer(CI_LAB_MAX_INGEST); - if (CI_LAB_Global.NextIngestBufPtr == NULL) - { - CFE_EVS_SendEvent(CI_LAB_INGEST_ALLOC_ERR_EID, CFE_EVS_EventType_ERROR, - "CI: L%d, buffer allocation failed\n", __LINE__); - break; - } + CI_LAB_GetInputBuffer(&CI_LAB_Global.NetBufPtr, &CI_LAB_Global.NetBufSize); } - status = OS_SocketRecvFrom(CI_LAB_Global.SocketID, CI_LAB_Global.NextIngestBufPtr, CI_LAB_MAX_INGEST, - &CI_LAB_Global.SocketAddress, OS_CHECK); - if (status >= (int32)sizeof(CFE_MSG_CommandHeader_t) && status <= ((int32)CI_LAB_MAX_INGEST)) + if (CI_LAB_Global.NetBufPtr == NULL) + { + break; + } + + OsStatus = OS_SocketRecvFrom(CI_LAB_Global.SocketID, CI_LAB_Global.NetBufPtr, CI_LAB_Global.NetBufSize, + &CI_LAB_Global.SocketAddress, OS_CHECK); + if (OsStatus > 0) { CFE_ES_PerfLogEntry(CI_LAB_SOCKET_RCV_PERF_ID); - CI_LAB_Global.HkTlm.Payload.IngestPackets++; - status = CFE_SB_TransmitBuffer(CI_LAB_Global.NextIngestBufPtr, false); + CfeStatus = CI_LAB_DecodeInputMessage(CI_LAB_Global.NetBufPtr, OsStatus, &SBBufPtr); + if (CfeStatus != CFE_SUCCESS) + { + CI_LAB_Global.HkTlm.Payload.IngestErrors++; + } + else + { + CI_LAB_Global.HkTlm.Payload.IngestPackets++; + CfeStatus = CFE_SB_TransmitBuffer(SBBufPtr, false); + } CFE_ES_PerfLogExit(CI_LAB_SOCKET_RCV_PERF_ID); - if (status == CFE_SUCCESS) + if (CfeStatus == CFE_SUCCESS) { /* Set NULL so a new buffer will be obtained next time around */ - CI_LAB_Global.NextIngestBufPtr = NULL; + CI_LAB_Global.NetBufPtr = NULL; + CI_LAB_Global.NetBufSize = 0; } else { CFE_EVS_SendEvent(CI_LAB_INGEST_SEND_ERR_EID, CFE_EVS_EventType_ERROR, - "CI: L%d, CFE_SB_TransmitBuffer() failed, status=%d\n", __LINE__, (int)status); + "CI_LAB: Ingest failed, status=%d\n", (int)CfeStatus); } } - else if (status > 0) - { - /* bad size, report as ingest error */ - CI_LAB_Global.HkTlm.Payload.IngestErrors++; - - bytes = CI_LAB_Global.NextIngestBufPtr->Msg.Byte; - CFE_EVS_SendEvent(CI_LAB_INGEST_LEN_ERR_EID, CFE_EVS_EventType_ERROR, - "CI: L%d, cmd %0x%0x %0x%0x dropped, bad length=%d\n", __LINE__, bytes[0], bytes[1], - bytes[2], bytes[3], (int)status); - } else { break; /* no (more) messages */ diff --git a/fsw/src/ci_lab_app.h b/fsw/src/ci_lab_app.h index 0b2500f..cb1510e 100644 --- a/fsw/src/ci_lab_app.h +++ b/fsw/src/ci_lab_app.h @@ -59,7 +59,8 @@ typedef struct CI_LAB_HkTlm_t HkTlm; - CFE_SB_Buffer_t *NextIngestBufPtr; + void * NetBufPtr; + size_t NetBufSize; } CI_LAB_GlobalData_t; diff --git a/fsw/src/ci_lab_decode.h b/fsw/src/ci_lab_decode.h new file mode 100644 index 0000000..db4b2ff --- /dev/null +++ b/fsw/src/ci_lab_decode.h @@ -0,0 +1,35 @@ +/************************************************************************ + * 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 is the dispatch hdr file for the Command Ingest lab application. + */ +#ifndef CI_LAB_DECODE_H +#define CI_LAB_DECODE_H + +/* +** Required header files... +*/ +#include "common_types.h" +#include "cfe_sb_api_typedefs.h" + +CFE_Status_t CI_LAB_GetInputBuffer(void **BufferOut, size_t *SizeOut); +CFE_Status_t CI_LAB_DecodeInputMessage(void *SourceBuffer, size_t SourceSize, CFE_SB_Buffer_t **DestBufferOut); + +#endif diff --git a/fsw/src/ci_lab_passthru_decode.c b/fsw/src/ci_lab_passthru_decode.c new file mode 100644 index 0000000..05d41e8 --- /dev/null +++ b/fsw/src/ci_lab_passthru_decode.c @@ -0,0 +1,114 @@ +/************************************************************************ + * 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 Command Ingest task. + */ + +/* +** Include Files: +*/ +#include "cfe.h" + +#include "ci_lab_app.h" +#include "ci_lab_perfids.h" +#include "ci_lab_msgids.h" +#include "ci_lab_decode.h" + +/* + * --------------------------------------- + * In a "passthrough" configuration - the data from the network + * is expected to be a direct instance of the CFE_MSG_Message_t base, + * and thus something can be sent directly to SB. + * + * Instead of using an intermediate buffer, just get a buffer from + * SB and put it directly in there. This reduces copying. + * --------------------------------------- + */ +CFE_Status_t CI_LAB_GetInputBuffer(void **BufferOut, size_t *SizeOut) +{ + CFE_SB_Buffer_t *IngestBuffer; + const size_t IngestSize = CI_LAB_MAX_INGEST; + + IngestBuffer = CFE_SB_AllocateMessageBuffer(IngestSize); + if (IngestBuffer == NULL) + { + *BufferOut = NULL; + *SizeOut = 0; + + CFE_EVS_SendEvent(CI_LAB_INGEST_ALLOC_ERR_EID, CFE_EVS_EventType_ERROR, "CI_LAB: buffer allocation failed\n"); + + return CFE_SB_BUF_ALOC_ERR; + } + + *BufferOut = IngestBuffer; + *SizeOut = IngestSize; + + return CFE_SUCCESS; +} + +/* + * --------------------------------------- + * In a "passthrough" configuration - the data from the network + * is expected to be a direct instance of the CFE_MSG_Message_t base, + * and thus something can be sent directly to SB. + * + * This just does a simple sanity check on the message size. But + * otherwise, the source buffer is used directly as the output buffer. + * --------------------------------------- + */ +CFE_Status_t CI_LAB_DecodeInputMessage(void *SourceBuffer, size_t SourceSize, CFE_SB_Buffer_t **DestBufferOut) +{ + CFE_SB_Buffer_t *MsgBufPtr; + CFE_MSG_Size_t MsgSize; + CFE_Status_t Status; + + if (SourceSize < sizeof(CFE_MSG_CommandHeader_t)) + { + MsgBufPtr = NULL; + Status = CFE_STATUS_WRONG_MSG_LENGTH; + + CFE_EVS_SendEvent(CI_LAB_INGEST_LEN_ERR_EID, CFE_EVS_EventType_ERROR, + "CI: cmd dropped, bad packet length=%lu\n", (unsigned long)SourceSize); + } + else + { + MsgBufPtr = SourceBuffer; + + /* Check the size from within the header itself, compare against network buffer size */ + CFE_MSG_GetSize(&MsgBufPtr->Msg, &MsgSize); + + if (MsgSize > SourceSize) + { + Status = CFE_STATUS_WRONG_MSG_LENGTH; + + CFE_EVS_SendEvent(CI_LAB_INGEST_LEN_ERR_EID, CFE_EVS_EventType_ERROR, + "CI: cmd dropped - length mismatch, %lu (hdr) / %lu (packet)\n", (unsigned long)MsgSize, + (unsigned long)SourceSize); + } + else + { + Status = CFE_SUCCESS; + } + } + + *DestBufferOut = MsgBufPtr; + + return Status; +} From ea9219f2e6cd36c5f87bbefd7c245701377b3004 Mon Sep 17 00:00:00 2001 From: Avi Weiss Date: Wed, 1 Nov 2023 21:24:52 +0200 Subject: [PATCH 10/11] Fix #52, Add version information to NOOP event --- fsw/src/ci_lab_cmds.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fsw/src/ci_lab_cmds.c b/fsw/src/ci_lab_cmds.c index bda0665..2a02fe8 100644 --- a/fsw/src/ci_lab_cmds.c +++ b/fsw/src/ci_lab_cmds.c @@ -27,6 +27,7 @@ #include "ci_lab_app.h" #include "ci_lab_cmds.h" +#include "ci_lab_version.h" /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* */ @@ -39,7 +40,8 @@ CFE_Status_t CI_LAB_NoopCmd(const CI_LAB_NoopCmd_t *cmd) /* Does everything the name implies */ CI_LAB_Global.HkTlm.Payload.CommandCounter++; - CFE_EVS_SendEvent(CI_LAB_NOOP_INF_EID, CFE_EVS_EventType_INFORMATION, "CI: NOOP command"); + CFE_EVS_SendEvent(CI_LAB_NOOP_INF_EID, CFE_EVS_EventType_INFORMATION, "CI: NOOP command. Version %d.%d.%d.%d", + CI_LAB_MAJOR_VERSION, CI_LAB_MINOR_VERSION, CI_LAB_REVISION, CI_LAB_MISSION_REV); return CFE_SUCCESS; } From baed83d19b3d4da8c51dd86d97e27785ba904a5c Mon Sep 17 00:00:00 2001 From: Dylan Date: Mon, 13 Nov 2023 13:27:58 -0500 Subject: [PATCH 11/11] Updating documentation and version numbers for v2.5.0-rc4+dev69 --- CHANGELOG.md | 5 +++++ fsw/src/ci_lab_version.h | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2895d28..fd706b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## Development Build: v2.5.0-rc4+dev69 +- add decode hooks +- Add version information to NOOP event +- See and + ## Development Build: v2.5.0-rc4+dev51 - reorganize source files - See diff --git a/fsw/src/ci_lab_version.h b/fsw/src/ci_lab_version.h index c242a62..cd7e58e 100644 --- a/fsw/src/ci_lab_version.h +++ b/fsw/src/ci_lab_version.h @@ -25,7 +25,7 @@ /* Development Build Macro Definitions */ -#define CI_LAB_BUILD_NUMBER 51 /*!< Development Build: Number of commits since baseline */ +#define CI_LAB_BUILD_NUMBER 69 /*!< Development Build: Number of commits since baseline */ #define CI_LAB_BUILD_BASELINE \ "v2.5.0-rc4" /*!< Development Build: git tag that is the base for the current development */