From 0706028d8ca88170b71255575b5f3b5629c59e04 Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Wed, 13 Dec 2023 14:59:53 -0500 Subject: [PATCH] Fix #184, initial inclusion of EDS file --- CMakeLists.txt | 12 +- eds/to_lab.xml | 224 ++++++++++++++++++++++++++++++++++ fsw/src/to_lab_eds_dispatch.c | 91 ++++++++++++++ fsw/src/to_lab_eds_encode.c | 88 +++++++++++++ 4 files changed, 414 insertions(+), 1 deletion(-) create mode 100644 eds/to_lab.xml create mode 100644 fsw/src/to_lab_eds_dispatch.c create mode 100644 fsw/src/to_lab_eds_encode.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 376023f..bf23d3b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,9 +19,19 @@ endforeach() set(APP_SRC_FILES fsw/src/to_lab_app.c fsw/src/to_lab_cmds.c +) + +if (CFE_EDS_ENABLED_BUILD) + list(APPEND APP_SRC_FILES + fsw/src/to_lab_eds_dispatch.c + fsw/src/to_lab_eds_encode.c + ) +else() + list(APPEND APP_SRC_FILES fsw/src/to_lab_dispatch.c fsw/src/to_lab_passthru_encode.c -) + ) +endif() # Create the app module add_cfe_app(to_lab ${APP_SRC_FILES}) diff --git a/eds/to_lab.xml b/eds/to_lab.xml new file mode 100644 index 0000000..6fbe9d4 --- /dev/null +++ b/eds/to_lab.xml @@ -0,0 +1,224 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/fsw/src/to_lab_eds_dispatch.c b/fsw/src/to_lab_eds_dispatch.c new file mode 100644 index 0000000..5e955fd --- /dev/null +++ b/fsw/src/to_lab_eds_dispatch.c @@ -0,0 +1,91 @@ +/************************************************************************ +** +** GSC-18128-1, "Core Flight Executive Version 6.7" +** +** Copyright (c) 2006-2019 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_app.c +** +** Purpose: +** his file contains the source code for the TO lab application +** +** Notes: +** +*************************************************************************/ + +#include "to_lab_app.h" +#include "to_lab_eventids.h" +#include "to_lab_dispatch.h" +#include "to_lab_cmds.h" + +#include "to_lab_eds_dictionary.h" +#include "to_lab_eds_dispatcher.h" + +static const TO_LAB_Application_Component_Telecommand_DispatchTable_t TO_LAB_TC_DISPATCH_TABLE = { + .CMD = {.AddPacketCmd_indication = TO_LAB_AddPacketCmd, + .NoopCmd_indication = TO_LAB_NoopCmd, + .EnableOutputCmd_indication = TO_LAB_EnableOutputCmd, + .RemoveAllCmd_indication = TO_LAB_RemoveAllCmd, + .RemovePacketCmd_indication = TO_LAB_RemovePacketCmd, + .ResetCountersCmd_indication = TO_LAB_ResetCountersCmd, + .SendDataTypesCmd_indication = TO_LAB_SendDataTypesCmd}, + .SEND_HK = {.indication = TO_LAB_SendHkCmd}}; + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* */ +/* TO_LAB_TaskPipe() -- Process command pipe message */ +/* */ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +void TO_LAB_TaskPipe(const CFE_SB_Buffer_t *SbBufPtr) +{ + CFE_Status_t status; + CFE_SB_MsgId_t MsgId; + CFE_MSG_Size_t MsgSize; + CFE_MSG_FcnCode_t MsgFc; + + status = TO_LAB_Application_Component_Telecommand_Dispatch(CFE_SB_Telecommand_indication_Command_ID, SbBufPtr, + &TO_LAB_TC_DISPATCH_TABLE); + + if (status != CFE_SUCCESS) + { + CFE_MSG_GetMsgId(&SbBufPtr->Msg, &MsgId); + ++TO_LAB_Global.HkTlm.Payload.CommandErrorCounter; + + if (status == CFE_STATUS_UNKNOWN_MSG_ID) + { + CFE_EVS_SendEvent(TO_LAB_MID_ERR_EID, CFE_EVS_EventType_ERROR, + "L%d TO: Invalid Msg ID Rcvd 0x%x status=0x%08x", __LINE__, + (unsigned int)CFE_SB_MsgIdToValue(MsgId), (unsigned int)status); + } + else if (status == CFE_STATUS_WRONG_MSG_LENGTH) + { + CFE_MSG_GetSize(&SbBufPtr->Msg, &MsgSize); + CFE_MSG_GetFcnCode(&SbBufPtr->Msg, &MsgFc); + CFE_EVS_SendEvent(TO_LAB_MID_ERR_EID, CFE_EVS_EventType_ERROR, + "Invalid length for command: ID = 0x%X, CC = %d, length = %u", + (unsigned int)CFE_SB_MsgIdToValue(MsgId), (int)MsgFc, (unsigned int)MsgSize); + } + else + { + CFE_MSG_GetFcnCode(&SbBufPtr->Msg, &MsgFc); + 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)MsgFc); + ++TO_LAB_Global.HkTlm.Payload.CommandErrorCounter; + } + } +} /* End of TO_LAB_TaskPipe() */ diff --git a/fsw/src/to_lab_eds_encode.c b/fsw/src/to_lab_eds_encode.c new file mode 100644 index 0000000..a5afef7 --- /dev/null +++ b/fsw/src/to_lab_eds_encode.c @@ -0,0 +1,88 @@ +/************************************************************************ + * 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_config.h" +#include "cfe_sb.h" +#include "cfe_msg.h" +#include "cfe_error.h" + +#include "to_lab_app.h" +#include "to_lab_encode.h" + +#include "edslib_datatypedb.h" +#include "cfe_missionlib_api.h" +#include "cfe_missionlib_runtime.h" +#include "cfe_mission_eds_parameters.h" +#include "cfe_mission_eds_interface_parameters.h" + +CFE_Status_t TO_LAB_EncodeOutputMessage(const CFE_SB_Buffer_t *SourceBuffer, const void **DestBufferOut, + size_t *DestSizeOut) +{ + EdsLib_Id_t EdsId; + EdsLib_DataTypeDB_TypeInfo_t TypeInfo; + CFE_SB_SoftwareBus_PubSub_Interface_t PubSubParams; + CFE_SB_Publisher_Component_t PublisherParams; + uint16 TopicId; + int32 EdsStatus; + CFE_Status_t ResultStatus; + size_t SourceBufferSize; + + static CFE_HDR_TelemetryHeader_PackedBuffer_t NetworkBuffer; + + const EdsLib_DatabaseObject_t *EDS_DB = CFE_Config_GetObjPointer(CFE_CONFIGID_MISSION_EDS_DB); + + ResultStatus = CFE_MSG_GetSize(&SourceBuffer->Msg, &SourceBufferSize); + if (ResultStatus != CFE_SUCCESS) + { + return ResultStatus; + } + + CFE_MissionLib_Get_PubSub_Parameters(&PubSubParams, &SourceBuffer->Msg.BaseMsg); + CFE_MissionLib_UnmapPublisherComponent(&PublisherParams, &PubSubParams); + TopicId = PublisherParams.Telemetry.TopicId; + + EdsStatus = CFE_MissionLib_GetArgumentType(&CFE_SOFTWAREBUS_INTERFACE, CFE_SB_Telemetry_Interface_ID, TopicId, 1, 1, + &EdsId); + if (EdsStatus != CFE_MISSIONLIB_SUCCESS) + { + return CFE_STATUS_UNKNOWN_MSG_ID; + } + + EdsStatus = EdsLib_DataTypeDB_PackCompleteObject(EDS_DB, &EdsId, NetworkBuffer, SourceBuffer, 8 * sizeof(NetworkBuffer), + SourceBufferSize); + if (EdsStatus != EDSLIB_SUCCESS) + { + return CFE_SB_INTERNAL_ERR; + } + + EdsStatus = EdsLib_DataTypeDB_GetTypeInfo(EDS_DB, EdsId, &TypeInfo); + if (EdsStatus != EDSLIB_SUCCESS) + { + return CFE_SB_INTERNAL_ERR; + } + + *DestSizeOut = (TypeInfo.Size.Bits + 7) / 8; + *DestBufferOut = NetworkBuffer; + + return CFE_SUCCESS; +}