refactored TcPacketCheck into TcPacketCheckIF to implement a CFDP packet checker

This commit is contained in:
tomatze 2021-07-04 16:20:26 +02:00
parent 8a4ce91501
commit 4860d984f3
8 changed files with 101 additions and 25 deletions

View File

@ -1,10 +1,9 @@
#ifndef FSFW_TCDISTRIBUTION_CFDPDISTRIBUTOR_H_ #ifndef FSFW_TCDISTRIBUTION_CFDPDISTRIBUTOR_H_
#define FSFW_TCDISTRIBUTION_CFDPDISTRIBUTOR_H_ #define FSFW_TCDISTRIBUTION_CFDPDISTRIBUTOR_H_
#include "TcPacketCheckCFDP.h"
#include "CFDPDistributorIF.h" #include "CFDPDistributorIF.h"
#include "TcDistributor.h" #include "TcDistributor.h"
#include "TcPacketCheck.h"
#include "../tmtcpacket/pus/tc.h" #include "../tmtcpacket/pus/tc.h"
#include "../returnvalues/HasReturnvaluesIF.h" #include "../returnvalues/HasReturnvaluesIF.h"
#include "../tmtcservices/AcceptsTelecommandsIF.h" #include "../tmtcservices/AcceptsTelecommandsIF.h"
@ -43,7 +42,7 @@ protected:
/** /**
* This attribute contains the class, that performs a formal packet check. * This attribute contains the class, that performs a formal packet check.
*/ */
TcPacketCheck checker; TcPacketCheckCFDP checker;
/** /**
* With this class, verification messages are sent to the * With this class, verification messages are sent to the
* TC Verification service. * TC Verification service.

View File

@ -2,7 +2,8 @@ target_sources(${LIB_FSFW_NAME} PRIVATE
CCSDSDistributor.cpp CCSDSDistributor.cpp
PUSDistributor.cpp PUSDistributor.cpp
TcDistributor.cpp TcDistributor.cpp
TcPacketCheck.cpp TcPacketCheckPUS.cpp
TcPacketCheckCFDP.cpp
CFDPDistributor.cpp CFDPDistributor.cpp
) )

View File

@ -1,10 +1,9 @@
#ifndef FSFW_TCDISTRIBUTION_PUSDISTRIBUTOR_H_ #ifndef FSFW_TCDISTRIBUTION_PUSDISTRIBUTOR_H_
#define FSFW_TCDISTRIBUTION_PUSDISTRIBUTOR_H_ #define FSFW_TCDISTRIBUTION_PUSDISTRIBUTOR_H_
#include "TcPacketCheckPUS.h"
#include "PUSDistributorIF.h" #include "PUSDistributorIF.h"
#include "TcDistributor.h" #include "TcDistributor.h"
#include "TcPacketCheck.h"
#include "../tmtcpacket/pus/tc.h" #include "../tmtcpacket/pus/tc.h"
#include "../returnvalues/HasReturnvaluesIF.h" #include "../returnvalues/HasReturnvaluesIF.h"
#include "../tmtcservices/AcceptsTelecommandsIF.h" #include "../tmtcservices/AcceptsTelecommandsIF.h"
@ -43,7 +42,7 @@ protected:
/** /**
* This attribute contains the class, that performs a formal packet check. * This attribute contains the class, that performs a formal packet check.
*/ */
TcPacketCheck checker; TcPacketCheckPUS checker;
/** /**
* With this class, verification messages are sent to the * With this class, verification messages are sent to the
* TC Verification service. * TC Verification service.

View File

@ -0,0 +1,13 @@
#include "TcPacketCheckCFDP.h"
TcPacketCheckCFDP::TcPacketCheckCFDP(uint16_t setApid): apid(setApid) {
}
ReturnValue_t TcPacketCheckCFDP::checkPacket(TcPacketStoredBase* currentPacket) {
return RETURN_OK;
}
uint16_t TcPacketCheckCFDP::getApid() const {
return apid;
}

View File

@ -0,0 +1,35 @@
#ifndef FSFW_TCDISTRIBUTION_TCPACKETCHECKCFDP_H_
#define FSFW_TCDISTRIBUTION_TCPACKETCHECKCFDP_H_
#include "TcPacketCheckIF.h"
#include "../FSFW.h"
class TcPacketStoredBase;
/**
* This class performs a formal packet check for incoming CFDP Packets.
* @ingroup tc_distribution
*/
class TcPacketCheckCFDP :
public TcPacketCheckIF,
public HasReturnvaluesIF {
protected:
/**
* The packet id each correct packet should have.
* It is composed of the APID and some static fields.
*/
uint16_t apid;
public:
/**
* The constructor only sets the APID attribute.
* @param set_apid The APID to set.
*/
TcPacketCheckCFDP(uint16_t setApid);
ReturnValue_t checkPacket(TcPacketStoredBase* currentPacket) override;
uint16_t getApid() const;
};
#endif /* FSFW_TCDISTRIBUTION_TCPACKETCHECKCFDP_H_ */

View File

