added tcdistribution modules

This commit is contained in:
Robin Müller 2021-10-20 16:50:38 +02:00
parent 9c6ff685cc
commit 0da32e8d43
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814
15 changed files with 545 additions and 218 deletions

View File

@ -7,8 +7,8 @@
#define CCSDS_DISTRIBUTOR_DEBUGGING 0
CCSDSDistributor::CCSDSDistributor(uint16_t setDefaultApid,
object_id_t setObjectId):
TcDistributor(setObjectId), defaultApid( setDefaultApid ) {
object_id_t setObjectId):
TcDistributor(setObjectId), defaultApid( setDefaultApid ) {
}
CCSDSDistributor::~CCSDSDistributor() {}
@ -16,97 +16,97 @@ CCSDSDistributor::~CCSDSDistributor() {}
TcDistributor::TcMqMapIter CCSDSDistributor::selectDestination() {
#if CCSDS_DISTRIBUTOR_DEBUGGING == 1
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::debug << "CCSDSDistributor::selectDestination received: " <<
this->currentMessage.getStorageId().poolIndex << ", " <<
this->currentMessage.getStorageId().packetIndex << std::endl;
sif::debug << "CCSDSDistributor::selectDestination received: " <<
this->currentMessage.getStorageId().poolIndex << ", " <<
this->currentMessage.getStorageId().packetIndex << std::endl;
#else
sif::printDebug("CCSDSDistributor::selectDestination received: %d, %d\n",
currentMessage.getStorageId().poolIndex, currentMessage.getStorageId().packetIndex);
sif::printDebug("CCSDSDistributor::selectDestination received: %d, %d\n",
currentMessage.getStorageId().poolIndex, currentMessage.getStorageId().packetIndex);
#endif
#endif
const uint8_t* packet = nullptr;
size_t size = 0;
ReturnValue_t result = this->tcStore->getData(currentMessage.getStorageId(),
&packet, &size );
if(result != HasReturnvaluesIF::RETURN_OK) {
const uint8_t* packet = nullptr;
size_t size = 0;
ReturnValue_t result = this->tcStore->getData(currentMessage.getStorageId(),
&packet, &size );
if(result != HasReturnvaluesIF::RETURN_OK) {
#if FSFW_VERBOSE_LEVEL >= 1
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "CCSDSDistributor::selectDestination: Getting data from"
" store failed!" << std::endl;
sif::error << "CCSDSDistributor::selectDestination: Getting data from"
" store failed!" << std::endl;
#else
sif::printError("CCSDSDistributor::selectDestination: Getting data from"
sif::printError("CCSDSDistributor::selectDestination: Getting data from"
" store failed!\n");
#endif
#endif
}
SpacePacketBase currentPacket(packet);
}
SpacePacketBase currentPacket(packet);
#if FSFW_CPP_OSTREAM_ENABLED == 1 && CCSDS_DISTRIBUTOR_DEBUGGING == 1
sif::info << "CCSDSDistributor::selectDestination has packet with APID " << std::hex <<
currentPacket.getAPID() << std::dec << std::endl;
sif::info << "CCSDSDistributor::selectDestination has packet with APID " << std::hex <<
currentPacket.getAPID() << std::dec << std::endl;
#endif
TcMqMapIter position = this->queueMap.find(currentPacket.getAPID());
if ( position != this->queueMap.end() ) {
return position;
} else {
//The APID was not found. Forward packet to main SW-APID anyway to
// create acceptance failure report.
return this->queueMap.find( this->defaultApid );
}
TcMqMapIter position = this->queueMap.find(currentPacket.getAPID());
if ( position != this->queueMap.end() ) {
return position;
} else {
//The APID was not found. Forward packet to main SW-APID anyway to
// create acceptance failure report.
return this->queueMap.find( this->defaultApid );
}
}
MessageQueueId_t CCSDSDistributor::getRequestQueue() {
return tcQueue->getId();
return tcQueue->getId();
}
ReturnValue_t CCSDSDistributor::registerApplication(
AcceptsTelecommandsIF* application) {
ReturnValue_t returnValue = RETURN_OK;
auto insertPair = this->queueMap.emplace(application->getIdentifier(),
application->getRequestQueue());
if(not insertPair.second) {
returnValue = RETURN_FAILED;
}
return returnValue;
AcceptsTelecommandsIF* application) {
ReturnValue_t returnValue = RETURN_OK;
auto insertPair = this->queueMap.emplace(application->getIdentifier(),
application->getRequestQueue());
if(not insertPair.second) {
returnValue = RETURN_FAILED;
}
return returnValue;
}
ReturnValue_t CCSDSDistributor::registerApplication(uint16_t apid,
MessageQueueId_t id) {
ReturnValue_t returnValue = RETURN_OK;
auto insertPair = this->queueMap.emplace(apid, id);
if(not insertPair.second) {
returnValue = RETURN_FAILED;
}
return returnValue;
MessageQueueId_t id) {
ReturnValue_t returnValue = RETURN_OK;
auto insertPair = this->queueMap.emplace(apid, id);
if(not insertPair.second) {
returnValue = RETURN_FAILED;
}
return returnValue;
}
uint16_t CCSDSDistributor::getIdentifier() {
return 0;
return 0;
}
ReturnValue_t CCSDSDistributor::initialize() {
ReturnValue_t status = this->TcDistributor::initialize();
this->tcStore = ObjectManager::instance()->get<StorageManagerIF>( objects::TC_STORE );
if (this->tcStore == nullptr) {
ReturnValue_t status = this->TcDistributor::initialize();
this->tcStore = ObjectManager::instance()->get<StorageManagerIF>( objects::TC_STORE );
if (this->tcStore == nullptr) {
#if FSFW_VERBOSE_LEVEL >= 1
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "CCSDSDistributor::initialize: Could not initialize"
" TC store!" << std::endl;
sif::error << "CCSDSDistributor::initialize: Could not initialize"
" TC store!" << std::endl;
#else
sif::printError("CCSDSDistributor::initialize: Could not initialize"
sif::printError("CCSDSDistributor::initialize: Could not initialize"
" TC store!\n");
#endif
#endif
status = RETURN_FAILED;
}
return status;
status = RETURN_FAILED;
}
return status;
}
ReturnValue_t CCSDSDistributor::callbackAfterSending(
ReturnValue_t queueStatus) {
if (queueStatus != RETURN_OK) {
tcStore->deleteData(currentMessage.getStorageId());
}
return RETURN_OK;
ReturnValue_t queueStatus) {
if (queueStatus != RETURN_OK) {
tcStore->deleteData(currentMessage.getStorageId());
}
return RETURN_OK;
}

View File

@ -15,56 +15,57 @@
* The Secondary Header (with Service/Subservice) is ignored.
* @ingroup tc_distribution
*/
class CCSDSDistributor : public TcDistributor,
public CCSDSDistributorIF,
public AcceptsTelecommandsIF {
class CCSDSDistributor:
public TcDistributor,
public CCSDSDistributorIF,
public AcceptsTelecommandsIF {
public:
/**
* @brief The constructor sets the default APID and calls the
* TcDistributor ctor with a certain object id.
* @details
* @c tcStore is set in the @c initialize method.
* @param setDefaultApid The default APID, where packets with unknown
* destination are sent to.
*/
CCSDSDistributor(uint16_t setDefaultApid, object_id_t setObjectId);
/**
* The destructor is empty.
*/
virtual ~CCSDSDistributor();
/**
* @brief The constructor sets the default APID and calls the
* TcDistributor ctor with a certain object id.
* @details
* @c tcStore is set in the @c initialize method.
* @param setDefaultApid The default APID, where packets with unknown
* destination are sent to.
*/
CCSDSDistributor(uint16_t setDefaultApid, object_id_t setObjectId);
/**
* The destructor is empty.
*/
virtual ~CCSDSDistributor();
MessageQueueId_t getRequestQueue() override;
ReturnValue_t registerApplication( uint16_t apid,
MessageQueueId_t id) override;
ReturnValue_t registerApplication(
AcceptsTelecommandsIF* application) override;
uint16_t getIdentifier() override;
ReturnValue_t initialize() override;
MessageQueueId_t getRequestQueue() override;
ReturnValue_t registerApplication( uint16_t apid,
MessageQueueId_t id) override;
ReturnValue_t registerApplication(
AcceptsTelecommandsIF* application) override;
uint16_t getIdentifier() override;
ReturnValue_t initialize() override;
protected:
/**
* This implementation checks if an application with fitting APID has
* registered and forwards the packet to the according message queue.
* If the packet is not found, it returns the queue to @c defaultApid,
* where a Acceptance Failure message should be generated.
* @return Iterator to map entry of found APID or iterator to default APID.
*/
TcMqMapIter selectDestination() override;
/**
* This implementation checks if an application with fitting APID has
* registered and forwards the packet to the according message queue.
* If the packet is not found, it returns the queue to @c defaultApid,
* where a Acceptance Failure message should be generated.
* @return Iterator to map entry of found APID or iterator to default APID.
*/
TcMqMapIter selectDestination() override;
/**
* The callback here handles the generation of acceptance
* success/failure messages.
*/
ReturnValue_t callbackAfterSending( ReturnValue_t queueStatus ) override;
/**
* The default APID, where packets with unknown APID are sent to.
*/
uint16_t defaultApid;
/**
* A reference to the TC storage must be maintained, as this class handles
* pure Space Packets and there exists no SpacePacketStored class.
*/
StorageManagerIF* tcStore = nullptr;
/**
* The default APID, where packets with unknown APID are sent to.
*/
uint16_t defaultApid;
/**
* A reference to the TC storage must be maintained, as this class handles
* pure Space Packets and there exists no SpacePacketStored class.
*/
StorageManagerIF* tcStore = nullptr;
};

View File

@ -13,31 +13,30 @@
*/
class CCSDSDistributorIF {
public:
/**
* With this call, a class implementing the CCSDSApplicationIF can register
* at the distributor.
* @param application A pointer to the Application to register.
* @return - @c RETURN_OK on success,
* - @c RETURN_FAILED on failure.
*/
virtual ReturnValue_t registerApplication(
AcceptsTelecommandsIF* application) = 0;
/**
* With this call, other Applications can register to the CCSDS distributor.
* This is done by passing an APID and a MessageQueueId to the method.
* @param apid The APID to register.
* @param id The MessageQueueId of the message queue to send the
* TC Packets to.
* @return - @c RETURN_OK on success,
* - @c RETURN_FAILED on failure.
*/
virtual ReturnValue_t registerApplication( uint16_t apid,
MessageQueueId_t id) = 0;
/**
* The empty virtual destructor.
*/
virtual ~CCSDSDistributorIF() {
}
/**
* With this call, a class implementing the CCSDSApplicationIF can register
* at the distributor.
* @param application A pointer to the Application to register.
* @return - @c RETURN_OK on success,
* - @c RETURN_FAILED on failure.
*/
virtual ReturnValue_t registerApplication(
AcceptsTelecommandsIF* application) = 0;
/**
* With this call, other Applications can register to the CCSDS distributor.
* This is done by passing an APID and a MessageQueueId to the method.
* @param apid The APID to register.
* @param id The MessageQueueId of the message queue to send the
* TC Packets to.
* @return - @c RETURN_OK on success,
* - @c RETURN_FAILED on failure.
*/
virtual ReturnValue_t registerApplication( uint16_t apid,
MessageQueueId_t id) = 0;
/**
* The empty virtual destructor.
*/
virtual ~CCSDSDistributorIF() {}
};

View File

@ -0,0 +1,147 @@
#include "fsfw/tcdistribution/CCSDSDistributorIF.h"
#include "fsfw/tcdistribution/CFDPDistributor.h"
#include "fsfw/tmtcpacket/cfdp/CFDPPacketStored.h"
#include "fsfw/objectmanager/ObjectManager.h"
#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), apid(setApid), checker(setApid),
tcStatus(RETURN_FAILED), packetSource(setPacketSource) {
}
CFDPDistributor::~CFDPDistributor() {}
CFDPDistributor::TcMqMapIter CFDPDistributor::selectDestination() {
#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;
#else
sif::printDebug("CFDPDistributor::handlePacket received: %d, %d\n", storeId.poolIndex,
storeId.packetIndex);
#endif
#endif
TcMqMapIter queueMapIt = this->queueMap.end();
if(this->currentPacket == nullptr) {
return queueMapIt;
}
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 << "CFDPDistributor::handlePacket: Packet format invalid, code " <<
static_cast<int>(tcStatus) << std::endl;
#else
sif::printDebug("CFDPDistributor::handlePacket: Packet format invalid, code %d\n",
static_cast<int>(tcStatus));
#endif
#endif
}
queueMapIt = this->queueMap.find(0);
}
else {
tcStatus = PACKET_LOST;
}
if (queueMapIt == this->queueMap.end()) {
tcStatus = DESTINATION_NOT_FOUND;
#if FSFW_VERBOSE_LEVEL >= 1
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::debug << "CFDPDistributor::handlePacket: Destination not found" << std::endl;
#else
sif::printDebug("CFDPDistributor::handlePacket: Destination not found\n");
#endif /* !FSFW_CPP_OSTREAM_ENABLED == 1 */
#endif
}
if (tcStatus != RETURN_OK) {
return this->queueMap.end();
}
else {
return queueMapIt;
}
}
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 FSFW_CFDP_DISTRIBUTOR_DEBUGGING == 1
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::info << "CFDPDistributor::registerHandler: Handler ID: " << static_cast<int>(handlerId) << std::endl;
#else
sif::printInfo("CFDPDistributor::registerHandler: Handler ID: %d\n", static_cast<int>(handlerId));
#endif
#endif
MessageQueueId_t queue = handler->getRequestQueue();
auto returnPair = queueMap.emplace(handlerId, queue);
if (not returnPair.second) {
#if FSFW_VERBOSE_LEVEL >= 1
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "CFDPDistributor::registerHandler: Service ID already"
" exists in map" << std::endl;
#else
sif::printError("CFDPDistributor::registerHandler: Service ID already exists in map\n");
#endif
#endif
return SERVICE_ID_ALREADY_EXISTS;
}
return HasReturnvaluesIF::RETURN_OK;
}
MessageQueueId_t CFDPDistributor::getRequestQueue() {
return tcQueue->getId();
}
//ReturnValue_t CFDPDistributor::callbackAfterSending(ReturnValue_t queueStatus) {
// if (queueStatus != RETURN_OK) {
// tcStatus = queueStatus;
// }
// if (tcStatus != RETURN_OK) {
// this->verifyChannel.sendFailureReport(tc_verification::ACCEPTANCE_FAILURE,
// currentPacket, tcStatus);
// // A failed packet is deleted immediately after reporting,
// // otherwise it will block memory.
// currentPacket->deletePacket();
// return RETURN_FAILED;
// } else {
// this->verifyChannel.sendSuccessReport(tc_verification::ACCEPTANCE_SUCCESS,
// currentPacket);
// return RETURN_OK;
// }
//}
uint16_t CFDPDistributor::getIdentifier() {
return this->apid;
}
ReturnValue_t CFDPDistributor::initialize() {
currentPacket = new CFDPPacketStored();
if(currentPacket == nullptr) {
// Should not happen, memory allocation failed!
return ObjectManagerIF::CHILD_INIT_FAILED;
}
CCSDSDistributorIF* ccsdsDistributor = ObjectManager::instance()->get<CCSDSDistributorIF>(
packetSource);
if (ccsdsDistributor == nullptr) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "CFDPDistributor::initialize: Packet source invalid" << std::endl;
sif::error << " Make sure it exists and implements CCSDSDistributorIF!" << std::endl;
#else
sif::printError("CFDPDistributor::initialize: Packet source invalid\n");
sif::printError("Make sure it exists and implements CCSDSDistributorIF\n");
#endif
return RETURN_FAILED;
}
return ccsdsDistributor->registerApplication(this);
}

