added CFDPHandler (not working yet)
This commit is contained in:
parent
c6998b0f17
commit
974d25dbb1
63
inc/fsfw/cfdp/CFDPHandler.h
Normal file
63
inc/fsfw/cfdp/CFDPHandler.h
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
#ifndef FSFW_CFDP_CFDPHANDLER_H_
|
||||||
|
#define FSFW_CFDP_CFDPHANDLER_H_
|
||||||
|
|
||||||
|
#include "fsfw/tmtcservices/AcceptsTelecommandsIF.h"
|
||||||
|
#include "fsfw/objectmanager/SystemObject.h"
|
||||||
|
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
|
||||||
|
#include "fsfw/tasks/ExecutableObjectIF.h"
|
||||||
|
#include "fsfw/tcdistribution/CFDPDistributor.h"
|
||||||
|
|
||||||
|
#include "fsfw/ipc/MessageQueueIF.h"
|
||||||
|
|
||||||
|
namespace Factory{
|
||||||
|
void setStaticFrameworkObjectIds();
|
||||||
|
}
|
||||||
|
|
||||||
|
class CFDPHandler :
|
||||||
|
public ExecutableObjectIF,
|
||||||
|
public AcceptsTelecommandsIF,
|
||||||
|
public SystemObject,
|
||||||
|
public HasReturnvaluesIF {
|
||||||
|
friend void (Factory::setStaticFrameworkObjectIds)();
|
||||||
|
public:
|
||||||
|
CFDPHandler(object_id_t setObjectId, CFDPDistributor* distributor);
|
||||||
|
/**
|
||||||
|
* The destructor is empty.
|
||||||
|
*/
|
||||||
|
virtual ~CFDPHandler();
|
||||||
|
|
||||||
|
virtual ReturnValue_t handleRequest(uint8_t subservice);
|
||||||
|
|
||||||
|
virtual ReturnValue_t performService();
|
||||||
|
virtual ReturnValue_t initialize() override;
|
||||||
|
virtual uint16_t getIdentifier() override;
|
||||||
|
MessageQueueId_t getRequestQueue() override;
|
||||||
|
ReturnValue_t performOperation(uint8_t opCode) override;
|
||||||
|
protected:
|
||||||
|
/**
|
||||||
|
* This is a complete instance of the telecommand reception queue
|
||||||
|
* of the class. It is initialized on construction of the class.
|
||||||
|
*/
|
||||||
|
MessageQueueIF* requestQueue = nullptr;
|
||||||
|
|
||||||
|
CFDPDistributor* distributor = nullptr;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The current CFDP packet to be processed.
|
||||||
|
* It is deleted after handleRequest was executed.
|
||||||
|
*/
|
||||||
|
CFDPPacketStored currentPacket;
|
||||||
|
|
||||||
|
static object_id_t packetSource;
|
||||||
|
|
||||||
|
static object_id_t packetDestination;
|
||||||
|
private:
|
||||||
|
/**
|
||||||
|
* This constant sets the maximum number of packets accepted per call.
|
||||||
|
* Remember that one packet must be completely handled in one
|
||||||
|
* #handleRequest call.
|
||||||
|
*/
|
||||||
|
static const uint8_t CFDP_HANDLER_MAX_RECEPTION = 10;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* FSFW_CFDP_CFDPHANDLER_H_ */
|
@ -19,6 +19,9 @@ enum framework_objects: object_id_t {
|
|||||||
PUS_SERVICE_200_MODE_MGMT = 0x53000200,
|
PUS_SERVICE_200_MODE_MGMT = 0x53000200,
|
||||||
PUS_SERVICE_201_HEALTH = 0x53000201,
|
PUS_SERVICE_201_HEALTH = 0x53000201,
|
||||||
|
|
||||||
|
/* CFDP Distributer */
|
||||||
|
CFDP_PACKET_DISTRIBUTOR = 0x53001000,
|
||||||
|
|
||||||
//Generic IDs for IPC, modes, health, events
|
//Generic IDs for IPC, modes, health, events
|
||||||
HEALTH_TABLE = 0x53010000,
|
HEALTH_TABLE = 0x53010000,
|
||||||
// MODE_STORE = 0x53010100,
|
// MODE_STORE = 0x53010100,
|
||||||
|
@ -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 "../tmtcpacket/pus/tc.h"
|
#include "../tmtcpacket/cfdp/CFDPPacketStored.h"
|
||||||
#include "../returnvalues/HasReturnvaluesIF.h"
|
#include "../returnvalues/HasReturnvaluesIF.h"
|
||||||
#include "../tmtcservices/AcceptsTelecommandsIF.h"
|
#include "../tmtcservices/AcceptsTelecommandsIF.h"
|
||||||
#include "../tmtcservices/VerificationReporter.h"
|
#include "../tmtcservices/VerificationReporter.h"
|
||||||
@ -33,25 +32,17 @@ public:
|
|||||||
* The destructor is empty.
|
* The destructor is empty.
|
||||||
*/
|
*/
|
||||||
virtual ~CFDPDistributor();
|
virtual ~CFDPDistributor();
|
||||||
ReturnValue_t registerService(AcceptsTelecommandsIF* service) override;
|
ReturnValue_t registerHandler(AcceptsTelecommandsIF* handler) override;
|
||||||
MessageQueueId_t getRequestQueue() override;
|
MessageQueueId_t getRequestQueue() override;
|
||||||
ReturnValue_t initialize() override;
|
ReturnValue_t initialize() override;
|
||||||
uint16_t getIdentifier() override;
|
uint16_t getIdentifier() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/**
|
uint16_t apid;
|
||||||
* This attribute contains the class, that performs a formal packet check.
|
|
||||||
*/
|
|
||||||
TcPacketCheckCFDP checker;
|
|
||||||
/**
|
|
||||||
* With this class, verification messages are sent to the
|
|
||||||
* TC Verification service.
|
|
||||||
*/
|
|
||||||
VerificationReporter verifyChannel;
|
|
||||||
/**
|
/**
|
||||||
* The currently handled packet is stored here.
|
* The currently handled packet is stored here.
|
||||||
*/
|
*/
|
||||||
TcPacketStoredPus* currentPacket = nullptr;
|
CFDPPacketStored* currentPacket = nullptr;
|
||||||
/**
|
/**
|
||||||
* With this variable, the current check status is stored to generate
|
* With this variable, the current check status is stored to generate
|
||||||
* acceptance messages later.
|
* acceptance messages later.
|
||||||
@ -73,7 +64,7 @@ protected:
|
|||||||
* The callback here handles the generation of acceptance
|
* The callback here handles the generation of acceptance
|
||||||
* success/failure messages.
|
* success/failure messages.
|
||||||
*/
|
*/
|
||||||
ReturnValue_t callbackAfterSending(ReturnValue_t queueStatus) override;
|
//ReturnValue_t callbackAfterSending(ReturnValue_t queueStatus) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* FSFW_TCDISTRIBUTION_CFDPDISTRIBUTOR_H_ */
|
#endif /* FSFW_TCDISTRIBUTION_CFDPDISTRIBUTOR_H_ */
|
||||||
|
@ -15,13 +15,13 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual ~CFDPDistributorIF() {
|
virtual ~CFDPDistributorIF() {
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* With this method, Services can register themselves at the CFDP Distributor.
|
* With this method, Handlers can register themselves at the CFDP Distributor.
|
||||||
* @param service A pointer to the registering Service.
|
* @param handler A pointer to the registering Handler.
|
||||||
* @return - @c RETURN_OK on success,
|
* @return - @c RETURN_OK on success,
|
||||||
* - @c RETURN_FAILED on failure.
|
* - @c RETURN_FAILED on failure.
|
||||||
*/
|
*/
|
||||||
virtual ReturnValue_t registerService( AcceptsTelecommandsIF* service ) = 0;
|
virtual ReturnValue_t registerHandler(AcceptsTelecommandsIF* handler) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* FSFW_TCDISTRIBUTION_CFDPDISTRIBUTORIF_H_ */
|
#endif /* FSFW_TCDISTRIBUTION_CFDPDISTRIBUTORIF_H_ */
|
||||||
|
27
inc/fsfw/tmtcpacket/cfdp/CFDPPacket.h
Normal file
27
inc/fsfw/tmtcpacket/cfdp/CFDPPacket.h
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
#ifndef FSFW_INC_FSFW_TMTCPACKET_CFDP_CFDPPACKET_H_
|
||||||
|
#define FSFW_INC_FSFW_TMTCPACKET_CFDP_CFDPPACKET_H_
|
||||||
|
|
||||||
|
#include "fsfw/tmtcpacket/SpacePacketBase.h"
|
||||||
|
|
||||||
|
class CFDPPacket : public SpacePacketBase {
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* This is the default constructor.
|
||||||
|
* It sets its internal data pointer to the address passed and also
|
||||||
|
* forwards the data pointer to the parent SpacePacketBase class.
|
||||||
|
* @param setData The position where the packet data lies.
|
||||||
|
*/
|
||||||
|
CFDPPacket( const uint8_t* setData );
|
||||||
|
/**
|
||||||
|
* This is the empty default destructor.
|
||||||
|
*/
|
||||||
|
virtual ~CFDPPacket();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is a debugging helper method that prints the whole packet content
|
||||||
|
* to the screen.
|
||||||
|
*/
|
||||||
|
void print();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* FSFW_INC_FSFW_TMTCPACKET_CFDP_CFDPPACKET_H_ */
|
64
inc/fsfw/tmtcpacket/cfdp/CFDPPacketStored.h
Normal file
64
inc/fsfw/tmtcpacket/cfdp/CFDPPacketStored.h
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
#ifndef FSFW_INC_FSFW_TMTCPACKET_CFDP_CFDPPACKETSTORED_H_
|
||||||
|
#define FSFW_INC_FSFW_TMTCPACKET_CFDP_CFDPPACKETSTORED_H_
|
||||||
|
|
||||||
|
#include "../pus/tc/TcPacketStoredBase.h"
|
||||||
|
#include "CFDPPacket.h"
|
||||||
|
|
||||||
|
class CFDPPacketStored:
|
||||||
|
public CFDPPacket {
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* Create stored packet with existing data.
|
||||||
|
* @param data
|
||||||
|
* @param size
|
||||||
|
*/
|
||||||
|
CFDPPacketStored(const uint8_t* data, size_t size);
|
||||||
|
/**
|
||||||
|
* Create stored packet from existing packet in store
|
||||||
|
* @param setAddress
|
||||||
|
*/
|
||||||
|
CFDPPacketStored(store_address_t setAddress);
|
||||||
|
CFDPPacketStored();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Getter function for the raw data.
|
||||||
|
* @param dataPtr [out] Pointer to the data pointer to set
|
||||||
|
* @param dataSize [out] Address of size to set.
|
||||||
|
* @return -@c RETURN_OK if data was retrieved successfully.
|
||||||
|
*/
|
||||||
|
ReturnValue_t getData(const uint8_t ** dataPtr, size_t* dataSize);
|
||||||
|
|
||||||
|
void setStoreAddress(store_address_t setAddress);
|
||||||
|
|
||||||
|
store_address_t getStoreAddress();
|
||||||
|
|
||||||
|
ReturnValue_t deletePacket();
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
bool isSizeCorrect();
|
||||||
|
protected:
|
||||||
|
/**
|
||||||
|
* This is a pointer to the store all instances of the class use.
|
||||||
|
* If the store is not yet set (i.e. @c store is NULL), every constructor
|
||||||
|
* call tries to set it and throws an error message in case of failures.
|
||||||
|
* The default store is objects::TC_STORE.
|
||||||
|
*/
|
||||||
|
static StorageManagerIF* store;
|
||||||
|
/**
|
||||||
|
* The address where the packet data of the object instance is stored.
|
||||||
|
*/
|
||||||
|
store_address_t storeAddress;
|
||||||
|
/**
|
||||||
|
* A helper method to check if a store is assigned to the class.
|
||||||
|
* If not, the method tries to retrieve the store from the global
|
||||||
|
* ObjectManager.
|
||||||
|
* @return @li @c true if the store is linked or could be created.
|
||||||
|
* @li @c false otherwise.
|
||||||
|
*/
|
||||||
|
bool checkAndSetStore();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* FSFW_INC_FSFW_TMTCPACKET_CFDP_CFDPPACKETSTORED_H_ */
|
@ -1,4 +1,5 @@
|
|||||||
add_subdirectory(action)
|
add_subdirectory(action)
|
||||||
|
add_subdirectory(cfdp)
|
||||||
add_subdirectory(container)
|
add_subdirectory(container)
|
||||||
add_subdirectory(controller)
|
add_subdirectory(controller)
|
||||||
add_subdirectory(datapool)
|
add_subdirectory(datapool)
|
||||||
|
59
src/core/cfdp/CFDPHandler.cpp
Normal file
59
src/core/cfdp/CFDPHandler.cpp
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
#include "fsfw/cfdp/CFDPHandler.h"
|
||||||
|
|
||||||
|
#include "fsfw/tmtcservices/AcceptsTelemetryIF.h"
|
||||||
|
#include "fsfw/ipc/QueueFactory.h"
|
||||||
|
#include "fsfw/objectmanager/ObjectManager.h"
|
||||||
|
|
||||||
|
object_id_t CFDPHandler::packetSource = 0;
|
||||||
|
object_id_t CFDPHandler::packetDestination = 0;
|
||||||
|
|
||||||
|
CFDPHandler::CFDPHandler(object_id_t setObjectId, CFDPDistributor* dist) : SystemObject(setObjectId) {
|
||||||
|
requestQueue = QueueFactory::instance()->createMessageQueue(CFDP_HANDLER_MAX_RECEPTION);
|
||||||
|
distributor = dist;
|
||||||
|
}
|
||||||
|
|
||||||
|
CFDPHandler::~CFDPHandler() {}
|
||||||
|
|
||||||
|
ReturnValue_t CFDPHandler::initialize() {
|
||||||
|
ReturnValue_t result = SystemObject::initialize();
|
||||||
|
if (result != RETURN_OK) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
this->distributor->registerHandler(this);
|
||||||
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
ReturnValue_t CFDPHandler::handleRequest(uint8_t subservice) {
|
||||||
|
#if FSFW_VERBOSE_LEVEL >= 1
|
||||||
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::debug << "CFDPHandler::handleRequest" << std::endl;
|
||||||
|
#else
|
||||||
|
sif::printDebug("CFDPHandler::handleRequest");
|
||||||
|
#endif /* !FSFW_CPP_OSTREAM_ENABLED == 1 */
|
||||||
|
#endif
|
||||||
|
return RETURN_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
ReturnValue_t CFDPHandler::performOperation(uint8_t opCode) {
|
||||||
|
ReturnValue_t result = this->performService();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
ReturnValue_t CFDPHandler::performService() {
|
||||||
|
#if FSFW_VERBOSE_LEVEL >= 1
|
||||||
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::debug << "CFDPHandler::performService" << std::endl;
|
||||||
|
#else
|
||||||
|
sif::printDebug("CFDPHandler::performService");
|
||||||
|
#endif /* !FSFW_CPP_OSTREAM_ENABLED == 1 */
|
||||||
|
#endif
|
||||||
|
return RETURN_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t CFDPHandler::getIdentifier() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
MessageQueueId_t CFDPHandler::getRequestQueue() {
|
||||||
|
return this->requestQueue->getId();
|
||||||
|
}
|
4
src/core/cfdp/CMakeLists.txt
Normal file
4
src/core/cfdp/CMakeLists.txt
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
target_sources(${LIB_FSFW_NAME}
|
||||||
|
PRIVATE
|
||||||
|
CFDPHandler.cpp
|
||||||
|
)
|
@ -1,15 +1,18 @@
|
|||||||
#include "fsfw/tcdistribution/CCSDSDistributorIF.h"
|
#include "fsfw/tcdistribution/CCSDSDistributorIF.h"
|
||||||
#include "fsfw/tcdistribution/CFDPDistributor.h"
|
#include "fsfw/tcdistribution/CFDPDistributor.h"
|
||||||
|
|
||||||
|
#include "fsfw/tmtcpacket/cfdp/CFDPPacketStored.h"
|
||||||
|
|
||||||
#include "fsfw/objectmanager/ObjectManager.h"
|
#include "fsfw/objectmanager/ObjectManager.h"
|
||||||
#include "fsfw/serviceinterface/ServiceInterface.h"
|
|
||||||
|
|
||||||
#define CFDP_DISTRIBUTOR_DEBUGGING 0
|
#define CFDP_DISTRIBUTOR_DEBUGGING 0
|
||||||
|
|
||||||
CFDPDistributor::CFDPDistributor(uint16_t setApid, object_id_t setObjectId,
|
CFDPDistributor::CFDPDistributor(uint16_t setApid, object_id_t setObjectId,
|
||||||
object_id_t setPacketSource) :
|
object_id_t setPacketSource) :
|
||||||
TcDistributor(setObjectId), checker(setApid), verifyChannel(),
|
TcDistributor(setObjectId),
|
||||||
tcStatus(RETURN_FAILED), packetSource(setPacketSource) {}
|
tcStatus(RETURN_FAILED), packetSource(setPacketSource) {
|
||||||
|
this->apid = setApid;
|
||||||
|
}
|
||||||
|
|
||||||
CFDPDistributor::~CFDPDistributor() {}
|
CFDPDistributor::~CFDPDistributor() {}
|
||||||
|
|
||||||
@ -30,20 +33,7 @@ CFDPDistributor::TcMqMapIter CFDPDistributor::selectDestination() {
|
|||||||
}
|
}
|
||||||
this->currentPacket->setStoreAddress(this->currentMessage.getStorageId());
|
this->currentPacket->setStoreAddress(this->currentMessage.getStorageId());
|
||||||
if (currentPacket->getWholeData() != nullptr) {
|
if (currentPacket->getWholeData() != nullptr) {
|
||||||
tcStatus = checker.checkPacket(currentPacket);
|
queueMapIt = this->queueMap.find(0);
|
||||||
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
|
|
||||||
}
|
|
||||||
uint32_t queue_id = currentPacket->getService();
|
|
||||||
queueMapIt = this->queueMap.find(queue_id);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
tcStatus = PACKET_LOST;
|
tcStatus = PACKET_LOST;
|
||||||
@ -70,24 +60,24 @@ CFDPDistributor::TcMqMapIter CFDPDistributor::selectDestination() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ReturnValue_t CFDPDistributor::registerService(AcceptsTelecommandsIF* service) {
|
ReturnValue_t CFDPDistributor::registerHandler(AcceptsTelecommandsIF* handler) {
|
||||||
uint16_t serviceId = service->getIdentifier();
|
uint16_t handlerId = handler->getIdentifier(); //should be 0, because CFDPHandler does not set a set a service-ID
|
||||||
#if CFDP_DISTRIBUTOR_DEBUGGING == 1
|
#if CFDP_DISTRIBUTOR_DEBUGGING == 1
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
sif::info << "Service ID: " << static_cast<int>(serviceId) << std::endl;
|
sif::info << "CFDPDistributor::registerHandler: Handler ID: " << static_cast<int>(handlerId) << std::endl;
|
||||||
#else
|
#else
|
||||||
sif::printInfo("Service ID: %d\n", static_cast<int>(serviceId));
|
sif::printInfo("CFDPDistributor::registerHandler: Handler ID: %d\n", static_cast<int>(handlerId));
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
MessageQueueId_t queue = service->getRequestQueue();
|
MessageQueueId_t queue = handler->getRequestQueue();
|
||||||
auto returnPair = queueMap.emplace(serviceId, queue);
|
auto returnPair = queueMap.emplace(handlerId, queue);
|
||||||
if (not returnPair.second) {
|
if (not returnPair.second) {
|
||||||
#if FSFW_VERBOSE_LEVEL >= 1
|
#if FSFW_VERBOSE_LEVEL >= 1
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
sif::error << "CFDPDistributor::registerService: Service ID already"
|
sif::error << "CFDPDistributor::registerHandler: Service ID already"
|
||||||
" exists in map" << std::endl;
|
" exists in map" << std::endl;
|
||||||
#else
|
#else
|
||||||
sif::printError("CFDPDistributor::registerService: Service ID already exists in map\n");
|
sif::printError("CFDPDistributor::registerHandler: Service ID already exists in map\n");
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
return SERVICE_ID_ALREADY_EXISTS;
|
return SERVICE_ID_ALREADY_EXISTS;
|
||||||
@ -99,30 +89,30 @@ MessageQueueId_t CFDPDistributor::getRequestQueue() {
|
|||||||
return tcQueue->getId();
|
return tcQueue->getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t CFDPDistributor::callbackAfterSending(ReturnValue_t queueStatus) {
|
//ReturnValue_t CFDPDistributor::callbackAfterSending(ReturnValue_t queueStatus) {
|
||||||
if (queueStatus != RETURN_OK) {
|
// if (queueStatus != RETURN_OK) {
|
||||||
tcStatus = queueStatus;
|
// tcStatus = queueStatus;
|
||||||
}
|
// }
|
||||||
if (tcStatus != RETURN_OK) {
|
// if (tcStatus != RETURN_OK) {
|
||||||
this->verifyChannel.sendFailureReport(tc_verification::ACCEPTANCE_FAILURE,
|
// this->verifyChannel.sendFailureReport(tc_verification::ACCEPTANCE_FAILURE,
|
||||||
currentPacket, tcStatus);
|
// currentPacket, tcStatus);
|
||||||
// A failed packet is deleted immediately after reporting,
|
// // A failed packet is deleted immediately after reporting,
|
||||||
// otherwise it will block memory.
|
// // otherwise it will block memory.
|
||||||
currentPacket->deletePacket();
|
// currentPacket->deletePacket();
|
||||||
return RETURN_FAILED;
|
// return RETURN_FAILED;
|
||||||
} else {
|
// } else {
|
||||||
this->verifyChannel.sendSuccessReport(tc_verification::ACCEPTANCE_SUCCESS,
|
// this->verifyChannel.sendSuccessReport(tc_verification::ACCEPTANCE_SUCCESS,
|
||||||
currentPacket);
|
// currentPacket);
|
||||||
return RETURN_OK;
|
// return RETURN_OK;
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
||||||
uint16_t CFDPDistributor::getIdentifier() {
|
uint16_t CFDPDistributor::getIdentifier() {
|
||||||
return checker.getApid();
|
return this->apid;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t CFDPDistributor::initialize() {
|
ReturnValue_t CFDPDistributor::initialize() {
|
||||||
currentPacket = new TcPacketStoredPus();
|
currentPacket = new CFDPPacketStored();
|
||||||
if(currentPacket == nullptr) {
|
if(currentPacket == nullptr) {
|
||||||
// Should not happen, memory allocation failed!
|
// Should not happen, memory allocation failed!
|
||||||
return ObjectManagerIF::CHILD_INIT_FAILED;
|
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||||
|
@ -3,5 +3,6 @@ target_sources(${LIB_FSFW_NAME} PRIVATE
|
|||||||
SpacePacketBase.cpp
|
SpacePacketBase.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
add_subdirectory(cfdp)
|
||||||
add_subdirectory(packetmatcher)
|
add_subdirectory(packetmatcher)
|
||||||
add_subdirectory(pus)
|
add_subdirectory(pus)
|
20
src/core/tmtcpacket/cfdp/CFDPPacket.cpp
Normal file
20
src/core/tmtcpacket/cfdp/CFDPPacket.cpp
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
#include "fsfw/tmtcpacket/cfdp/CFDPPacket.h"
|
||||||
|
|
||||||
|
#include "fsfw/globalfunctions/CRC.h"
|
||||||
|
#include "fsfw/globalfunctions/arrayprinter.h"
|
||||||
|
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||||
|
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
|
CFDPPacket::CFDPPacket(const uint8_t* setData): SpacePacketBase(setData) {}
|
||||||
|
|
||||||
|
CFDPPacket::~CFDPPacket() {}
|
||||||
|
|
||||||
|
void CFDPPacket::print() {
|
||||||
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::info << "CFDPPacket::print:" << std::endl;
|
||||||
|
#else
|
||||||
|
sif::printInfo("CFDPPacket::print:\n");
|
||||||
|
#endif
|
||||||
|
arrayprinter::print(getWholeData(), getFullSize());
|
||||||
|
}
|
85
src/core/tmtcpacket/cfdp/CFDPPacketStored.cpp
Normal file
85
src/core/tmtcpacket/cfdp/CFDPPacketStored.cpp
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
#include "fsfw/tmtcpacket/cfdp/CFDPPacketStored.h"
|
||||||
|
#include "fsfw/objectmanager/ObjectManager.h"
|
||||||
|
|
||||||
|
StorageManagerIF* CFDPPacketStored::store = nullptr;
|
||||||
|
|
||||||
|
CFDPPacketStored::CFDPPacketStored(): CFDPPacket(nullptr) {
|
||||||
|
}
|
||||||
|
|
||||||
|
CFDPPacketStored::CFDPPacketStored(store_address_t setAddress): CFDPPacket(nullptr) {
|
||||||
|
this->setStoreAddress(setAddress);
|
||||||
|
}
|
||||||
|
|
||||||
|
CFDPPacketStored::CFDPPacketStored(const uint8_t* data, size_t size): CFDPPacket(data) {
|
||||||
|
if (this->getFullSize() != size) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (this->checkAndSetStore()) {
|
||||||
|
ReturnValue_t status = store->addData(&storeAddress, data, size);
|
||||||
|
if (status != HasReturnvaluesIF::RETURN_OK) {
|
||||||
|
this->setData(nullptr);
|
||||||
|
}
|
||||||
|
const uint8_t* storePtr = nullptr;
|
||||||
|
// Repoint base data pointer to the data in the store.
|
||||||
|
store->getData(storeAddress, &storePtr, &size);
|
||||||
|
this->setData(storePtr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ReturnValue_t CFDPPacketStored::deletePacket() {
|
||||||
|
ReturnValue_t result = this->store->deleteData(this->storeAddress);
|
||||||
|
this->storeAddress.raw = StorageManagerIF::INVALID_ADDRESS;
|
||||||
|
this->setData(nullptr);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//CFDPPacket* CFDPPacketStored::getPacketBase() {
|
||||||
|
// return this;
|
||||||
|
//}
|
||||||
|
void CFDPPacketStored::setStoreAddress(store_address_t setAddress) {
|
||||||
|
this->storeAddress = setAddress;
|
||||||
|
const uint8_t* tempData = nullptr;
|
||||||
|
size_t tempSize;
|
||||||
|
ReturnValue_t status = StorageManagerIF::RETURN_FAILED;
|
||||||
|
if (this->checkAndSetStore()) {
|
||||||
|
status = this->store->getData(this->storeAddress, &tempData, &tempSize);
|
||||||
|
}
|
||||||
|
if (status == StorageManagerIF::RETURN_OK) {
|
||||||
|
this->setData(tempData);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this->setData(nullptr);
|
||||||
|
this->storeAddress.raw = StorageManagerIF::INVALID_ADDRESS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
store_address_t CFDPPacketStored::getStoreAddress() {
|
||||||
|
return this->storeAddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CFDPPacketStored::checkAndSetStore() {
|
||||||
|
if (this->store == nullptr) {
|
||||||
|
this->store = ObjectManager::instance()->get<StorageManagerIF>(objects::TC_STORE);
|
||||||
|
if (this->store == nullptr) {
|
||||||
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::error << "CFDPPacketStored::CFDPPacketStored: TC Store not found!"
|
||||||
|
<< std::endl;
|
||||||
|
#endif
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CFDPPacketStored::isSizeCorrect() {
|
||||||
|
const uint8_t* temp_data = nullptr;
|
||||||
|
size_t temp_size;
|
||||||
|
ReturnValue_t status = this->store->getData(this->storeAddress, &temp_data,
|
||||||
|
&temp_size);
|
||||||
|
if (status == StorageManagerIF::RETURN_OK) {
|
||||||
|
if (this->getFullSize() == temp_size) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
4
src/core/tmtcpacket/cfdp/CMakeLists.txt
Normal file
4
src/core/tmtcpacket/cfdp/CMakeLists.txt
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
target_sources(${LIB_FSFW_NAME} PRIVATE
|
||||||
|
CFDPPacket.cpp
|
||||||
|
CFDPPacketStored.cpp
|
||||||
|
)
|
Loading…
Reference in New Issue
Block a user