continue handler implementation

This commit is contained in:
Robin Müller 2022-09-08 11:26:29 +02:00
parent 9c9daffbbc
commit 6d43fa8911
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC
3 changed files with 64 additions and 23 deletions

View File

@ -1,16 +1,19 @@
#include "CfdpHandler.h" #include "CfdpHandler.h"
#include "fsfw/cfdp/pdu/PduHeaderReader.h"
#include "fsfw/ipc/QueueFactory.h" #include "fsfw/ipc/QueueFactory.h"
#include "fsfw/tmtcservices/TmTcMessage.h"
using namespace returnvalue; using namespace returnvalue;
using namespace cfdp; using namespace cfdp;
CfdpHandler::CfdpHandler(const HandlerCfg& cfg) CfdpHandler::CfdpHandler(const FsfwHandlerParams& fsfwParams, const CfdpHandlerCfg& cfdpCfg)
: SystemObject(cfg.objectId), : SystemObject(fsfwParams.objectId),
UserBase(cfg.vfs), UserBase(fsfwParams.vfs),
destHandler( destHandler(DestHandlerParams(cfdpCfg.cfg, *this, *this, cfdpCfg.packetInfoList,
DestHandlerParams(cfg.cfg, *this, *this, cfg.packetInfoList, cfg.lostSegmentsList), cfdpCfg.lostSegmentsList),
FsfwParams(cfg.packetDest, nullptr, this)) { FsfwParams(fsfwParams.packetDest, nullptr, this, fsfwParams.tcStore,
fsfwParams.tmStore)) {
// TODO: Make queue params configurable, or better yet, expect it to be passed externally // TODO: Make queue params configurable, or better yet, expect it to be passed externally
msgQueue = QueueFactory::instance()->createMessageQueue(); msgQueue = QueueFactory::instance()->createMessageQueue();
destHandler.setMsgQueue(*msgQueue); destHandler.setMsgQueue(*msgQueue);
@ -19,8 +22,7 @@ CfdpHandler::CfdpHandler(const HandlerCfg& cfg)
[[nodiscard]] const char* CfdpHandler::getName() const { return "CFDP Handler"; } [[nodiscard]] const char* CfdpHandler::getName() const { return "CFDP Handler"; }
[[nodiscard]] uint32_t CfdpHandler::getIdentifier() const { [[nodiscard]] uint32_t CfdpHandler::getIdentifier() const {
// TODO: Return local entity ID? Which will probably be equal to APID return destHandler.getDestHandlerParams().cfg.localId.getValue();
return 0;
} }
[[nodiscard]] MessageQueueId_t CfdpHandler::getRequestQueue() const { return msgQueue->getId(); } [[nodiscard]] MessageQueueId_t CfdpHandler::getRequestQueue() const { return msgQueue->getId(); }
@ -30,13 +32,26 @@ ReturnValue_t CfdpHandler::initialize() {
if (result != OK) { if (result != OK) {
return result; return result;
} }
tcStore = destHandler.getTcStore();
tmStore = destHandler.getTmStore();
return SystemObject::initialize(); return SystemObject::initialize();
} }
ReturnValue_t CfdpHandler::performOperation(uint8_t operationCode) { ReturnValue_t CfdpHandler::performOperation(uint8_t operationCode) {
// TODO: Receive TC packets and route them to source and dest handler, depending on which is // TODO: Receive TC packets and route them to source and dest handler, depending on which is
// correct or more appropriate // correct or more appropriate
return OK; ReturnValue_t status;
ReturnValue_t result = OK;
TmTcMessage tmtcMsg;
for (status = msgQueue->receiveMessage(&tmtcMsg); status == returnvalue::OK;
status = msgQueue->receiveMessage(&tmtcMsg)) {
result = handleCfdpPacket(tmtcMsg);
if (result != OK) {
status = result;
}
}
return status;
} }
void CfdpHandler::transactionIndication(const cfdp::TransactionId& id) {} void CfdpHandler::transactionIndication(const cfdp::TransactionId& id) {}
@ -56,3 +71,21 @@ void CfdpHandler::eofRecvIndication(const cfdp::TransactionId& id) {}
bool CfdpHandler::getRemoteCfg(const cfdp::EntityId& remoteId, cfdp::RemoteEntityCfg** cfg) { bool CfdpHandler::getRemoteCfg(const cfdp::EntityId& remoteId, cfdp::RemoteEntityCfg** cfg) {
return false; return false;
} }
ReturnValue_t CfdpHandler::handleCfdpPacket(TmTcMessage& msg) {
auto accessorPair = tcStore->getData(msg.getStorageId());
PduHeaderReader reader(accessorPair.second.data(), accessorPair.second.size());
ReturnValue_t result = reader.parseData();
if (result != returnvalue::OK) {
return result;
}
// The CFDP distributor should have taken care of ensuring the destination ID is correct
PduTypes type = reader.getPduType();
// Only the destination handler can process these PDUs
if (type == PduTypes::FILE_DATA) {
} else {
// Route depending on directive type. Retrieve directive type from raw stream for better
// performance (with size check)
}
return OK;
}

View File

@ -7,23 +7,27 @@
#include "fsfw/objectmanager/SystemObject.h" #include "fsfw/objectmanager/SystemObject.h"
#include "fsfw/tasks/ExecutableObjectIF.h" #include "fsfw/tasks/ExecutableObjectIF.h"
#include "fsfw/tmtcservices/AcceptsTelecommandsIF.h" #include "fsfw/tmtcservices/AcceptsTelecommandsIF.h"
#include "fsfw/tmtcservices/TmTcMessage.h"
struct HandlerCfg { struct FsfwHandlerParams {
HandlerCfg(object_id_t objectId, cfdp::LocalEntityCfg cfg, HasFileSystemIF& vfs, FsfwHandlerParams(object_id_t objectId, HasFileSystemIF& vfs, AcceptsTelemetryIF& packetDest,
AcceptsTelemetryIF& packetDest, cfdp::PacketInfoListBase& packetInfo, StorageManagerIF& tcStore, StorageManagerIF& tmStore)
cfdp::LostSegmentsListBase& lostSegmentsList) : objectId(objectId), vfs(vfs), packetDest(packetDest), tcStore(tcStore), tmStore(tmStore) {}
: objectId(objectId),
cfg(std::move(cfg)),
vfs(vfs),
packetInfoList(packetInfo),
lostSegmentsList(lostSegmentsList),
packetDest(packetDest) {}
object_id_t objectId{}; object_id_t objectId{};
cfdp::LocalEntityCfg cfg;
HasFileSystemIF& vfs; HasFileSystemIF& vfs;
AcceptsTelemetryIF& packetDest;
StorageManagerIF& tcStore;
StorageManagerIF& tmStore;
};
struct CfdpHandlerCfg {
CfdpHandlerCfg(cfdp::LocalEntityCfg cfg, cfdp::PacketInfoListBase& packetInfo,
cfdp::LostSegmentsListBase& lostSegmentsList)
: cfg(std::move(cfg)), packetInfoList(packetInfo), lostSegmentsList(lostSegmentsList) {}
cfdp::LocalEntityCfg cfg;
cfdp::PacketInfoListBase& packetInfoList; cfdp::PacketInfoListBase& packetInfoList;
cfdp::LostSegmentsListBase& lostSegmentsList; cfdp::LostSegmentsListBase& lostSegmentsList;
AcceptsTelemetryIF& packetDest;
}; };
class CfdpHandler : public SystemObject, class CfdpHandler : public SystemObject,
@ -32,7 +36,7 @@ class CfdpHandler : public SystemObject,
public ExecutableObjectIF, public ExecutableObjectIF,
public AcceptsTelecommandsIF { public AcceptsTelecommandsIF {
public: public:
explicit CfdpHandler(const HandlerCfg& cfg); explicit CfdpHandler(const FsfwHandlerParams& fsfwParams, const CfdpHandlerCfg& cfdpCfg);
[[nodiscard]] const char* getName() const override; [[nodiscard]] const char* getName() const override;
[[nodiscard]] uint32_t getIdentifier() const override; [[nodiscard]] uint32_t getIdentifier() const override;
@ -62,6 +66,10 @@ class CfdpHandler : public SystemObject,
private: private:
MessageQueueIF* msgQueue = nullptr; MessageQueueIF* msgQueue = nullptr;
cfdp::DestHandler destHandler; cfdp::DestHandler destHandler;
StorageManagerIF* tcStore = nullptr;
StorageManagerIF* tmStore = nullptr;
ReturnValue_t handleCfdpPacket(TmTcMessage& msg);
}; };
#endif // FSFW_EXAMPLE_HOSTED_CFDPHANDLER_H #endif // FSFW_EXAMPLE_HOSTED_CFDPHANDLER_H

2
fsfw

@ -1 +1 @@
Subproject commit 11a4b276423ac287f5522cdbf913a81e1ee3d347 Subproject commit c87667c03f82f2be88e2a684b98a25be4cdae26b