From b0e1480383227c410c4d8b890424fe7df785bc97 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 21 Jul 2021 21:56:31 +0200 Subject: [PATCH] pushed cfdp update --- src/fsfw/tcdistribution/CFDPDistributor.cpp | 27 ++++++++++++++----- src/fsfw/tcdistribution/CFDPDistributor.h | 2 ++ src/fsfw/tcdistribution/TcPacketCheckCFDP.cpp | 4 +-- src/fsfw/tcdistribution/TcPacketCheckCFDP.h | 4 +-- src/fsfw/tcdistribution/TcPacketCheckIF.h | 5 ++-- src/fsfw/tcdistribution/TcPacketCheckPUS.cpp | 8 +++--- src/fsfw/tcdistribution/TcPacketCheckPUS.h | 2 +- src/fsfw/tmtcservices/CommandingServiceBase.h | 1 - 8 files changed, 34 insertions(+), 19 deletions(-) diff --git a/src/fsfw/tcdistribution/CFDPDistributor.cpp b/src/fsfw/tcdistribution/CFDPDistributor.cpp index 37294988..d112dd8d 100644 --- a/src/fsfw/tcdistribution/CFDPDistributor.cpp +++ b/src/fsfw/tcdistribution/CFDPDistributor.cpp @@ -5,20 +5,21 @@ #include "fsfw/objectmanager/ObjectManager.h" -#define CFDP_DISTRIBUTOR_DEBUGGING 0 +#ifndef FSFW_CFDP_DISTRIBUTOR_DEBUGGING +#define FSFW_CFDP_DISTRIBUTOR_DEBUGGING 1 +#endif CFDPDistributor::CFDPDistributor(uint16_t setApid, object_id_t setObjectId, - object_id_t setPacketSource) : - TcDistributor(setObjectId), + object_id_t setPacketSource): + TcDistributor(setObjectId), apid(setApid), checker(setApid), tcStatus(RETURN_FAILED), packetSource(setPacketSource) { - this->apid = setApid; } CFDPDistributor::~CFDPDistributor() {} CFDPDistributor::TcMqMapIter CFDPDistributor::selectDestination() { -#if CFDP_DISTRIBUTOR_DEBUGGING == 1 - store_address_t storeId = this->currentMessage.getStorageId(); +#if FSFW_CFDP_DISTRIBUTOR_DEBUGGING == 1 + store_address_t storeId = this->currentMessage.getStorageId(); #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::debug << "CFDPDistributor::handlePacket received: " << storeId.poolIndex << ", " << storeId.packetIndex << std::endl; @@ -33,6 +34,18 @@ CFDPDistributor::TcMqMapIter CFDPDistributor::selectDestination() { } this->currentPacket->setStoreAddress(this->currentMessage.getStorageId()); if (currentPacket->getWholeData() != nullptr) { + tcStatus = checker.checkPacket(currentPacket); + if(tcStatus != HasReturnvaluesIF::RETURN_OK) { +#if FSFW_VERBOSE_LEVEL >= 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 + sif::debug << "PUSDistributor::handlePacket: Packet format invalid, code " << + static_cast(tcStatus) << std::endl; +#else + sif::printDebug("PUSDistributor::handlePacket: Packet format invalid, code %d\n", + static_cast(tcStatus)); +#endif +#endif + } queueMapIt = this->queueMap.find(0); } else { @@ -62,7 +75,7 @@ CFDPDistributor::TcMqMapIter CFDPDistributor::selectDestination() { ReturnValue_t CFDPDistributor::registerHandler(AcceptsTelecommandsIF* handler) { uint16_t handlerId = handler->getIdentifier(); //should be 0, because CFDPHandler does not set a set a service-ID -#if CFDP_DISTRIBUTOR_DEBUGGING == 1 +#if FSFW_CFDP_DISTRIBUTOR_DEBUGGING == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::info << "CFDPDistributor::registerHandler: Handler ID: " << static_cast(handlerId) << std::endl; #else diff --git a/src/fsfw/tcdistribution/CFDPDistributor.h b/src/fsfw/tcdistribution/CFDPDistributor.h index 12436be2..5c7513b3 100644 --- a/src/fsfw/tcdistribution/CFDPDistributor.h +++ b/src/fsfw/tcdistribution/CFDPDistributor.h @@ -1,6 +1,7 @@ #ifndef FSFW_TCDISTRIBUTION_CFDPDISTRIBUTOR_H_ #define FSFW_TCDISTRIBUTION_CFDPDISTRIBUTOR_H_ +#include #include "CFDPDistributorIF.h" #include "TcDistributor.h" #include "../tmtcpacket/cfdp/CFDPPacketStored.h" @@ -43,6 +44,7 @@ protected: * The currently handled packet is stored here. */ CFDPPacketStored* currentPacket = nullptr; + TcPacketCheckCFDP checker; /** * With this variable, the current check status is stored to generate * acceptance messages later. diff --git a/src/fsfw/tcdistribution/TcPacketCheckCFDP.cpp b/src/fsfw/tcdistribution/TcPacketCheckCFDP.cpp index f3811a04..43e5511b 100644 --- a/src/fsfw/tcdistribution/TcPacketCheckCFDP.cpp +++ b/src/fsfw/tcdistribution/TcPacketCheckCFDP.cpp @@ -1,10 +1,10 @@ #include "fsfw/tcdistribution/TcPacketCheckCFDP.h" - +#include "fsfw/tmtcpacket/cfdp/CFDPPacketStored.h" TcPacketCheckCFDP::TcPacketCheckCFDP(uint16_t setApid): apid(setApid) { } -ReturnValue_t TcPacketCheckCFDP::checkPacket(TcPacketStoredBase* currentPacket) { +ReturnValue_t TcPacketCheckCFDP::checkPacket(SpacePacketBase* currentPacket) { return RETURN_OK; } diff --git a/src/fsfw/tcdistribution/TcPacketCheckCFDP.h b/src/fsfw/tcdistribution/TcPacketCheckCFDP.h index 49f4391d..8205fe4b 100644 --- a/src/fsfw/tcdistribution/TcPacketCheckCFDP.h +++ b/src/fsfw/tcdistribution/TcPacketCheckCFDP.h @@ -5,7 +5,7 @@ #include "fsfw/FSFW.h" -class TcPacketStoredBase; +class CFDPPacketStored; /** * This class performs a formal packet check for incoming CFDP Packets. @@ -27,7 +27,7 @@ public: */ TcPacketCheckCFDP(uint16_t setApid); - ReturnValue_t checkPacket(TcPacketStoredBase* currentPacket) override; + ReturnValue_t checkPacket(SpacePacketBase* currentPacket) override; uint16_t getApid() const; }; diff --git a/src/fsfw/tcdistribution/TcPacketCheckIF.h b/src/fsfw/tcdistribution/TcPacketCheckIF.h index 58c17021..ac1dfef9 100644 --- a/src/fsfw/tcdistribution/TcPacketCheckIF.h +++ b/src/fsfw/tcdistribution/TcPacketCheckIF.h @@ -3,8 +3,7 @@ #include "../returnvalues/HasReturnvaluesIF.h" -// TODO TcPacketStoredBase is currently only for PUS packets. not for CFDP packets -class TcPacketStoredBase; +class SpacePacketBase; /** * This interface is used by PacketCheckers for PUS packets and CFDP packets . @@ -26,7 +25,7 @@ public: * - @c INCORRECT_CHECKSUM if checksum is invalid. * - @c ILLEGAL_APID if APID does not match. */ - virtual ReturnValue_t checkPacket(TcPacketStoredBase* currentPacket) = 0; + virtual ReturnValue_t checkPacket(SpacePacketBase* currentPacket) = 0; }; #endif /* FSFW_TCDISTRIBUTION_TCPACKETCHECKIF_H_ */ diff --git a/src/fsfw/tcdistribution/TcPacketCheckPUS.cpp b/src/fsfw/tcdistribution/TcPacketCheckPUS.cpp index 5f9cfaf6..06acb518 100644 --- a/src/fsfw/tcdistribution/TcPacketCheckPUS.cpp +++ b/src/fsfw/tcdistribution/TcPacketCheckPUS.cpp @@ -1,6 +1,7 @@ #include "fsfw/tcdistribution/TcPacketCheckPUS.h" #include "fsfw/globalfunctions/CRC.h" +#include "fsfw/tmtcpacket/pus/tc/TcPacketStoredPus.h" #include "fsfw/tmtcpacket/pus/tc/TcPacketBase.h" #include "fsfw/tmtcpacket/pus/tc/TcPacketStoredBase.h" #include "fsfw/serviceinterface/ServiceInterface.h" @@ -10,8 +11,9 @@ TcPacketCheckPUS::TcPacketCheckPUS(uint16_t setApid): apid(setApid) { } -ReturnValue_t TcPacketCheckPUS::checkPacket(TcPacketStoredBase* currentPacket) { - TcPacketBase* tcPacketBase = currentPacket->getPacketBase(); +ReturnValue_t TcPacketCheckPUS::checkPacket(SpacePacketBase* currentPacket) { + TcPacketStoredBase* storedPacket = dynamic_cast(currentPacket); + TcPacketBase* tcPacketBase = storedPacket->getPacketBase(); if(tcPacketBase == nullptr) { return RETURN_FAILED; } @@ -29,7 +31,7 @@ ReturnValue_t TcPacketCheckPUS::checkPacket(TcPacketStoredBase* currentPacket) { if (tcPacketBase->getAPID() != this->apid) return ILLEGAL_APID; - if (not currentPacket->isSizeCorrect()) { + if (not storedPacket->isSizeCorrect()) { return INCOMPLETE_PACKET; } diff --git a/src/fsfw/tcdistribution/TcPacketCheckPUS.h b/src/fsfw/tcdistribution/TcPacketCheckPUS.h index f07cf89d..ae4c7789 100644 --- a/src/fsfw/tcdistribution/TcPacketCheckPUS.h +++ b/src/fsfw/tcdistribution/TcPacketCheckPUS.h @@ -55,7 +55,7 @@ public: */ TcPacketCheckPUS(uint16_t setApid); - ReturnValue_t checkPacket(TcPacketStoredBase* currentPacket) override; + ReturnValue_t checkPacket(SpacePacketBase* currentPacket) override; uint16_t getApid() const; }; diff --git a/src/fsfw/tmtcservices/CommandingServiceBase.h b/src/fsfw/tmtcservices/CommandingServiceBase.h index b6709693..ba026009 100644 --- a/src/fsfw/tmtcservices/CommandingServiceBase.h +++ b/src/fsfw/tmtcservices/CommandingServiceBase.h @@ -14,7 +14,6 @@ #include "fsfw/container/FIFO.h" #include "fsfw/serialize/SerializeIF.h" -class TcPacketStored; class TcPacketStoredBase; namespace Factory{