added pus c support for tc
This commit is contained in:
@ -1,7 +1,6 @@
|
||||
target_sources(${LIB_FSFW_NAME}
|
||||
PRIVATE
|
||||
CCSDSDistributor.cpp
|
||||
PUSDistributor.cpp
|
||||
TcDistributor.cpp
|
||||
TcPacketCheck.cpp
|
||||
target_sources(${LIB_FSFW_NAME} PRIVATE
|
||||
CCSDSDistributor.cpp
|
||||
PUSDistributor.cpp
|
||||
TcDistributor.cpp
|
||||
TcPacketCheck.cpp
|
||||
)
|
||||
|
@ -3,7 +3,6 @@
|
||||
|
||||
#include "../objectmanager/ObjectManager.h"
|
||||
#include "../serviceinterface/ServiceInterface.h"
|
||||
#include "../tmtcpacket/pus/TcPacketStored.h"
|
||||
#include "../tmtcservices/PusVerificationReport.h"
|
||||
|
||||
#define PUS_DISTRIBUTOR_DEBUGGING 0
|
||||
@ -119,7 +118,11 @@ uint16_t PUSDistributor::getIdentifier() {
|
||||
}
|
||||
|
||||
ReturnValue_t PUSDistributor::initialize() {
|
||||
currentPacket = new TcPacketStored();
|
||||
#if FSFW_USE_PUS_C_TELECOMMANDS == 1
|
||||
currentPacket = new TcPacketStoredPusC();
|
||||
#else
|
||||
currentPacket = new TcPacketStoredPusA();
|
||||
#endif
|
||||
if(currentPacket == nullptr) {
|
||||
// Should not happen, memory allocation failed!
|
||||
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "TcDistributor.h"
|
||||
#include "TcPacketCheck.h"
|
||||
|
||||
#include "../tmtcpacket/pus/TcPacketStored.h"
|
||||
#include "../returnvalues/HasReturnvaluesIF.h"
|
||||
#include "../tmtcservices/AcceptsTelecommandsIF.h"
|
||||
#include "../tmtcservices/VerificationReporter.h"
|
||||
@ -51,7 +52,12 @@ protected:
|
||||
/**
|
||||
* The currently handled packet is stored here.
|
||||
*/
|
||||
TcPacketStored* currentPacket = nullptr;
|
||||
#if FSFW_USE_PUS_C_TELECOMMANDS == 1
|
||||
TcPacketStoredPusC* currentPacket = nullptr;
|
||||
#else
|
||||
TcPacketStoredPusA* currentPacket = nullptr;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* With this variable, the current check status is stored to generate
|
||||
* acceptance messages later.
|
||||
|
@ -1,39 +1,45 @@
|
||||
#include "TcPacketCheck.h"
|
||||
|
||||
#include "../globalfunctions/CRC.h"
|
||||
#include "../serviceinterface/ServiceInterfaceStream.h"
|
||||
#include "../tmtcpacket/pus/TcPacketBase.h"
|
||||
#include "../tmtcpacket/pus/TcPacketStoredBase.h"
|
||||
#include "../serviceinterface/ServiceInterface.h"
|
||||
#include "../storagemanager/StorageManagerIF.h"
|
||||
#include "../tmtcservices/VerificationCodes.h"
|
||||
|
||||
TcPacketCheck::TcPacketCheck( uint16_t setApid ) : apid(setApid) {
|
||||
TcPacketCheck::TcPacketCheck(uint16_t setApid): apid(setApid) {
|
||||
}
|
||||
|
||||
ReturnValue_t TcPacketCheck::checkPacket( TcPacketStored* currentPacket ) {
|
||||
uint16_t calculated_crc = CRC::crc16ccitt( currentPacket->getWholeData(),
|
||||
currentPacket->getFullSize() );
|
||||
if ( calculated_crc != 0 ) {
|
||||
return INCORRECT_CHECKSUM;
|
||||
}
|
||||
bool condition = (not currentPacket->hasSecondaryHeader()) or
|
||||
(currentPacket->getPacketVersionNumber() != CCSDS_VERSION_NUMBER) or
|
||||
(not currentPacket->isTelecommand());
|
||||
if ( condition ) {
|
||||
return INCORRECT_PRIMARY_HEADER;
|
||||
}
|
||||
if ( currentPacket->getAPID() != this->apid )
|
||||
return ILLEGAL_APID;
|
||||
ReturnValue_t TcPacketCheck::checkPacket(TcPacketStoredBase* currentPacket) {
|
||||
TcPacketBase* tcPacketBase = currentPacket->getPacketBase();
|
||||
if(tcPacketBase == nullptr) {
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
uint16_t calculated_crc = CRC::crc16ccitt(tcPacketBase->getWholeData(),
|
||||
tcPacketBase->getFullSize());
|
||||
if (calculated_crc != 0) {
|
||||
return INCORRECT_CHECKSUM;
|
||||
}
|
||||
bool condition = (not tcPacketBase->hasSecondaryHeader()) or
|
||||
(tcPacketBase->getPacketVersionNumber() != CCSDS_VERSION_NUMBER) or
|
||||
(not tcPacketBase->isTelecommand());
|
||||
if (condition) {
|
||||
return INCORRECT_PRIMARY_HEADER;
|
||||
}
|
||||
if (tcPacketBase->getAPID() != this->apid)
|
||||
return ILLEGAL_APID;
|
||||
|
||||
if ( not currentPacket->isSizeCorrect() ) {
|
||||
return INCOMPLETE_PACKET;
|
||||
}
|
||||
condition = (currentPacket->getSecondaryHeaderFlag() != CCSDS_SECONDARY_HEADER_FLAG) ||
|
||||
(currentPacket->getPusVersionNumber() != PUS_VERSION_NUMBER);
|
||||
if ( condition ) {
|
||||
return INCORRECT_SECONDARY_HEADER;
|
||||
}
|
||||
return RETURN_OK;
|
||||
if (not currentPacket->isSizeCorrect()) {
|
||||
return INCOMPLETE_PACKET;
|
||||
}
|
||||
condition = (tcPacketBase->getSecondaryHeaderFlag() != CCSDS_SECONDARY_HEADER_FLAG) ||
|
||||
(tcPacketBase->getPusVersionNumber() != PUS_VERSION_NUMBER);
|
||||
if (condition) {
|
||||
return INCORRECT_SECONDARY_HEADER;
|
||||
}
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
uint16_t TcPacketCheck::getApid() const {
|
||||
return apid;
|
||||
return apid;
|
||||
}
|
||||
|
@ -2,9 +2,10 @@
|
||||
#define FSFW_TCDISTRIBUTION_TCPACKETCHECK_H_
|
||||
|
||||
#include "../returnvalues/HasReturnvaluesIF.h"
|
||||
#include "../tmtcpacket/pus/TcPacketStored.h"
|
||||
#include "../tmtcservices/PusVerificationReport.h"
|
||||
|
||||
class TcPacketStoredBase;
|
||||
|
||||
/**
|
||||
* This class performs a formal packet check for incoming PUS Telecommand Packets.
|
||||
* Currently, it only checks if the APID and CRC are correct.
|
||||
@ -12,49 +13,48 @@
|
||||
*/
|
||||
class TcPacketCheck : public HasReturnvaluesIF {
|
||||
protected:
|
||||
/**
|
||||
* Describes the version number a packet must have to pass.
|
||||
*/
|
||||
static constexpr uint8_t CCSDS_VERSION_NUMBER = 0;
|
||||
/**
|
||||
* Describes the secondary header a packet must have to pass.
|
||||
*/
|
||||
static constexpr uint8_t CCSDS_SECONDARY_HEADER_FLAG = 0;
|
||||
/**
|
||||
* Describes the TC Packet PUS Version Number a packet must have to pass.
|
||||
*/
|
||||
static constexpr uint8_t PUS_VERSION_NUMBER = 1;
|
||||
/**
|
||||
* The packet id each correct packet should have.
|
||||
* It is composed of the APID and some static fields.
|
||||
*/
|
||||
uint16_t apid;
|
||||
/**
|
||||
* Describes the version number a packet must have to pass.
|
||||
*/
|
||||
static constexpr uint8_t CCSDS_VERSION_NUMBER = 0;
|
||||
/**
|
||||
* Describes the secondary header a packet must have to pass.
|
||||
*/
|
||||
static constexpr uint8_t CCSDS_SECONDARY_HEADER_FLAG = 0;
|
||||
/**
|
||||
* Describes the TC Packet PUS Version Number a packet must have to pass.
|
||||
*/
|
||||
static constexpr uint8_t PUS_VERSION_NUMBER = 1;
|
||||
/**
|
||||
* The packet id each correct packet should have.
|
||||
* It is composed of the APID and some static fields.
|
||||
*/
|
||||
uint16_t apid;
|
||||
public:
|
||||
static const uint8_t INTERFACE_ID = CLASS_ID::TC_PACKET_CHECK;
|
||||
static const ReturnValue_t ILLEGAL_APID = MAKE_RETURN_CODE( 0 );
|
||||
static const ReturnValue_t INCOMPLETE_PACKET = MAKE_RETURN_CODE( 1 );
|
||||
static const ReturnValue_t INCORRECT_CHECKSUM = MAKE_RETURN_CODE( 2 );
|
||||
static const ReturnValue_t ILLEGAL_PACKET_TYPE = MAKE_RETURN_CODE( 3 );
|
||||
static const ReturnValue_t ILLEGAL_PACKET_SUBTYPE = MAKE_RETURN_CODE( 4 );
|
||||
static const ReturnValue_t INCORRECT_PRIMARY_HEADER = MAKE_RETURN_CODE( 5 );
|
||||
static const ReturnValue_t INCORRECT_SECONDARY_HEADER = MAKE_RETURN_CODE( 6 );
|
||||
/**
|
||||
* The constructor only sets the APID attribute.
|
||||
* @param set_apid The APID to set.
|
||||
*/
|
||||
TcPacketCheck( uint16_t setApid );
|
||||
/**
|
||||
* This is the actual method to formally check a certain Telecommand Packet.
|
||||
* 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( TcPacketStored* currentPacket );
|
||||
static const uint8_t INTERFACE_ID = CLASS_ID::TC_PACKET_CHECK;
|
||||
static const ReturnValue_t ILLEGAL_APID = MAKE_RETURN_CODE( 0 );
|
||||
static const ReturnValue_t INCOMPLETE_PACKET = MAKE_RETURN_CODE( 1 );
|
||||
static const ReturnValue_t INCORRECT_CHECKSUM = MAKE_RETURN_CODE( 2 );
|
||||
static const ReturnValue_t ILLEGAL_PACKET_TYPE = MAKE_RETURN_CODE( 3 );
|
||||
static const ReturnValue_t ILLEGAL_PACKET_SUBTYPE = MAKE_RETURN_CODE( 4 );
|
||||
static const ReturnValue_t INCORRECT_PRIMARY_HEADER = MAKE_RETURN_CODE( 5 );
|
||||
static const ReturnValue_t INCORRECT_SECONDARY_HEADER = MAKE_RETURN_CODE( 6 );
|
||||
/**
|
||||
* The constructor only sets the APID attribute.
|
||||
* @param set_apid The APID to set.
|
||||
*/
|
||||
TcPacketCheck(uint16_t setApid);
|
||||
/**
|
||||
* This is the actual method to formally check a certain Telecommand Packet.
|
||||
* 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_ */
|
||||
|
Reference in New Issue
Block a user