@ -0,0 +1,32 @@
#ifndef FSFW_TCDISTRIBUTION_TCPACKETCHECKIF_H_
#define FSFW_TCDISTRIBUTION_TCPACKETCHECKIF_H_
#include "../returnvalues/HasReturnvaluesIF.h"
// TODO TcPacketStoredBase is currently only for PUS packets. not for CFDP packets
class TcPacketStoredBase;
/**
* This interface is used by PacketCheckers for PUS packets and CFDP packets .
* @ingroup tc_distribution
*/
class TcPacketCheckIF {
public:
/**
* The empty virtual destructor.
*/
virtual ~TcPacketCheckIF() {
}
/**
* This is the actual method to formally check a certain Packet.
* The packet's Application Data can not be checked here.
* @param current_packet The packet to check
* @return - @c RETURN_OK on success.
* - @c INCORRECT_CHECKSUM if checksum is invalid.
* - @c ILLEGAL_APID if APID does not match.
*/
virtual ReturnValue_t checkPacket(TcPacketStoredBase* currentPacket) = 0;
};
#endif /* FSFW_TCDISTRIBUTION_TCPACKETCHECKIF_H_ */

View File

@ -1,4 +1,4 @@
#include "TcPacketCheck.h" #include "TcPacketCheckPUS.h"
#include "../globalfunctions/CRC.h" #include "../globalfunctions/CRC.h"
#include "../tmtcpacket/pus/tc/TcPacketBase.h" #include "../tmtcpacket/pus/tc/TcPacketBase.h"
@ -7,10 +7,10 @@
#include "../storagemanager/StorageManagerIF.h" #include "../storagemanager/StorageManagerIF.h"
#include "../tmtcservices/VerificationCodes.h" #include "../tmtcservices/VerificationCodes.h"
TcPacketCheck::TcPacketCheck(uint16_t setApid): apid(setApid) { TcPacketCheckPUS::TcPacketCheckPUS(uint16_t setApid): apid(setApid) {
} }
ReturnValue_t TcPacketCheck::checkPacket(TcPacketStoredBase* currentPacket) { ReturnValue_t TcPacketCheckPUS::checkPacket(TcPacketStoredBase* currentPacket) {
TcPacketBase* tcPacketBase = currentPacket->getPacketBase(); TcPacketBase* tcPacketBase = currentPacket->getPacketBase();
if(tcPacketBase == nullptr) { if(tcPacketBase == nullptr) {
return RETURN_FAILED; return RETURN_FAILED;
@ -41,6 +41,6 @@ ReturnValue_t TcPacketCheck::checkPacket(TcPacketStoredBase* currentPacket) {
return RETURN_OK; return RETURN_OK;
} }
uint16_t TcPacketCheck::getApid() const { uint16_t TcPacketCheckPUS::getApid() const {
return apid; return apid;
} }

View File

@ -1,5 +1,7 @@
#ifndef FSFW_TCDISTRIBUTION_TCPACKETCHECK_H_ #ifndef FSFW_TCDISTRIBUTION_TCPACKETCHECKPUS_H_
#define FSFW_TCDISTRIBUTION_TCPACKETCHECK_H_ #define FSFW_TCDISTRIBUTION_TCPACKETCHECKPUS_H_
#include "TcPacketCheckIF.h"
#include "../FSFW.h" #include "../FSFW.h"
#include "../returnvalues/HasReturnvaluesIF.h" #include "../returnvalues/HasReturnvaluesIF.h"
@ -12,7 +14,9 @@ class TcPacketStoredBase;
* Currently, it only checks if the APID and CRC are correct. * Currently, it only checks if the APID and CRC are correct.
* @ingroup tc_distribution * @ingroup tc_distribution
*/ */
class TcPacketCheck : public HasReturnvaluesIF { class TcPacketCheckPUS :
public TcPacketCheckIF,
public HasReturnvaluesIF {
protected: protected:
/** /**
* Describes the version number a packet must have to pass. * Describes the version number a packet must have to pass.
@ -49,18 +53,11 @@ public:
* The constructor only sets the APID attribute. * The constructor only sets the APID attribute.
* @param set_apid The APID to set. * @param set_apid The APID to set.
*/ */
TcPacketCheck(uint16_t setApid); TcPacketCheckPUS(uint16_t setApid);
/**
* This is the actual method to formally check a certain Telecommand Packet. ReturnValue_t checkPacket(TcPacketStoredBase* currentPacket) override;
* The packet's Application Data can not be checked here.
* @param current_packet The packt to check
* @return - @c RETURN_OK on success.
* - @c INCORRECT_CHECKSUM if checksum is invalid.
* - @c ILLEGAL_APID if APID does not match.
*/
ReturnValue_t checkPacket(TcPacketStoredBase* currentPacket);
uint16_t getApid() const; uint16_t getApid() const;
}; };
#endif /* FSFW_TCDISTRIBUTION_TCPACKETCHECK_H_ */ #endif /* FSFW_TCDISTRIBUTION_TCPACKETCHECKPUS_H_ */