diff --git a/CHANGELOG.md b/CHANGELOG.md index 2000c4f4..c2c5d0ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,9 @@ list yields a list of all related PRs for each release. # [unreleased] +- Extended TM funnels to allow multiple TM recipients. + PR: https://egit.irs.uni-stuttgart.de/eive/eive-obsw/pulls/312 + # [v1.15.0] 27.10.2022 - Consistent device file naming diff --git a/bsp_hosted/ObjectFactory.cpp b/bsp_hosted/ObjectFactory.cpp index 29b1dda8..a3c94fe1 100644 --- a/bsp_hosted/ObjectFactory.cpp +++ b/bsp_hosted/ObjectFactory.cpp @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include #include @@ -59,7 +59,9 @@ void Factory::setStaticFrameworkObjectIds() { void ObjectFactory::produce(void* args) { Factory::setStaticFrameworkObjectIds(); - ObjectFactory::produceGenericObjects(); + PusTmFunnel* pusFunnel; + CfdpTmFunnel* cfdpFunnel; + ObjectFactory::produceGenericObjects(nullptr, &pusFunnel, &cfdpFunnel); dummy::DummyCfg cfg; dummy::createDummies(cfg); diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index d95fef7d..fe6e112d 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -30,11 +30,11 @@ #include "linux/devices/ploc/PlocSupervisorHandler.h" #include "linux/devices/startracker/StarTrackerHandler.h" #include "linux/devices/startracker/StrHelper.h" -#include "linux/obc/AxiPtmeConfig.h" -#include "linux/obc/PapbVcInterface.h" -#include "linux/obc/PdecHandler.h" -#include "linux/obc/Ptme.h" -#include "linux/obc/PtmeConfig.h" +#include "linux/ipcore/AxiPtmeConfig.h" +#include "linux/ipcore/PapbVcInterface.h" +#include "linux/ipcore/PdecHandler.h" +#include "linux/ipcore/Ptme.h" +#include "linux/ipcore/PtmeConfig.h" #include "mission/csp/CspCookie.h" #include "mission/system/fdir/AcsBoardFdir.h" #include "mission/system/fdir/GomspacePowerFdir.h" @@ -92,8 +92,8 @@ #include "mission/devices/devicedefinitions/SyrlinksDefinitions.h" #include "mission/devices/devicedefinitions/payloadPcduDefinitions.h" #include "mission/system/objects/AcsBoardAssembly.h" -#include "mission/tmtc/CCSDSHandler.h" -#include "mission/tmtc/TmFunnel.h" +#include "mission/tmtc/CcsdsIpCoreHandler.h" +#include "mission/tmtc/TmFunnelHandler.h" #include "mission/tmtc/VirtualChannel.h" ResetArgs RESET_ARGS_GNSS; @@ -705,7 +705,8 @@ void ObjectFactory::createReactionWheelComponents(LinuxLibgpioIF* gpioComIF, #endif /* OBSW_ADD_RW == 1 */ } -ReturnValue_t ObjectFactory::createCcsdsComponents(LinuxLibgpioIF* gpioComIF) { +ReturnValue_t ObjectFactory::createCcsdsComponents(LinuxLibgpioIF* gpioComIF, + CcsdsIpCoreHandler** ipCoreHandler) { using namespace gpio; // GPIO definitions of signals connected to the virtual channel interfaces of the PTME IP Core GpioCookie* gpioCookiePtmeIp = new GpioCookie; @@ -768,18 +769,19 @@ ReturnValue_t ObjectFactory::createCcsdsComponents(LinuxLibgpioIF* gpioComIF) { #else static const uint32_t TRANSMITTER_TIMEOUT = 900000; // 15 minutes #endif - CCSDSHandler* ccsdsHandler = new CCSDSHandler( + *ipCoreHandler = new CcsdsIpCoreHandler( objects::CCSDS_HANDLER, objects::PTME, objects::CCSDS_PACKET_DISTRIBUTOR, ptmeConfig, gpioComIF, gpioIds::RS485_EN_TX_CLOCK, gpioIds::RS485_EN_TX_DATA, TRANSMITTER_TIMEOUT); VirtualChannel* vc = nullptr; vc = new VirtualChannel(ccsds::VC0, common::VC0_QUEUE_SIZE, objects::CCSDS_HANDLER); - ccsdsHandler->addVirtualChannel(ccsds::VC0, vc); + (*ipCoreHandler)->addVirtualChannel(ccsds::VC0, vc); vc = new VirtualChannel(ccsds::VC1, common::VC1_QUEUE_SIZE, objects::CCSDS_HANDLER); - ccsdsHandler->addVirtualChannel(ccsds::VC1, vc); + (*ipCoreHandler)->addVirtualChannel(ccsds::VC1, vc); vc = new VirtualChannel(ccsds::VC2, common::VC2_QUEUE_SIZE, objects::CCSDS_HANDLER); - ccsdsHandler->addVirtualChannel(ccsds::VC2, vc); + (*ipCoreHandler)->addVirtualChannel(ccsds::VC2, vc); vc = new VirtualChannel(ccsds::VC3, common::VC3_QUEUE_SIZE, objects::CCSDS_HANDLER); - ccsdsHandler->addVirtualChannel(ccsds::VC3, vc); + (*ipCoreHandler)->addVirtualChannel(ccsds::VC3, vc); + GpioCookie* gpioCookiePdec = new GpioCookie; consumer.str(""); consumer << "0x" << std::hex << objects::PDEC_HANDLER; diff --git a/bsp_q7s/core/ObjectFactory.h b/bsp_q7s/core/ObjectFactory.h index 2947d786..3737db92 100644 --- a/bsp_q7s/core/ObjectFactory.h +++ b/bsp_q7s/core/ObjectFactory.h @@ -2,6 +2,9 @@ #define BSP_Q7S_OBJECTFACTORY_H_ #include +#include +#include +#include #include @@ -37,7 +40,7 @@ void createSolarArrayDeploymentComponents(PowerSwitchIF& pwrSwitcher, GpioIF& gp void createSyrlinksComponents(PowerSwitchIF* pwrSwitcher); void createPayloadComponents(LinuxLibgpioIF* gpioComIF); void createReactionWheelComponents(LinuxLibgpioIF* gpioComIF, PowerSwitchIF* pwrSwitcher); -ReturnValue_t createCcsdsComponents(LinuxLibgpioIF* gpioComIF); +ReturnValue_t createCcsdsComponents(LinuxLibgpioIF* gpioComIF, CcsdsIpCoreHandler** ipCoreHandler); void createMiscComponents(); void createTestComponents(LinuxLibgpioIF* gpioComIF); diff --git a/bsp_q7s/em/emObjectFactory.cpp b/bsp_q7s/em/emObjectFactory.cpp index 13ae55d6..ff3b57bb 100644 --- a/bsp_q7s/em/emObjectFactory.cpp +++ b/bsp_q7s/em/emObjectFactory.cpp @@ -17,7 +17,9 @@ void ObjectFactory::produce(void* args) { ObjectFactory::setStatics(); HealthTableIF* healthTable = nullptr; - ObjectFactory::produceGenericObjects(&healthTable); + PusTmFunnel* pusFunnel = nullptr; + CfdpTmFunnel* cfdpFunnel = nullptr; + ObjectFactory::produceGenericObjects(&healthTable, &pusFunnel, &cfdpFunnel); LinuxLibgpioIF* gpioComIF = nullptr; UartComIF* uartComIF = nullptr; @@ -75,7 +77,11 @@ void ObjectFactory::produce(void* args) { createStrComponents(pwrSwitcher); #endif /* OBSW_ADD_STAR_TRACKER == 1 */ #if OBSW_ADD_CCSDS_IP_CORES == 1 - createCcsdsComponents(gpioComIF); + CcsdsIpCoreHandler* ipCoreHandler = nullptr; + createCcsdsComponents(gpioComIF, &ipCoreHandler); +#if OBSW_TM_TO_PTME == 1 + ObjectFactory::addTmtcIpCoresToFunnels(*ipCoreHandler, *pusFunnel, *cfdpFunnel); +#endif #endif /* OBSW_ADD_CCSDS_IP_CORES == 1 */ /* Test Task */ #if OBSW_ADD_TEST_CODE == 1 diff --git a/bsp_q7s/fmObjectFactory.cpp b/bsp_q7s/fmObjectFactory.cpp index 19085541..a36b25d9 100644 --- a/bsp_q7s/fmObjectFactory.cpp +++ b/bsp_q7s/fmObjectFactory.cpp @@ -16,7 +16,9 @@ void ObjectFactory::produce(void* args) { ObjectFactory::setStatics(); HealthTableIF* healthTable = nullptr; - ObjectFactory::produceGenericObjects(&healthTable); + PusTmFunnel* pusFunnel = nullptr; + CfdpTmFunnel* cfdpFunnel = nullptr; + ObjectFactory::produceGenericObjects(&healthTable, &pusFunnel, &cfdpFunnel); LinuxLibgpioIF* gpioComIF = nullptr; UartComIF* uartComIF = nullptr; @@ -62,7 +64,11 @@ void ObjectFactory::produce(void* args) { createStrComponents(pwrSwitcher); #endif /* OBSW_ADD_STAR_TRACKER == 1 */ #if OBSW_ADD_CCSDS_IP_CORES == 1 - createCcsdsComponents(gpioComIF); + CcsdsIpCoreHandler* ipCoreHandler = nullptr; + createCcsdsComponents(gpioComIF, &ipCoreHandler); +#if OBSW_TM_TO_PTME == 1 + ObjectFactory::addTmtcIpCoresToFunnels(*ipCoreHandler, *pusFunnel, *cfdpFunnel); +#endif #endif /* OBSW_ADD_CCSDS_IP_CORES == 1 */ #if OBSW_ADD_SCEX_DEVICE == 1 diff --git a/linux/CMakeLists.txt b/linux/CMakeLists.txt index 861dfb5c..d7e6ca93 100644 --- a/linux/CMakeLists.txt +++ b/linux/CMakeLists.txt @@ -4,6 +4,6 @@ add_subdirectory(callbacks) add_subdirectory(boardtest) add_subdirectory(devices) add_subdirectory(fsfwconfig) -add_subdirectory(obc) +add_subdirectory(ipcore) target_sources(${OBSW_NAME} PUBLIC ObjectFactory.cpp InitMission.cpp) diff --git a/linux/ObjectFactory.cpp b/linux/ObjectFactory.cpp index d6e80dc1..271875d6 100644 --- a/linux/ObjectFactory.cpp +++ b/linux/ObjectFactory.cpp @@ -18,13 +18,14 @@ #include #include #include -#include -#include #include "OBSWConfig.h" #include "devConf.h" #include "devices/addresses.h" #include "devices/gpioIds.h" +#include "eive/definitions.h" +#include "mission/system/objects/SusAssembly.h" +#include "mission/system/objects/TcsBoardAssembly.h" #include "mission/system/tree/acsModeTree.h" void ObjectFactory::createSunSensorComponents(GpioIF* gpioComIF, SpiComIF* spiComIF, @@ -354,3 +355,9 @@ void ObjectFactory::gpioChecker(ReturnValue_t result, std::string output) { sif::error << "ObjectFactory: Adding GPIOs failed for " << output << std::endl; } } + +void ObjectFactory::addTmtcIpCoresToFunnels(CcsdsIpCoreHandler& ipCoreHandler, + PusTmFunnel& pusFunnel, CfdpTmFunnel& cfdpFunnel) { + cfdpFunnel.addDestination(ipCoreHandler, config::LIVE_TM); + pusFunnel.addDestination(ipCoreHandler, config::LIVE_TM); +} diff --git a/linux/ObjectFactory.h b/linux/ObjectFactory.h index 9c4ac63e..3704e9bd 100644 --- a/linux/ObjectFactory.h +++ b/linux/ObjectFactory.h @@ -4,6 +4,9 @@ #include #include #include +#include +#include +#include #include #include @@ -29,4 +32,7 @@ void gpioChecker(ReturnValue_t result, std::string output); void createThermalController(); AcsController* createAcsController(bool connectSubsystem); +void addTmtcIpCoresToFunnels(CcsdsIpCoreHandler& ipCoreHandler, PusTmFunnel& pusFunnel, + CfdpTmFunnel& cfdpFunnel); + } // namespace ObjectFactory diff --git a/linux/obc/AxiPtmeConfig.cpp b/linux/ipcore/AxiPtmeConfig.cpp similarity index 100% rename from linux/obc/AxiPtmeConfig.cpp rename to linux/ipcore/AxiPtmeConfig.cpp diff --git a/linux/obc/AxiPtmeConfig.h b/linux/ipcore/AxiPtmeConfig.h similarity index 100% rename from linux/obc/AxiPtmeConfig.h rename to linux/ipcore/AxiPtmeConfig.h diff --git a/linux/obc/CMakeLists.txt b/linux/ipcore/CMakeLists.txt similarity index 100% rename from linux/obc/CMakeLists.txt rename to linux/ipcore/CMakeLists.txt diff --git a/linux/obc/PapbVcInterface.cpp b/linux/ipcore/PapbVcInterface.cpp similarity index 98% rename from linux/obc/PapbVcInterface.cpp rename to linux/ipcore/PapbVcInterface.cpp index 1fbbe2ba..b8b12c7a 100644 --- a/linux/obc/PapbVcInterface.cpp +++ b/linux/ipcore/PapbVcInterface.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include "fsfw/serviceinterface/ServiceInterface.h" diff --git a/linux/obc/PapbVcInterface.h b/linux/ipcore/PapbVcInterface.h similarity index 98% rename from linux/obc/PapbVcInterface.h rename to linux/ipcore/PapbVcInterface.h index 6162765e..83081d9d 100644 --- a/linux/obc/PapbVcInterface.h +++ b/linux/ipcore/PapbVcInterface.h @@ -6,7 +6,7 @@ #include "OBSWConfig.h" #include "fsfw/returnvalues/returnvalue.h" -#include "linux/obc/VcInterfaceIF.h" +#include "linux/ipcore/VcInterfaceIF.h" /** * @brief This class handles the transmission of data to a virtual channel of the PTME IP Core diff --git a/linux/obc/PdecConfig.cpp b/linux/ipcore/PdecConfig.cpp similarity index 100% rename from linux/obc/PdecConfig.cpp rename to linux/ipcore/PdecConfig.cpp diff --git a/linux/obc/PdecConfig.h b/linux/ipcore/PdecConfig.h similarity index 100% rename from linux/obc/PdecConfig.h rename to linux/ipcore/PdecConfig.h diff --git a/linux/obc/PdecHandler.cpp b/linux/ipcore/PdecHandler.cpp similarity index 100% rename from linux/obc/PdecHandler.cpp rename to linux/ipcore/PdecHandler.cpp diff --git a/linux/obc/PdecHandler.h b/linux/ipcore/PdecHandler.h similarity index 100% rename from linux/obc/PdecHandler.h rename to linux/ipcore/PdecHandler.h diff --git a/linux/obc/Ptme.cpp b/linux/ipcore/Ptme.cpp similarity index 98% rename from linux/obc/Ptme.cpp rename to linux/ipcore/Ptme.cpp index 65705c2e..0c475236 100644 --- a/linux/obc/Ptme.cpp +++ b/linux/ipcore/Ptme.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include #include diff --git a/linux/obc/Ptme.h b/linux/ipcore/Ptme.h similarity index 96% rename from linux/obc/Ptme.h rename to linux/ipcore/Ptme.h index f76f7fd1..2de85a38 100644 --- a/linux/obc/Ptme.h +++ b/linux/ipcore/Ptme.h @@ -9,8 +9,8 @@ #include "OBSWConfig.h" #include "fsfw/returnvalues/returnvalue.h" -#include "linux/obc/PtmeIF.h" -#include "linux/obc/VcInterfaceIF.h" +#include "linux/ipcore/PtmeIF.h" +#include "linux/ipcore/VcInterfaceIF.h" /** * @brief This class handles the interfacing to the telemetry (PTME) IP core responsible for the diff --git a/linux/obc/PtmeConfig.cpp b/linux/ipcore/PtmeConfig.cpp similarity index 100% rename from linux/obc/PtmeConfig.cpp rename to linux/ipcore/PtmeConfig.cpp diff --git a/linux/obc/PtmeConfig.h b/linux/ipcore/PtmeConfig.h similarity index 98% rename from linux/obc/PtmeConfig.h rename to linux/ipcore/PtmeConfig.h index 9c5a85af..f57f6fb5 100644 --- a/linux/obc/PtmeConfig.h +++ b/linux/ipcore/PtmeConfig.h @@ -4,7 +4,7 @@ #include "AxiPtmeConfig.h" #include "fsfw/objectmanager/SystemObject.h" #include "fsfw/returnvalues/returnvalue.h" -#include "linux/obc/PtmeConfig.h" +#include "linux/ipcore/PtmeConfig.h" #include "returnvalues/classIds.h" /** diff --git a/linux/obc/PtmeIF.h b/linux/ipcore/PtmeIF.h similarity index 100% rename from linux/obc/PtmeIF.h rename to linux/ipcore/PtmeIF.h diff --git a/linux/obc/VcInterfaceIF.h b/linux/ipcore/VcInterfaceIF.h similarity index 100% rename from linux/obc/VcInterfaceIF.h rename to linux/ipcore/VcInterfaceIF.h diff --git a/mission/core/GenericFactory.cpp b/mission/core/GenericFactory.cpp index e81818e9..8f4924f1 100644 --- a/mission/core/GenericFactory.cpp +++ b/mission/core/GenericFactory.cpp @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include "OBSWConfig.h" #include "eive/definitions.h" @@ -66,7 +66,8 @@ EiveFaultHandler EIVE_FAULT_HANDLER; } // namespace cfdp -void ObjectFactory::produceGenericObjects(HealthTableIF** healthTable_) { +void ObjectFactory::produceGenericObjects(HealthTableIF** healthTable_, PusTmFunnel** pusFunnel, + CfdpTmFunnel** cfdpFunnel) { // Framework objects new EventManager(objects::EVENT_MANAGER); auto healthTable = new HealthTable(objects::HEALTH_TABLE); @@ -98,12 +99,12 @@ void ObjectFactory::produceGenericObjects(HealthTableIF** healthTable_) { #if OBSW_ADD_TCPIP_BRIDGE == 1 #if OBSW_USE_TMTC_TCP_BRIDGE == 0 - auto tmtcBridge = new UdpTmTcBridge(objects::TMTC_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR); + auto tcpIpTmtcBridge = new UdpTmTcBridge(objects::TMTC_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR); new UdpTcPollingTask(objects::TMTC_POLLING_TASK, objects::TMTC_BRIDGE); sif::info << "Created UDP server for TMTC commanding with listener port " << udpBridge->getUdpPort() << std::endl; #else - auto tmtcBridge = new TcpTmTcBridge(objects::TMTC_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR); + auto tcpIpTmtcBridge = new TcpTmTcBridge(objects::TMTC_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR); auto tcpServer = new TcpTmTcServer(objects::TMTC_POLLING_TASK, objects::TMTC_BRIDGE); // TCP is stream based. Use packet ID as start marker when parsing for space packets tcpServer->setSpacePacketParsingOptions({common::PUS_PACKET_ID, common::CFDP_PACKET_ID}); @@ -113,23 +114,21 @@ void ObjectFactory::produceGenericObjects(HealthTableIF** healthTable_) { tcpServer->enableWiretapping(true); #endif /* OBSW_TCP_SERVER_WIRETAPPING == 1 */ #endif /* OBSW_USE_TMTC_TCP_BRIDGE == 0 */ - tmtcBridge->setMaxNumberOfPacketsStored(300); + tcpIpTmtcBridge->setMaxNumberOfPacketsStored(300); #endif /* OBSW_ADD_TCPIP_BRIDGE == 1 */ auto* ccsdsDistrib = new CcsdsDistributor(config::EIVE_PUS_APID, objects::CCSDS_PACKET_DISTRIBUTOR); new PusDistributor(config::EIVE_PUS_APID, objects::PUS_PACKET_DISTRIBUTOR, ccsdsDistrib); - uint8_t vc = 0; -#if OBSW_TM_TO_PTME == 1 - vc = config::LIVE_TM; + *cfdpFunnel = new CfdpTmFunnel(objects::CFDP_TM_FUNNEL, config::EIVE_CFDP_APID, *tmStore); + *pusFunnel = new PusTmFunnel(objects::PUS_TM_FUNNEL, *timeStamper, *tmStore); +#if OBSW_ADD_TCPIP_BRIDGE == 1 + (*cfdpFunnel)->addDestination(*tcpIpTmtcBridge, 0); + (*pusFunnel)->addDestination(*tcpIpTmtcBridge, 0); #endif - auto* cfdpFunnel = - new CfdpTmFunnel(objects::CFDP_TM_FUNNEL, config::EIVE_CFDP_APID, *tmtcBridge, *tmStore, vc); - auto* pusFunnel = - new PusTmFunnel(objects::PUS_TM_FUNNEL, *tmtcBridge, *timeStamper, *tmStore, vc); // Every TM packet goes through this funnel - new TmFunnel(objects::TM_FUNNEL, *pusFunnel, *cfdpFunnel); + new TmFunnelHandler(objects::TM_FUNNEL, **pusFunnel, **cfdpFunnel); // PUS service stack new Service1TelecommandVerification(objects::PUS_SERVICE_1_VERIFICATION, config::EIVE_PUS_APID, @@ -165,7 +164,7 @@ void ObjectFactory::produceGenericObjects(HealthTableIF** healthTable_) { new CfdpDistributor(distribCfg); auto* msgQueue = QueueFactory::instance()->createMessageQueue(32); - FsfwHandlerParams params(objects::CFDP_HANDLER, HOST_FS, *cfdpFunnel, *tcStore, *tmStore, + FsfwHandlerParams params(objects::CFDP_HANDLER, HOST_FS, **cfdpFunnel, *tcStore, *tmStore, *msgQueue); cfdp::IndicationCfg indicationCfg; UnsignedByteField apid(config::EIVE_LOCAL_CFDP_ENTITY_ID); diff --git a/mission/core/GenericFactory.h b/mission/core/GenericFactory.h index 4bc6695d..2e2b0748 100644 --- a/mission/core/GenericFactory.h +++ b/mission/core/GenericFactory.h @@ -2,10 +2,13 @@ #define MISSION_CORE_GENERICFACTORY_H_ class HealthTableIF; +class PusTmFunnel; +class CfdpTmFunnel; namespace ObjectFactory { -void produceGenericObjects(HealthTableIF** healthTable = nullptr); +void produceGenericObjects(HealthTableIF** healthTable, PusTmFunnel** pusFunnel, + CfdpTmFunnel** cfdpFunnel); } diff --git a/mission/tmtc/CMakeLists.txt b/mission/tmtc/CMakeLists.txt index f34f9ccc..bb92a84e 100644 --- a/mission/tmtc/CMakeLists.txt +++ b/mission/tmtc/CMakeLists.txt @@ -1,3 +1,4 @@ target_sources( - ${LIB_EIVE_MISSION} PRIVATE CCSDSHandler.cpp VirtualChannel.cpp TmFunnel.cpp - CfdpTmFunnel.cpp PusTmFunnel.cpp) + ${LIB_EIVE_MISSION} + PRIVATE CcsdsIpCoreHandler.cpp VirtualChannel.cpp TmFunnelHandler.cpp + TmFunnelBase.cpp CfdpTmFunnel.cpp PusTmFunnel.cpp) diff --git a/mission/tmtc/CCSDSHandler.cpp b/mission/tmtc/CcsdsIpCoreHandler.cpp similarity index 73% rename from mission/tmtc/CCSDSHandler.cpp rename to mission/tmtc/CcsdsIpCoreHandler.cpp index 26abec25..c65a12a8 100644 --- a/mission/tmtc/CCSDSHandler.cpp +++ b/mission/tmtc/CcsdsIpCoreHandler.cpp @@ -1,7 +1,7 @@ -#include "CCSDSHandler.h" +#include "CcsdsIpCoreHandler.h" -#include -#include +#include +#include #include "fsfw/events/EventManagerIF.h" #include "fsfw/ipc/QueueFactory.h" @@ -11,9 +11,10 @@ #include "fsfw/serviceinterface/serviceInterfaceDefintions.h" #include "mission/devices/devicedefinitions/SyrlinksDefinitions.h" -CCSDSHandler::CCSDSHandler(object_id_t objectId, object_id_t ptmeId, object_id_t tcDestination, - PtmeConfig* ptmeConfig, GpioIF* gpioIF, gpioId_t enTxClock, - gpioId_t enTxData, uint32_t transmitterTimeout) +CcsdsIpCoreHandler::CcsdsIpCoreHandler(object_id_t objectId, object_id_t ptmeId, + object_id_t tcDestination, PtmeConfig* ptmeConfig, + GpioIF* gpioIF, gpioId_t enTxClock, gpioId_t enTxData, + uint32_t transmitterTimeout) : SystemObject(objectId), ptmeId(ptmeId), tcDestination(tcDestination), @@ -30,9 +31,9 @@ CCSDSHandler::CCSDSHandler(object_id_t objectId, object_id_t ptmeId, object_id_t QueueFactory::instance()->createMessageQueue(10, EventMessage::EVENT_MESSAGE_SIZE, &mqArgs); } -CCSDSHandler::~CCSDSHandler() {} +CcsdsIpCoreHandler::~CcsdsIpCoreHandler() {} -ReturnValue_t CCSDSHandler::performOperation(uint8_t operationCode) { +ReturnValue_t CcsdsIpCoreHandler::performOperation(uint8_t operationCode) { checkEvents(); readCommandQueue(); handleTelemetry(); @@ -41,16 +42,16 @@ ReturnValue_t CCSDSHandler::performOperation(uint8_t operationCode) { return returnvalue::OK; } -void CCSDSHandler::handleTelemetry() { +void CcsdsIpCoreHandler::handleTelemetry() { VirtualChannelMapIter iter; for (iter = virtualChannelMap.begin(); iter != virtualChannelMap.end(); iter++) { iter->second->performOperation(); } } -void CCSDSHandler::handleTelecommands() {} +void CcsdsIpCoreHandler::handleTelecommands() {} -ReturnValue_t CCSDSHandler::initialize() { +ReturnValue_t CcsdsIpCoreHandler::initialize() { ReturnValue_t result = returnvalue::OK; PtmeIF* ptme = ObjectManager::instance()->get(ptmeId); if (ptme == nullptr) { @@ -62,7 +63,7 @@ ReturnValue_t CCSDSHandler::initialize() { ObjectManager::instance()->get(tcDestination); if (tcDistributor == nullptr) { #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "CCSDSHandler::initialize: Invalid TC Distributor object" << std::endl; + sif::error << "CcsdsHandler::initialize: Invalid TC Distributor object" << std::endl; #endif return ObjectManagerIF::CHILD_INIT_FAILED; } @@ -91,14 +92,14 @@ ReturnValue_t CCSDSHandler::initialize() { EventManagerIF* manager = ObjectManager::instance()->get(objects::EVENT_MANAGER); if (manager == nullptr) { #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "CCSDSHandler::initialize: Invalid event manager" << std::endl; + sif::error << "CcsdsHandler::initialize: Invalid event manager" << std::endl; #endif return ObjectManagerIF::CHILD_INIT_FAILED; } result = manager->registerListener(eventQueue->getId()); if (result != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "CCSDSHandler::initialize: Failed to register CCSDS handler as event " + sif::warning << "CcsdsHandler::initialize: Failed to register CCSDS handler as event " "listener" << std::endl; #endif @@ -110,7 +111,7 @@ ReturnValue_t CCSDSHandler::initialize() { event::getEventId(PdecHandler::BIT_LOCK_PDEC)); if (result != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "CCSDSHandler::initialize: Failed to subscribe to events from PDEC " + sif::error << "CcsdsHandler::initialize: Failed to subscribe to events from PDEC " "handler" << std::endl; #endif @@ -136,7 +137,7 @@ ReturnValue_t CCSDSHandler::initialize() { return result; } -void CCSDSHandler::readCommandQueue(void) { +void CcsdsIpCoreHandler::readCommandQueue(void) { CommandMessage commandMessage; ReturnValue_t result = returnvalue::FAILED; @@ -157,61 +158,62 @@ void CCSDSHandler::readCommandQueue(void) { } } -MessageQueueId_t CCSDSHandler::getCommandQueue() const { return commandQueue->getId(); } +MessageQueueId_t CcsdsIpCoreHandler::getCommandQueue() const { return commandQueue->getId(); } -void CCSDSHandler::addVirtualChannel(VcId_t vcId, VirtualChannel* virtualChannel) { +void CcsdsIpCoreHandler::addVirtualChannel(VcId_t vcId, VirtualChannel* virtualChannel) { if (vcId > common::NUMBER_OF_VIRTUAL_CHANNELS) { - sif::warning << "CCSDSHandler::addVirtualChannel: Invalid virtual channel ID" << std::endl; + sif::warning << "CcsdsHandler::addVirtualChannel: Invalid virtual channel ID" << std::endl; return; } if (virtualChannel == nullptr) { - sif::warning << "CCSDSHandler::addVirtualChannel: Invalid virtual channel interface" + sif::warning << "CcsdsHandler::addVirtualChannel: Invalid virtual channel interface" << std::endl; return; } auto status = virtualChannelMap.emplace(vcId, virtualChannel); if (status.second == false) { - sif::warning << "CCSDSHandler::addVirtualChannel: Failed to add virtual channel to " + sif::warning << "CcsdsHandler::addVirtualChannel: Failed to add virtual channel to " "virtual channel map" << std::endl; return; } } -MessageQueueId_t CCSDSHandler::getReportReceptionQueue(uint8_t virtualChannel) const { +MessageQueueId_t CcsdsIpCoreHandler::getReportReceptionQueue(uint8_t virtualChannel) const { if (virtualChannel < common::NUMBER_OF_VIRTUAL_CHANNELS) { auto iter = virtualChannelMap.find(virtualChannel); if (iter != virtualChannelMap.end()) { return iter->second->getReportReceptionQueue(); } else { - sif::warning << "CCSDSHandler::getReportReceptionQueue: Virtual channel with ID " + sif::warning << "CcsdsHandler::getReportReceptionQueue: Virtual channel with ID " << static_cast(virtualChannel) << " not in virtual channel map" << std::endl; return MessageQueueIF::NO_QUEUE; } } else { - sif::debug << "CCSDSHandler::getReportReceptionQueue: Invalid virtual channel requested"; + sif::debug << "CcsdsHandler::getReportReceptionQueue: Invalid virtual channel requested"; } return MessageQueueIF::NO_QUEUE; } -ReturnValue_t CCSDSHandler::getParameter(uint8_t domainId, uint8_t uniqueIdentifier, - ParameterWrapper* parameterWrapper, - const ParameterWrapper* newValues, uint16_t startAtIndex) { +ReturnValue_t CcsdsIpCoreHandler::getParameter(uint8_t domainId, uint8_t uniqueIdentifier, + ParameterWrapper* parameterWrapper, + const ParameterWrapper* newValues, + uint16_t startAtIndex) { return returnvalue::OK; } -uint32_t CCSDSHandler::getIdentifier() const { return 0; } +uint32_t CcsdsIpCoreHandler::getIdentifier() const { return 0; } -MessageQueueId_t CCSDSHandler::getRequestQueue() const { +MessageQueueId_t CcsdsIpCoreHandler::getRequestQueue() const { // Forward packets directly to TC distributor return tcDistributorQueueId; } -ReturnValue_t CCSDSHandler::executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, - const uint8_t* data, size_t size) { +ReturnValue_t CcsdsIpCoreHandler::executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, + const uint8_t* data, size_t size) { ReturnValue_t result = returnvalue::OK; switch (actionId) { case SET_LOW_RATE: { @@ -261,7 +263,7 @@ ReturnValue_t CCSDSHandler::executeAction(ActionId_t actionId, MessageQueueId_t return EXECUTION_FINISHED; } -void CCSDSHandler::checkEvents() { +void CcsdsIpCoreHandler::checkEvents() { EventMessage event; for (ReturnValue_t result = eventQueue->receiveMessage(&event); result == returnvalue::OK; result = eventQueue->receiveMessage(&event)) { @@ -270,14 +272,14 @@ void CCSDSHandler::checkEvents() { handleEvent(&event); break; default: - sif::debug << "CCSDSHandler::checkEvents: Did not subscribe to this event message" + sif::debug << "CcsdsHandler::checkEvents: Did not subscribe to this event message" << std::endl; break; } } } -void CCSDSHandler::handleEvent(EventMessage* eventMessage) { +void CcsdsIpCoreHandler::handleEvent(EventMessage* eventMessage) { Event event = eventMessage->getEvent(); switch (event) { case PdecHandler::BIT_LOCK_PDEC: { @@ -289,12 +291,12 @@ void CCSDSHandler::handleEvent(EventMessage* eventMessage) { break; } default: - sif::debug << "CCSDSHandler::handleEvent: Did not subscribe to this event" << std::endl; + sif::debug << "CcsdsHandler::handleEvent: Did not subscribe to this event" << std::endl; break; } } -void CCSDSHandler::handleBitLockEvent() { +void CcsdsIpCoreHandler::handleBitLockEvent() { if (transmitterCountdown.isBusy()) { // Transmitter already enabled return; @@ -302,21 +304,21 @@ void CCSDSHandler::handleBitLockEvent() { enableTransmit(); } -void CCSDSHandler::handleCarrierLockEvent() { +void CcsdsIpCoreHandler::handleCarrierLockEvent() { if (!enableTxWhenCarrierLock) { return; } enableTransmit(); } -void CCSDSHandler::forwardLinkstate() { +void CcsdsIpCoreHandler::forwardLinkstate() { VirtualChannelMapIter iter; for (iter = virtualChannelMap.begin(); iter != virtualChannelMap.end(); iter++) { iter->second->setLinkState(linkState); } } -void CCSDSHandler::enableTransmit() { +void CcsdsIpCoreHandler::enableTransmit() { if (transmitterCountdown.isBusy()) { // Transmitter already enabled return; @@ -327,7 +329,7 @@ void CCSDSHandler::enableTransmit() { #endif } -void CCSDSHandler::checkTxTimer() { +void CcsdsIpCoreHandler::checkTxTimer() { if (linkState == DOWN) { return; } @@ -336,7 +338,7 @@ void CCSDSHandler::checkTxTimer() { } } -void CCSDSHandler::disableTransmit() { +void CcsdsIpCoreHandler::disableTransmit() { #ifndef TE0720_1CFA gpioIF->pullLow(enTxClock); gpioIF->pullLow(enTxData); @@ -346,4 +348,4 @@ void CCSDSHandler::disableTransmit() { transmitterCountdown.setTimeout(0); } -const char* CCSDSHandler::getName() const { return "CCSDS Handler"; } +const char* CcsdsIpCoreHandler::getName() const { return "CCSDS Handler"; } diff --git a/mission/tmtc/CCSDSHandler.h b/mission/tmtc/CcsdsIpCoreHandler.h similarity index 90% rename from mission/tmtc/CCSDSHandler.h rename to mission/tmtc/CcsdsIpCoreHandler.h index d76dbdaf..942b73cb 100644 --- a/mission/tmtc/CCSDSHandler.h +++ b/mission/tmtc/CcsdsIpCoreHandler.h @@ -17,7 +17,7 @@ #include "fsfw/tmtcservices/AcceptsTelemetryIF.h" #include "fsfw_hal/common/gpio/GpioIF.h" #include "fsfw_hal/common/gpio/gpioDefinitions.h" -#include "linux/obc/PtmeConfig.h" +#include "linux/ipcore/PtmeConfig.h" /** * @brief This class handles the data exchange with the CCSDS IP cores implemented in the @@ -28,12 +28,12 @@ * * @author J. Meier */ -class CCSDSHandler : public SystemObject, - public ExecutableObjectIF, - public AcceptsTelemetryIF, - public AcceptsTelecommandsIF, - public ReceivesParameterMessagesIF, - public HasActionsIF { +class CcsdsIpCoreHandler : public SystemObject, + public ExecutableObjectIF, + public AcceptsTelemetryIF, + public AcceptsTelecommandsIF, + public ReceivesParameterMessagesIF, + public HasActionsIF { public: using VcId_t = uint8_t; @@ -49,11 +49,11 @@ class CCSDSHandler : public SystemObject, * @param enTxClock GPIO ID of RS485 tx clock enable * @param enTxData GPIO ID of RS485 tx data enable */ - CCSDSHandler(object_id_t objectId, object_id_t ptmeId, object_id_t tcDestination, - PtmeConfig* ptmeConfig, GpioIF* gpioIF, gpioId_t enTxClock, gpioId_t enTxData, - uint32_t transmitterTimeout = 900000); + CcsdsIpCoreHandler(object_id_t objectId, object_id_t ptmeId, object_id_t tcDestination, + PtmeConfig* ptmeConfig, GpioIF* gpioIF, gpioId_t enTxClock, gpioId_t enTxData, + uint32_t transmitterTimeout = 900000); - ~CCSDSHandler(); + ~CcsdsIpCoreHandler(); ReturnValue_t performOperation(uint8_t operationCode = 0) override; ReturnValue_t initialize(); diff --git a/mission/tmtc/CfdpTmFunnel.cpp b/mission/tmtc/CfdpTmFunnel.cpp index 7969961b..33ecc034 100644 --- a/mission/tmtc/CfdpTmFunnel.cpp +++ b/mission/tmtc/CfdpTmFunnel.cpp @@ -5,29 +5,21 @@ #include "fsfw/tmtcservices/TmTcMessage.h" CfdpTmFunnel::CfdpTmFunnel(object_id_t objectId, uint16_t cfdpInCcsdsApid, - const AcceptsTelemetryIF& downlinkDestination, StorageManagerIF& tmStore, - uint8_t vc) - : SystemObject(objectId), cfdpInCcsdsApid(cfdpInCcsdsApid), tmStore(tmStore) { - msgQueue = QueueFactory::instance()->createMessageQueue(5); - msgQueue->setDefaultDestination(downlinkDestination.getReportReceptionQueue(vc)); -} + StorageManagerIF& tmStore) + : TmFunnelBase(objectId, tmStore, 10), cfdpInCcsdsApid(cfdpInCcsdsApid) {} const char* CfdpTmFunnel::getName() const { return "CFDP TM Funnel"; } -MessageQueueId_t CfdpTmFunnel::getReportReceptionQueue(uint8_t virtualChannel) const { - return msgQueue->getId(); -} - ReturnValue_t CfdpTmFunnel::performOperation(uint8_t) { TmTcMessage currentMessage; - ReturnValue_t status = msgQueue->receiveMessage(¤tMessage); + ReturnValue_t status = tmQueue->receiveMessage(¤tMessage); while (status == returnvalue::OK) { status = handlePacket(currentMessage); if (status != returnvalue::OK) { sif::warning << "CfdpTmFunnel packet handling failed" << std::endl; break; } - status = msgQueue->receiveMessage(¤tMessage); + status = tmQueue->receiveMessage(¤tMessage); } if (status == MessageQueueIF::EMPTY) { @@ -74,12 +66,27 @@ ReturnValue_t CfdpTmFunnel::handlePacket(TmTcMessage& msg) { // Delete old packet tmStore.deleteData(msg.getStorageId()); msg.setStorageId(newStoreId); - result = msgQueue->sendToDefault(&msg); - if (result != returnvalue::OK) { - tmStore.deleteData(msg.getStorageId()); + store_address_t origStoreId = newStoreId; + for (unsigned int idx = 0; idx < destinations.size(); idx++) { + const auto& destVcidPair = destinations[idx]; + if (destinations.size() > 1) { + if (idx <= destinations.size() - 1) { + // Create copy of data to ensure each TM recipient has its own copy. That way, we don't need + // to bother with send order and where the data is deleted. + store_address_t storeId; + result = tmStore.addData(&storeId, newPacketData, serSize); + msg.setStorageId(storeId); + } else { + msg.setStorageId(origStoreId); + } + } + result = tmQueue->sendMessage(destVcidPair.first, &msg); + if (result != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "CfdpTmFunnel::handlePacket: Error sending TM to downlink handler" << std::endl; + sif::error << "PusTmFunnel::handlePacket: Error sending TM to downlink handler" << std::endl; #endif + tmStore.deleteData(msg.getStorageId()); + } } return result; } diff --git a/mission/tmtc/CfdpTmFunnel.h b/mission/tmtc/CfdpTmFunnel.h index fe2d664d..a6d947fd 100644 --- a/mission/tmtc/CfdpTmFunnel.h +++ b/mission/tmtc/CfdpTmFunnel.h @@ -1,19 +1,19 @@ #ifndef FSFW_EXAMPLE_COMMON_CFDPTMFUNNEL_H #define FSFW_EXAMPLE_COMMON_CFDPTMFUNNEL_H +#include + +#include + #include "fsfw/objectmanager/SystemObject.h" #include "fsfw/storagemanager/StorageManagerIF.h" #include "fsfw/tmtcservices/AcceptsTelemetryIF.h" #include "fsfw/tmtcservices/TmTcMessage.h" -class CfdpTmFunnel : public AcceptsTelemetryIF, public SystemObject { +class CfdpTmFunnel : public TmFunnelBase { public: - CfdpTmFunnel(object_id_t objectId, uint16_t cfdpInCcsdsApid, - const AcceptsTelemetryIF& downlinkDestination, StorageManagerIF& tmStore, - uint8_t vc); + CfdpTmFunnel(object_id_t objectId, uint16_t cfdpInCcsdsApid, StorageManagerIF& tmStore); [[nodiscard]] const char* getName() const override; - [[nodiscard]] MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel) const override; - ReturnValue_t performOperation(uint8_t opCode); ReturnValue_t initialize() override; @@ -22,7 +22,5 @@ class CfdpTmFunnel : public AcceptsTelemetryIF, public SystemObject { uint16_t sourceSequenceCount = 0; uint16_t cfdpInCcsdsApid; - MessageQueueIF* msgQueue; - StorageManagerIF& tmStore; }; #endif // FSFW_EXAMPLE_COMMON_CFDPTMFUNNEL_H diff --git a/mission/tmtc/PusTmFunnel.cpp b/mission/tmtc/PusTmFunnel.cpp index f4072f0f..a776e6b9 100644 --- a/mission/tmtc/PusTmFunnel.cpp +++ b/mission/tmtc/PusTmFunnel.cpp @@ -4,21 +4,12 @@ #include "fsfw/objectmanager.h" #include "fsfw/tmtcpacket/pus/tm/PusTmZcWriter.h" -PusTmFunnel::PusTmFunnel(object_id_t objectId, const AcceptsTelemetryIF &downlinkDestination, - TimeReaderIF &timeReader, StorageManagerIF &tmStore, uint8_t vcId, +PusTmFunnel::PusTmFunnel(object_id_t objectId, TimeReaderIF &timeReader, StorageManagerIF &tmStore, uint32_t messageDepth) - : SystemObject(objectId), timeReader(timeReader), tmStore(tmStore) { - tmQueue = QueueFactory::instance()->createMessageQueue(messageDepth, - MessageQueueMessage::MAX_MESSAGE_SIZE); - tmQueue->setDefaultDestination(downlinkDestination.getReportReceptionQueue(vcId)); -} + : TmFunnelBase(objectId, tmStore, messageDepth), timeReader(timeReader) {} PusTmFunnel::~PusTmFunnel() = default; -MessageQueueId_t PusTmFunnel::getReportReceptionQueue(uint8_t virtualChannel) const { - return tmQueue->getId(); -} - ReturnValue_t PusTmFunnel::performOperation(uint8_t) { TmTcMessage currentMessage; ReturnValue_t status = tmQueue->receiveMessage(¤tMessage); @@ -40,7 +31,8 @@ ReturnValue_t PusTmFunnel::performOperation(uint8_t) { ReturnValue_t PusTmFunnel::handlePacket(TmTcMessage &message) { uint8_t *packetData = nullptr; size_t size = 0; - ReturnValue_t result = tmStore.modifyData(message.getStorageId(), &packetData, &size); + store_address_t origStoreId = message.getStorageId(); + ReturnValue_t result = tmStore.modifyData(origStoreId, &packetData, &size); if (result != returnvalue::OK) { return result; } @@ -56,12 +48,26 @@ ReturnValue_t PusTmFunnel::handlePacket(TmTcMessage &message) { sourceSequenceCount = sourceSequenceCount % ccsds::LIMIT_SEQUENCE_COUNT; packet.updateErrorControl(); - result = tmQueue->sendToDefault(&message); - if (result != returnvalue::OK) { - tmStore.deleteData(message.getStorageId()); + for (unsigned int idx = 0; idx < destinations.size(); idx++) { + const auto &destVcidPair = destinations[idx]; + if (destinations.size() > 1) { + if (idx <= destinations.size() - 1) { + // Create copy of data to ensure each TM recipient has its own copy. That way, we don't need + // to bother with send order and where the data is deleted. + store_address_t storeId; + result = tmStore.addData(&storeId, packetData, size); + message.setStorageId(storeId); + } else { + message.setStorageId(origStoreId); + } + } + result = tmQueue->sendMessage(destVcidPair.first, &message); + if (result != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "PusTmFunnel::handlePacket: Error sending TM to downlink handler" << std::endl; + sif::error << "PusTmFunnel::handlePacket: Error sending TM to downlink handler" << std::endl; #endif + tmStore.deleteData(message.getStorageId()); + } } return result; } diff --git a/mission/tmtc/PusTmFunnel.h b/mission/tmtc/PusTmFunnel.h index ae0390b3..ca9a6016 100644 --- a/mission/tmtc/PusTmFunnel.h +++ b/mission/tmtc/PusTmFunnel.h @@ -6,6 +6,9 @@ #include #include #include +#include + +#include #include "fsfw/timemanager/TimeReaderIF.h" @@ -20,22 +23,19 @@ * @ingroup utility * @author J. Meier, R. Mueller */ -class PusTmFunnel : public AcceptsTelemetryIF, public SystemObject { +class PusTmFunnel : public TmFunnelBase { public: - explicit PusTmFunnel(object_id_t objectId, const AcceptsTelemetryIF &downlinkDestination, - TimeReaderIF &timeReader, StorageManagerIF &tmStore, uint8_t vdId, - uint32_t messageDepth = 20); + explicit PusTmFunnel(object_id_t objectId, TimeReaderIF &timeReader, StorageManagerIF &tmStore, + uint32_t messageDepth = 10); [[nodiscard]] const char *getName() const override; ~PusTmFunnel() override; - [[nodiscard]] MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel) const override; ReturnValue_t performOperation(uint8_t operationCode); private: uint16_t sourceSequenceCount = 0; TimeReaderIF &timeReader; - StorageManagerIF &tmStore; - MessageQueueIF *tmQueue = nullptr; + ReturnValue_t handlePacket(TmTcMessage &message); }; diff --git a/mission/tmtc/TmFunnel.cpp b/mission/tmtc/TmFunnel.cpp deleted file mode 100644 index 01bf0437..00000000 --- a/mission/tmtc/TmFunnel.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include "TmFunnel.h" - -#include - -TmFunnel::TmFunnel(object_id_t objectId, PusTmFunnel& pusFunnel, CfdpTmFunnel& cfdpFunnel) - : SystemObject(objectId), pusFunnel(pusFunnel), cfdpFunnel(cfdpFunnel) {} - -TmFunnel::~TmFunnel() = default; - -ReturnValue_t TmFunnel::performOperation(uint8_t operationCode) { - pusFunnel.performOperation(operationCode); - cfdpFunnel.performOperation(operationCode); - return returnvalue::OK; -} - -ReturnValue_t TmFunnel::initialize() { return returnvalue::OK; } diff --git a/mission/tmtc/TmFunnelBase.cpp b/mission/tmtc/TmFunnelBase.cpp new file mode 100644 index 00000000..fa0062e6 --- /dev/null +++ b/mission/tmtc/TmFunnelBase.cpp @@ -0,0 +1,19 @@ +#include "TmFunnelBase.h" + +#include "fsfw/ipc/QueueFactory.h" + +TmFunnelBase::TmFunnelBase(object_id_t objectId, StorageManagerIF &tmStore, uint32_t tmMsgDepth) + : SystemObject(objectId), tmStore(tmStore) { + tmQueue = QueueFactory::instance()->createMessageQueue(tmMsgDepth); +} + +TmFunnelBase::~TmFunnelBase() { QueueFactory::instance()->deleteMessageQueue(tmQueue); } + +MessageQueueId_t TmFunnelBase::getReportReceptionQueue(uint8_t virtualChannel) const { + return tmQueue->getId(); +} + +void TmFunnelBase::addDestination(const AcceptsTelemetryIF &downlinkDestination, uint8_t vcid) { + auto queueId = downlinkDestination.getReportReceptionQueue(vcid); + destinations.emplace_back(queueId, vcid); +} diff --git a/mission/tmtc/TmFunnelBase.h b/mission/tmtc/TmFunnelBase.h new file mode 100644 index 00000000..c630fefd --- /dev/null +++ b/mission/tmtc/TmFunnelBase.h @@ -0,0 +1,24 @@ +#ifndef MISSION_TMTC_TMFUNNELBASE_H_ +#define MISSION_TMTC_TMFUNNELBASE_H_ + +#include +#include +#include + +#include + +class TmFunnelBase : public AcceptsTelemetryIF, public SystemObject { + public: + TmFunnelBase(object_id_t objectId, StorageManagerIF& tmStore, uint32_t tmMsgDepth); + void addDestination(const AcceptsTelemetryIF& downlinkDestination, uint8_t vcid = 0); + [[nodiscard]] MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel) const override; + + virtual ~TmFunnelBase(); + + protected: + StorageManagerIF& tmStore; + std::vector> destinations; + MessageQueueIF* tmQueue = nullptr; +}; + +#endif /* MISSION_TMTC_TMFUNNELBASE_H_ */ diff --git a/mission/tmtc/TmFunnelHandler.cpp b/mission/tmtc/TmFunnelHandler.cpp new file mode 100644 index 00000000..33f8addc --- /dev/null +++ b/mission/tmtc/TmFunnelHandler.cpp @@ -0,0 +1,17 @@ +#include "TmFunnelHandler.h" + +#include + +TmFunnelHandler::TmFunnelHandler(object_id_t objectId, PusTmFunnel& pusFunnel, + CfdpTmFunnel& cfdpFunnel) + : SystemObject(objectId), pusFunnel(pusFunnel), cfdpFunnel(cfdpFunnel) {} + +TmFunnelHandler::~TmFunnelHandler() = default; + +ReturnValue_t TmFunnelHandler::performOperation(uint8_t operationCode) { + pusFunnel.performOperation(operationCode); + cfdpFunnel.performOperation(operationCode); + return returnvalue::OK; +} + +ReturnValue_t TmFunnelHandler::initialize() { return returnvalue::OK; } diff --git a/mission/tmtc/TmFunnel.h b/mission/tmtc/TmFunnelHandler.h similarity index 80% rename from mission/tmtc/TmFunnel.h rename to mission/tmtc/TmFunnelHandler.h index 5441db2b..a101f361 100644 --- a/mission/tmtc/TmFunnel.h +++ b/mission/tmtc/TmFunnelHandler.h @@ -19,10 +19,10 @@ * @ingroup utility * @author J. Meier, R. Mueller */ -class TmFunnel : public ExecutableObjectIF, public SystemObject { +class TmFunnelHandler : public ExecutableObjectIF, public SystemObject { public: - TmFunnel(object_id_t objectId, PusTmFunnel& pusFunnel, CfdpTmFunnel& cfdpFunnel); - ~TmFunnel() override; + TmFunnelHandler(object_id_t objectId, PusTmFunnel& pusFunnel, CfdpTmFunnel& cfdpFunnel); + ~TmFunnelHandler() override; ReturnValue_t performOperation(uint8_t operationCode) override; ReturnValue_t initialize() override; diff --git a/mission/tmtc/VirtualChannel.cpp b/mission/tmtc/VirtualChannel.cpp index 96a37b3b..9fe47b1c 100644 --- a/mission/tmtc/VirtualChannel.cpp +++ b/mission/tmtc/VirtualChannel.cpp @@ -1,6 +1,6 @@ #include "VirtualChannel.h" -#include "CCSDSHandler.h" +#include "CcsdsIpCoreHandler.h" #include "OBSWConfig.h" #include "fsfw/ipc/QueueFactory.h" #include "fsfw/objectmanager/ObjectManager.h" diff --git a/mission/tmtc/VirtualChannel.h b/mission/tmtc/VirtualChannel.h index 024ccee6..96d7ba9d 100644 --- a/mission/tmtc/VirtualChannel.h +++ b/mission/tmtc/VirtualChannel.h @@ -2,7 +2,7 @@ #define VIRTUALCHANNEL_H_ #include -#include +#include #include "OBSWConfig.h" #include "fsfw/returnvalues/returnvalue.h"