From c599714aea0834a98482e898389b313c4441916c Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 11 Nov 2022 15:39:27 +0100 Subject: [PATCH] some sort of filter handling --- bsp_q7s/core/ObjectFactory.cpp | 8 +++---- fsfw | 2 +- mission/tmtc/CMakeLists.txt | 10 +++++++-- mission/tmtc/TmStore.cpp | 39 ++++++++++++++++++++++++++++++++-- mission/tmtc/TmStore.h | 19 ++++++----------- 5 files changed, 57 insertions(+), 21 deletions(-) diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index 6dc08ca1..b110e82a 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -574,7 +574,7 @@ void ObjectFactory::createSolarArrayDeploymentComponents(PowerSwitchIF& pwrSwitc void ObjectFactory::createSyrlinksComponents(PowerSwitchIF* pwrSwitcher) { auto* syrlinksUartCookie = new SerialCookie(objects::SYRLINKS_HK_HANDLER, q7s::UART_SYRLINKS_DEV, uart::SYRLINKS_BAUD, - syrlinks::MAX_REPLY_SIZE, UartModes::NON_CANONICAL); + syrlinks::MAX_REPLY_SIZE, UartModes::NON_CANONICAL); syrlinksUartCookie->setParityEven(); auto syrlinksFdir = new SyrlinksFdir(objects::SYRLINKS_HK_HANDLER); @@ -603,7 +603,7 @@ void ObjectFactory::createPayloadComponents(LinuxLibgpioIF* gpioComIF, PowerSwit gpioChecker(gpioComIF->addGpios(mpsocGpioCookie), "PLOC MPSoC"); auto mpsocCookie = new SerialCookie(objects::PLOC_MPSOC_HANDLER, q7s::UART_PLOC_MPSOC_DEV, uart::PLOC_MPSOC_BAUD, - mpsoc::MAX_REPLY_SIZE, UartModes::NON_CANONICAL); + mpsoc::MAX_REPLY_SIZE, UartModes::NON_CANONICAL); mpsocCookie->setNoFixedSizeReply(); auto plocMpsocHelper = new PlocMPSoCHelper(objects::PLOC_MPSOC_HELPER); auto* mpsocHandler = new PlocMPSoCHandler( @@ -620,7 +620,7 @@ void ObjectFactory::createPayloadComponents(LinuxLibgpioIF* gpioComIF, PowerSwit gpioComIF->addGpios(supvGpioCookie); auto supervisorCookie = new SerialCookie(objects::PLOC_SUPERVISOR_HANDLER, q7s::UART_PLOC_SUPERVSIOR_DEV, - uart::PLOC_SUPV_BAUD, supv::MAX_PACKET_SIZE * 20, UartModes::NON_CANONICAL); + uart::PLOC_SUPV_BAUD, supv::MAX_PACKET_SIZE * 20, UartModes::NON_CANONICAL); supervisorCookie->setNoFixedSizeReply(); auto supvHelper = new PlocSupvHelper(objects::PLOC_SUPERVISOR_HELPER); auto* supvHandler = new PlocSupervisorHandler( @@ -907,7 +907,7 @@ void ObjectFactory::createTestComponents(LinuxLibgpioIF* gpioComIF) { void ObjectFactory::createStrComponents(PowerSwitchIF* pwrSwitcher) { auto* starTrackerCookie = new SerialCookie(objects::STAR_TRACKER, q7s::UART_STAR_TRACKER_DEV, uart::STAR_TRACKER_BAUD, - startracker::MAX_FRAME_SIZE * 2 + 2, UartModes::NON_CANONICAL); + startracker::MAX_FRAME_SIZE * 2 + 2, UartModes::NON_CANONICAL); starTrackerCookie->setNoFixedSizeReply(); StrHelper* strHelper = new StrHelper(objects::STR_HELPER); auto starTracker = diff --git a/fsfw b/fsfw index 046dbe1d..2b6a33e7 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 046dbe1deb8053f64d7ef85992dec22aea9a3a10 +Subproject commit 2b6a33e718f896300ca08345a9211c2ae974d014 diff --git a/mission/tmtc/CMakeLists.txt b/mission/tmtc/CMakeLists.txt index 3c631be7..cc84aabb 100644 --- a/mission/tmtc/CMakeLists.txt +++ b/mission/tmtc/CMakeLists.txt @@ -1,4 +1,10 @@ target_sources( ${LIB_EIVE_MISSION} - PRIVATE CcsdsIpCoreHandler.cpp VirtualChannel.cpp TmFunnelHandler.cpp - TmFunnelBase.cpp CfdpTmFunnel.cpp Service15TmStorage.cpp TmStore.cpp PusTmFunnel.cpp) + PRIVATE CcsdsIpCoreHandler.cpp + VirtualChannel.cpp + TmFunnelHandler.cpp + TmFunnelBase.cpp + CfdpTmFunnel.cpp + Service15TmStorage.cpp + TmStore.cpp + PusTmFunnel.cpp) diff --git a/mission/tmtc/TmStore.cpp b/mission/tmtc/TmStore.cpp index 12e1f4d3..3033b001 100644 --- a/mission/tmtc/TmStore.cpp +++ b/mission/tmtc/TmStore.cpp @@ -1,14 +1,49 @@ #include "TmStore.h" + #include +#include using namespace returnvalue; -TmStore::TmStore(object_id_t objectId, SdCardMountedIF& sdcMan) - : SystemObject(objectId), sdcMan(sdcMan) {} +TmStore::TmStore(object_id_t objectId, std::string baseName, PacketFilter filter, SdCardMountedIF& sdcMan) + : SystemObject(objectId), filter(filter), sdcMan(sdcMan) {} ReturnValue_t TmStore::passPacket(PusTmReader& reader) { + bool inApidList = false; + if (filter.apid) { + auto& apidFilter = filter.apid.value(); + if (std::find(apidFilter.begin(), apidFilter.end(), reader.getApid()) != apidFilter.end()) { + if (not filter.serviceSubservices and not filter.services) { + return storePacket(reader); + } + inApidList = true; + } + } + std::pair serviceSubservice; + serviceSubservice.first = reader.getService(); + serviceSubservice.second = reader.getSubService(); + if (filter.services) { + auto& serviceFilter = filter.services.value(); + if (std::find(serviceFilter.begin(), serviceFilter.end(), serviceSubservice.first) != + serviceFilter.end()) { + if (filter.apid and inApidList) { + return storePacket(reader); + } + } + } + if (filter.serviceSubservices) { + auto& serviceSubserviceFilter = filter.serviceSubservices.value(); + if (std::find(serviceSubserviceFilter.begin(), serviceSubserviceFilter.end(), + serviceSubservice) != serviceSubserviceFilter.end()) { + if (filter.apid and inApidList) { + return storePacket(reader); + } + } + } return returnvalue::OK; } +ReturnValue_t TmStore::storePacket(PusTmReader& reader) { return returnvalue::OK; } + MessageQueueId_t TmStore::getCommandQueue() { return MessageQueueIF::NO_QUEUE; } diff --git a/mission/tmtc/TmStore.h b/mission/tmtc/TmStore.h index 015feef6..7d8cb144 100644 --- a/mission/tmtc/TmStore.h +++ b/mission/tmtc/TmStore.h @@ -1,24 +1,24 @@ #ifndef MISSION_TMTC_TMSTOREBACKEND_H_ #define MISSION_TMTC_TMSTOREBACKEND_H_ -#include - #include #include #include #include +#include struct PacketFilter { - std::optional apid; - std::optional service; - std::optional> serviceSubservice; + std::optional> apid; + std::optional> services; + std::optional>> serviceSubservices; }; class TmStore : public SystemObject { public: - TmStore(object_id_t objectId, SdCardMountedIF& sdcMan); + TmStore(object_id_t objectId, std::string baseName, PacketFilter filter, SdCardMountedIF& sdcMan); ReturnValue_t passPacket(PusTmReader& reader); + ReturnValue_t storePacket(PusTmReader& reader); private: /** @@ -26,13 +26,8 @@ class TmStore : public SystemObject { * @return Id of command queue. */ MessageQueueId_t getCommandQueue(); - + PacketFilter filter; SdCardMountedIF& sdcMan; - - - std::vector apidToStore; - std::vector servicesToStore; - std::vector> serviceSubserviceCombinationToStore; }; #endif /* MISSION_TMTC_TMSTOREBACKEND_H_ */