2022-07-28 15:13:27 +02:00
|
|
|
#include "fsfw/cfdp/CfdpHandler.h"
|
2021-12-03 15:37:49 +01:00
|
|
|
|
2022-07-28 15:13:27 +02:00
|
|
|
#include "fsfw/cfdp/CfdpMessage.h"
|
2022-02-02 10:29:30 +01:00
|
|
|
#include "fsfw/ipc/CommandMessage.h"
|
2021-12-03 15:37:49 +01:00
|
|
|
#include "fsfw/ipc/QueueFactory.h"
|
|
|
|
#include "fsfw/objectmanager/ObjectManager.h"
|
2022-02-02 10:29:30 +01:00
|
|
|
#include "fsfw/storagemanager/storeAddress.h"
|
|
|
|
#include "fsfw/tmtcservices/AcceptsTelemetryIF.h"
|
2021-12-03 15:37:49 +01:00
|
|
|
|
2022-07-28 15:13:27 +02:00
|
|
|
object_id_t CfdpHandler::packetSource = 0;
|
|
|
|
object_id_t CfdpHandler::packetDestination = 0;
|
2021-12-03 15:37:49 +01:00
|
|
|
|
2022-07-29 12:03:14 +02:00
|
|
|
CfdpHandler::CfdpHandler(object_id_t setObjectId, CfdpDistributor* dist)
|
2022-02-02 10:29:30 +01:00
|
|
|
: SystemObject(setObjectId) {
|
|
|
|
requestQueue = QueueFactory::instance()->createMessageQueue(CFDP_HANDLER_MAX_RECEPTION);
|
|
|
|
distributor = dist;
|
2021-12-03 15:37:49 +01:00
|
|
|
}
|
|
|
|
|
2022-07-28 15:13:27 +02:00
|
|
|
CfdpHandler::~CfdpHandler() = default;
|
2021-12-03 15:37:49 +01:00
|
|
|
|
2022-07-28 15:13:27 +02:00
|
|
|
ReturnValue_t CfdpHandler::initialize() {
|
2022-02-02 10:29:30 +01:00
|
|
|
ReturnValue_t result = SystemObject::initialize();
|
|
|
|
if (result != RETURN_OK) {
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
this->distributor->registerHandler(this);
|
|
|
|
return HasReturnvaluesIF::RETURN_OK;
|
2021-12-03 15:37:49 +01:00
|
|
|
}
|
|
|
|
|
2022-07-28 15:13:27 +02:00
|
|
|
ReturnValue_t CfdpHandler::handleRequest(store_address_t storeId) {
|
2021-12-03 15:37:49 +01:00
|
|
|
#if FSFW_VERBOSE_LEVEL >= 1
|
|
|
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
2022-02-02 10:29:30 +01:00
|
|
|
sif::debug << "CFDPHandler::handleRequest" << std::endl;
|
2021-12-03 15:37:49 +01:00
|
|
|
#else
|
2022-02-02 10:29:30 +01:00
|
|
|
sif::printDebug("CFDPHandler::handleRequest\n");
|
2021-12-03 15:37:49 +01:00
|
|
|
#endif /* !FSFW_CPP_OSTREAM_ENABLED == 1 */
|
|
|
|
#endif
|
|
|
|
|
2022-02-02 10:29:30 +01:00
|
|
|
// TODO read out packet from store using storeId
|
2021-12-03 15:37:49 +01:00
|
|
|
|
2022-02-02 10:29:30 +01:00
|
|
|
return RETURN_OK;
|
2021-12-03 15:37:49 +01:00
|
|
|
}
|
|
|
|
|
2022-07-28 15:13:27 +02:00
|
|
|
ReturnValue_t CfdpHandler::performOperation(uint8_t opCode) {
|
2022-02-02 10:29:30 +01:00
|
|
|
ReturnValue_t status = RETURN_OK;
|
|
|
|
CommandMessage currentMessage;
|
|
|
|
for (status = this->requestQueue->receiveMessage(¤tMessage); status == RETURN_OK;
|
|
|
|
status = this->requestQueue->receiveMessage(¤tMessage)) {
|
2022-07-28 15:13:27 +02:00
|
|
|
store_address_t storeId = CfdpMessage::getStoreId(¤tMessage);
|
2022-02-02 10:29:30 +01:00
|
|
|
this->handleRequest(storeId);
|
|
|
|
}
|
|
|
|
return RETURN_OK;
|
2021-12-03 15:37:49 +01:00
|
|
|
}
|
|
|
|
|
2022-08-01 11:00:36 +02:00
|
|
|
uint32_t CfdpHandler::getIdentifier() const { return 0; }
|
2021-12-03 15:37:49 +01:00
|
|
|
|
2022-08-01 11:00:36 +02:00
|
|
|
MessageQueueId_t CfdpHandler::getRequestQueue() const { return this->requestQueue->getId(); }
|