View File

@ -0,0 +1,72 @@
#ifndef FSFW_TCDISTRIBUTION_CFDPDISTRIBUTOR_H_
#define FSFW_TCDISTRIBUTION_CFDPDISTRIBUTOR_H_
#include <fsfw/tcdistribution/TcPacketCheckCFDP.h>
#include "CFDPDistributorIF.h"
#include "TcDistributor.h"
#include "../tmtcpacket/cfdp/CFDPPacketStored.h"
#include "../returnvalues/HasReturnvaluesIF.h"
#include "../tmtcservices/AcceptsTelecommandsIF.h"
#include "../tmtcservices/VerificationReporter.h"
/**
* This class accepts CFDP Telecommands and forwards them to Application
* services.
* @ingroup tc_distribution
*/
class CFDPDistributor:
public TcDistributor,
public CFDPDistributorIF,
public AcceptsTelecommandsIF {
public:
/**
* The ctor passes @c set_apid to the checker class and calls the
* TcDistribution ctor with a certain object id.
* @param setApid The APID of this receiving Application.
* @param setObjectId Object ID of the distributor itself
* @param setPacketSource Object ID of the source of TC packets.
* Must implement CCSDSDistributorIF.
*/
CFDPDistributor(uint16_t setApid, object_id_t setObjectId,
object_id_t setPacketSource);
/**
* The destructor is empty.
*/
virtual ~CFDPDistributor();
ReturnValue_t registerHandler(AcceptsTelecommandsIF* handler) override;
MessageQueueId_t getRequestQueue() override;
ReturnValue_t initialize() override;
uint16_t getIdentifier() override;
protected:
uint16_t apid;
/**
* 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.
*/
ReturnValue_t tcStatus;
const object_id_t packetSource;
/**
* This method reads the packet service, checks if such a service is
* registered and forwards the packet to the destination.
* It also initiates the formal packet check and sending of verification
* messages.
* @return Iterator to map entry of found service id
* or iterator to @c map.end().
*/
TcMqMapIter selectDestination() override;
/**
* The callback here handles the generation of acceptance
* success/failure messages.
*/
//ReturnValue_t callbackAfterSending(ReturnValue_t queueStatus) override;
};
#endif /* FSFW_TCDISTRIBUTION_CFDPDISTRIBUTOR_H_ */

View File

@ -0,0 +1,27 @@
#ifndef FSFW_TCDISTRIBUTION_CFDPDISTRIBUTORIF_H_
#define FSFW_TCDISTRIBUTION_CFDPDISTRIBUTORIF_H_
#include "../tmtcservices/AcceptsTelecommandsIF.h"
#include "../ipc/MessageQueueSenderIF.h"
/**
* This interface allows CFDP Services to register themselves at a CFDP Distributor.
* @ingroup tc_distribution
*/
class CFDPDistributorIF {
public:
/**
* The empty virtual destructor.
*/
virtual ~CFDPDistributorIF() {
}
/**
* With this method, Handlers can register themselves at the CFDP Distributor.
* @param handler A pointer to the registering Handler.
* @return - @c RETURN_OK on success,
* - @c RETURN_FAILED on failure.
*/
virtual ReturnValue_t registerHandler(AcceptsTelecommandsIF* handler) = 0;
};
#endif /* FSFW_TCDISTRIBUTION_CFDPDISTRIBUTORIF_H_ */

View File

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

View File

@ -24,25 +24,25 @@ PUSDistributor::TcMqMapIter PUSDistributor::selectDestination() {
if(this->currentPacket == nullptr) {
return queueMapIt;
}
this->currentPacket->setStoreAddress(this->currentMessage.getStorageId());
this->currentPacket->setStoreAddress(this->currentMessage.getStorageId(), currentPacket);
if (currentPacket->getWholeData() != nullptr) {
tcStatus = checker.checkPacket(currentPacket);
if(tcStatus != HasReturnvaluesIF::RETURN_OK) {
#if FSFW_VERBOSE_LEVEL >= 1
const char* keyword = "unnamed error";
if(tcStatus == TcPacketCheck::INCORRECT_CHECKSUM) {
if(tcStatus == TcPacketCheckPUS::INCORRECT_CHECKSUM) {
keyword = "checksum";
}
else if(tcStatus == TcPacketCheck::INCORRECT_PRIMARY_HEADER) {
else if(tcStatus == TcPacketCheckPUS::INCORRECT_PRIMARY_HEADER) {
keyword = "incorrect primary header";
}
else if(tcStatus == TcPacketCheck::ILLEGAL_APID) {
else if(tcStatus == TcPacketCheckPUS::ILLEGAL_APID) {
keyword = "illegal APID";
}
else if(tcStatus == TcPacketCheck::INCORRECT_SECONDARY_HEADER) {
else if(tcStatus == TcPacketCheckPUS::INCORRECT_SECONDARY_HEADER) {
keyword = "incorrect secondary header";
}
else if(tcStatus == TcPacketCheck::INCOMPLETE_PACKET) {
else if(tcStatus == TcPacketCheckPUS::INCOMPLETE_PACKET) {
keyword = "incomplete packet";
}
#if FSFW_CPP_OSTREAM_ENABLED == 1

View File

@ -3,7 +3,7 @@
#include "PUSDistributorIF.h"
#include "TcDistributor.h"
#include "TcPacketCheck.h"
#include "TcPacketCheckPUS.h"
#include "fsfw/tmtcpacket/pus/tc.h"
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
@ -17,65 +17,65 @@
* @ingroup tc_distribution
*/
class PUSDistributor: public TcDistributor,
public PUSDistributorIF,
public AcceptsTelecommandsIF {
public PUSDistributorIF,
public AcceptsTelecommandsIF {
public:
/**
* The ctor passes @c set_apid to the checker class and calls the
* TcDistribution ctor with a certain object id.
* @param setApid The APID of this receiving Application.
* @param setObjectId Object ID of the distributor itself
* @param setPacketSource Object ID of the source of TC packets.
* Must implement CCSDSDistributorIF.
*/
PUSDistributor(uint16_t setApid, object_id_t setObjectId,
object_id_t setPacketSource);
/**
* The destructor is empty.
*/
virtual ~PUSDistributor();
ReturnValue_t registerService(AcceptsTelecommandsIF* service) override;
MessageQueueId_t getRequestQueue() override;
ReturnValue_t initialize() override;
uint16_t getIdentifier() override;
/**
* The ctor passes @c set_apid to the checker class and calls the
* TcDistribution ctor with a certain object id.
* @param setApid The APID of this receiving Application.
* @param setObjectId Object ID of the distributor itself
* @param setPacketSource Object ID of the source of TC packets.
* Must implement CCSDSDistributorIF.
*/
PUSDistributor(uint16_t setApid, object_id_t setObjectId,
object_id_t setPacketSource);
/**
* The destructor is empty.
*/
virtual ~PUSDistributor();
ReturnValue_t registerService(AcceptsTelecommandsIF* service) override;
MessageQueueId_t getRequestQueue() override;
ReturnValue_t initialize() override;
uint16_t getIdentifier() override;
protected:
/**
* This attribute contains the class, that performs a formal packet check.
*/
TcPacketCheck checker;
/**
* With this class, verification messages are sent to the
* TC Verification service.
*/
VerificationReporter verifyChannel;
/**
* The currently handled packet is stored here.
*/
TcPacketStoredPus* currentPacket = nullptr;
/**
* This attribute contains the class, that performs a formal packet check.
*/
TcPacketCheckPUS checker;
/**
* With this class, verification messages are sent to the
* TC Verification service.
*/
VerificationReporter verifyChannel;
/**
* The currently handled packet is stored here.
*/
TcPacketStoredPus* currentPacket = nullptr;
/**
* With this variable, the current check status is stored to generate
* acceptance messages later.
*/
ReturnValue_t tcStatus;
/**
* With this variable, the current check status is stored to generate
* acceptance messages later.
*/
ReturnValue_t tcStatus;
const object_id_t packetSource;
const object_id_t packetSource;
/**
* This method reads the packet service, checks if such a service is
* registered and forwards the packet to the destination.
* It also initiates the formal packet check and sending of verification
* messages.
* @return Iterator to map entry of found service id
* or iterator to @c map.end().
*/
TcMqMapIter selectDestination() override;
/**
* The callback here handles the generation of acceptance
* success/failure messages.
*/
ReturnValue_t callbackAfterSending(ReturnValue_t queueStatus) override;
/**
* This method reads the packet service, checks if such a service is
* registered and forwards the packet to the destination.
* It also initiates the formal packet check and sending of verification
* messages.
* @return Iterator to map entry of found service id
* or iterator to @c map.end().
*/
TcMqMapIter selectDestination() override;
/**
* The callback here handles the generation of acceptance
* success/failure messages.
*/
ReturnValue_t callbackAfterSending(ReturnValue_t queueStatus) override;
};
#endif /* FSFW_TCDISTRIBUTION_PUSDISTRIBUTOR_H_ */

View File

@ -10,18 +10,18 @@
*/
class PUSDistributorIF {
public:
/**
* The empty virtual destructor.
*/
virtual ~PUSDistributorIF() {
}
/**
* With this method, Services can register themselves at the PUS Distributor.
* @param service A pointer to the registering Service.
* @return - @c RETURN_OK on success,
* - @c RETURN_FAILED on failure.
*/
virtual ReturnValue_t registerService( AcceptsTelecommandsIF* service ) = 0;
/**
* The empty virtual destructor.
*/
virtual ~PUSDistributorIF() {
}
/**
* With this method, Services can register themselves at the PUS Distributor.
* @param service A pointer to the registering Service.
* @return - @c RETURN_OK on success,
* - @c RETURN_FAILED on failure.
*/
virtual ReturnValue_t registerService( AcceptsTelecommandsIF* service ) = 0;
};
#endif /* FSFW_TCDISTRIBUTION_PUSDISTRIBUTORIF_H_ */

View File

@ -0,0 +1,13 @@
#include "fsfw/tcdistribution/TcPacketCheckCFDP.h"
#include "fsfw/tmtcpacket/cfdp/CFDPPacketStored.h"
TcPacketCheckCFDP::TcPacketCheckCFDP(uint16_t setApid): apid(setApid) {
}
ReturnValue_t TcPacketCheckCFDP::checkPacket(SpacePacketBase* 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/FSFW.h"
class CFDPPacketStored;
/**
* 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(SpacePacketBase* currentPacket) override;
uint16_t getApid() const;
};
#endif /* FSFW_TCDISTRIBUTION_TCPACKETCHECKCFDP_H_ */

View File

@ -0,0 +1,31 @@
#ifndef FSFW_TCDISTRIBUTION_TCPACKETCHECKIF_H_
#define FSFW_TCDISTRIBUTION_TCPACKETCHECKIF_H_
#include "../returnvalues/HasReturnvaluesIF.h"
class SpacePacketBase;
/**
* 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(SpacePacketBase* currentPacket) = 0;
};
#endif /* FSFW_TCDISTRIBUTION_TCPACKETCHECKIF_H_ */

View File

@ -1,18 +1,20 @@
#include "fsfw/tcdistribution/TcPacketCheck.h"
#include "fsfw/tcdistribution/TcPacketCheckPUS.h"
#include "fsfw/globalfunctions/CRC.h"
#include "fsfw/tmtcpacket/pus/tc/TcPacketBase.h"
#include "fsfw/tmtcpacket/pus/tc/TcPacketStoredPus.h"
#include "fsfw/tmtcpacket/pus/tc/TcPacketPusBase.h"
#include "fsfw/tmtcpacket/pus/tc/TcPacketStoredBase.h"
#include "fsfw/serviceinterface/ServiceInterface.h"
#include "fsfw/storagemanager/StorageManagerIF.h"
#include "fsfw/tmtcservices/VerificationCodes.h"
TcPacketCheck::TcPacketCheck(uint16_t setApid): apid(setApid) {
TcPacketCheckPUS::TcPacketCheckPUS(uint16_t setApid): apid(setApid) {
}
ReturnValue_t TcPacketCheck::checkPacket(TcPacketStoredBase* currentPacket) {
TcPacketBase* tcPacketBase = currentPacket->getPacketBase();
if(tcPacketBase == nullptr) {
ReturnValue_t TcPacketCheckPUS::checkPacket(SpacePacketBase* currentPacket) {
TcPacketStoredBase* storedPacket = dynamic_cast<TcPacketStoredBase*>(currentPacket);
TcPacketPusBase* tcPacketBase = dynamic_cast<TcPacketPusBase*>(currentPacket);
if(tcPacketBase == nullptr or storedPacket == nullptr) {
return RETURN_FAILED;
}
uint16_t calculated_crc = CRC::crc16ccitt(tcPacketBase->getWholeData(),
@ -29,7 +31,7 @@ ReturnValue_t TcPacketCheck::checkPacket(TcPacketStoredBase* currentPacket) {
if (tcPacketBase->getAPID() != this->apid)
return ILLEGAL_APID;
if (not currentPacket->isSizeCorrect()) {
if (not storedPacket->isSizeCorrect()) {
return INCOMPLETE_PACKET;
}
@ -41,6 +43,6 @@ ReturnValue_t TcPacketCheck::checkPacket(TcPacketStoredBase* currentPacket) {
return RETURN_OK;
}
uint16_t TcPacketCheck::getApid() const {
uint16_t TcPacketCheckPUS::getApid() const {
return apid;
}

View File

@ -1,5 +1,7 @@
#ifndef FSFW_TCDISTRIBUTION_TCPACKETCHECK_H_
#define FSFW_TCDISTRIBUTION_TCPACKETCHECK_H_
#ifndef FSFW_TCDISTRIBUTION_TCPACKETCHECKPUS_H_
#define FSFW_TCDISTRIBUTION_TCPACKETCHECKPUS_H_
#include "TcPacketCheckIF.h"
#include "fsfw/FSFW.h"
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
@ -12,7 +14,9 @@ class TcPacketStoredBase;
* Currently, it only checks if the APID and CRC are correct.
* @ingroup tc_distribution
*/
class TcPacketCheck : public HasReturnvaluesIF {
class TcPacketCheckPUS :
public TcPacketCheckIF,
public HasReturnvaluesIF {
protected:
/**
* Describes the version number a packet must have to pass.
@ -49,18 +53,11 @@ public:
* 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);
TcPacketCheckPUS(uint16_t setApid);
ReturnValue_t checkPacket(SpacePacketBase* currentPacket) override;
uint16_t getApid() const;
};
#endif /* FSFW_TCDISTRIBUTION_TCPACKETCHECK_H_ */
#endif /* FSFW_TCDISTRIBUTION_TCPACKETCHECKPUS_H_ */