CFDP source handler #776
2
fsfw
2
fsfw
@ -1 +1 @@
|
|||||||
Subproject commit b39e1c7e076914d18fbb78716d3b5b9b12b8504b
|
Subproject commit 60dcacf432aa0a7b739f8fdf8bf4aaa37ac614e5
|
@ -11,9 +11,10 @@ using namespace cfdp;
|
|||||||
|
|
||||||
CfdpHandler::CfdpHandler(const FsfwHandlerParams& fsfwHandlerParams, const CfdpHandlerCfg& cfdpCfg)
|
CfdpHandler::CfdpHandler(const FsfwHandlerParams& fsfwHandlerParams, const CfdpHandlerCfg& cfdpCfg)
|
||||||
: SystemObject(fsfwHandlerParams.objectId),
|
: SystemObject(fsfwHandlerParams.objectId),
|
||||||
msgQueue(fsfwHandlerParams.msgQueue),
|
tmtcQueue(fsfwHandlerParams.tmtcQueue),
|
||||||
|
cfdpRequestQueue(fsfwHandlerParams.cfdpQueue),
|
||||||
localCfg(cfdpCfg.id, cfdpCfg.indicCfg, cfdpCfg.faultHandler),
|
localCfg(cfdpCfg.id, cfdpCfg.indicCfg, cfdpCfg.faultHandler),
|
||||||
fsfwParams(fsfwHandlerParams.packetDest, &fsfwHandlerParams.msgQueue, this,
|
fsfwParams(fsfwHandlerParams.packetDest, &fsfwHandlerParams.tmtcQueue, this,
|
||||||
fsfwHandlerParams.tcStore, fsfwHandlerParams.tmStore),
|
fsfwHandlerParams.tcStore, fsfwHandlerParams.tmStore),
|
||||||
destHandler(DestHandlerParams(localCfg, cfdpCfg.userHandler, cfdpCfg.remoteCfgProvider,
|
destHandler(DestHandlerParams(localCfg, cfdpCfg.userHandler, cfdpCfg.remoteCfgProvider,
|
||||||
cfdpCfg.packetInfoList, cfdpCfg.lostSegmentsList),
|
cfdpCfg.packetInfoList, cfdpCfg.lostSegmentsList),
|
||||||
@ -27,7 +28,7 @@ CfdpHandler::CfdpHandler(const FsfwHandlerParams& fsfwHandlerParams, const CfdpH
|
|||||||
return destHandler.getDestHandlerParams().cfg.localId.getValue();
|
return destHandler.getDestHandlerParams().cfg.localId.getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] MessageQueueId_t CfdpHandler::getRequestQueue() const { return msgQueue.getId(); }
|
[[nodiscard]] MessageQueueId_t CfdpHandler::getRequestQueue() const { return tmtcQueue.getId(); }
|
||||||
|
|
||||||
ReturnValue_t CfdpHandler::initialize() {
|
ReturnValue_t CfdpHandler::initialize() {
|
||||||
ReturnValue_t result = destHandler.initialize();
|
ReturnValue_t result = destHandler.initialize();
|
||||||
@ -46,19 +47,23 @@ ReturnValue_t CfdpHandler::performOperation(uint8_t operationCode) {
|
|||||||
ReturnValue_t status;
|
ReturnValue_t status;
|
||||||
ReturnValue_t result = OK;
|
ReturnValue_t result = OK;
|
||||||
TmTcMessage tmtcMsg;
|
TmTcMessage tmtcMsg;
|
||||||
for (status = msgQueue.receiveMessage(&tmtcMsg); status == returnvalue::OK;
|
for (status = tmtcQueue.receiveMessage(&tmtcMsg); status == returnvalue::OK;
|
||||||
status = msgQueue.receiveMessage(&tmtcMsg)) {
|
status = tmtcQueue.receiveMessage(&tmtcMsg)) {
|
||||||
result = handleCfdpPacket(tmtcMsg);
|
result = handleCfdpPacket(tmtcMsg);
|
||||||
if (result != OK) {
|
if (result != OK) {
|
||||||
status = result;
|
status = result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
auto& fsmRes = destHandler.performStateMachine();
|
const DestHandler::FsmResult& destResult = destHandler.stateMachine();
|
||||||
// TODO: Error handling?
|
// TODO: Error handling?
|
||||||
while (fsmRes.callStatus == CallStatus::CALL_AGAIN) {
|
while (destResult.callStatus == CallStatus::CALL_AGAIN) {
|
||||||
destHandler.performStateMachine();
|
destHandler.stateMachine();
|
||||||
// TODO: Error handling?
|
// TODO: Error handling?
|
||||||
}
|
}
|
||||||
|
const SourceHandler::FsmResult& srcResult = srcHandler.stateMachine();
|
||||||
|
while (srcResult.callStatus == CallStatus::CALL_AGAIN) {
|
||||||
|
srcHandler.stateMachine();
|
||||||
|
}
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,19 +14,22 @@
|
|||||||
|
|
||||||
struct FsfwHandlerParams {
|
struct FsfwHandlerParams {
|
||||||
FsfwHandlerParams(object_id_t objectId, HasFileSystemIF& vfs, AcceptsTelemetryIF& packetDest,
|
FsfwHandlerParams(object_id_t objectId, HasFileSystemIF& vfs, AcceptsTelemetryIF& packetDest,
|
||||||
StorageManagerIF& tcStore, StorageManagerIF& tmStore, MessageQueueIF& msgQueue)
|
StorageManagerIF& tcStore, StorageManagerIF& tmStore, MessageQueueIF& tmtcQueue,
|
||||||
|
MessageQueueIF& cfdpQueue)
|
||||||
: objectId(objectId),
|
: objectId(objectId),
|
||||||
vfs(vfs),
|
vfs(vfs),
|
||||||
packetDest(packetDest),
|
packetDest(packetDest),
|
||||||
tcStore(tcStore),
|
tcStore(tcStore),
|
||||||
tmStore(tmStore),
|
tmStore(tmStore),
|
||||||
msgQueue(msgQueue) {}
|
tmtcQueue(tmtcQueue),
|
||||||
|
cfdpQueue(cfdpQueue) {}
|
||||||
object_id_t objectId{};
|
object_id_t objectId{};
|
||||||
HasFileSystemIF& vfs;
|
HasFileSystemIF& vfs;
|
||||||
AcceptsTelemetryIF& packetDest;
|
AcceptsTelemetryIF& packetDest;
|
||||||
StorageManagerIF& tcStore;
|
StorageManagerIF& tcStore;
|
||||||
StorageManagerIF& tmStore;
|
StorageManagerIF& tmStore;
|
||||||
MessageQueueIF& msgQueue;
|
MessageQueueIF& tmtcQueue;
|
||||||
|
MessageQueueIF& cfdpQueue;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CfdpHandlerCfg {
|
struct CfdpHandlerCfg {
|
||||||
@ -63,7 +66,8 @@ class CfdpHandler : public SystemObject, public ExecutableObjectIF, public Accep
|
|||||||
ReturnValue_t performOperation(uint8_t operationCode) override;
|
ReturnValue_t performOperation(uint8_t operationCode) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MessageQueueIF& msgQueue;
|
MessageQueueIF& tmtcQueue;
|
||||||
|
MessageQueueIF& cfdpRequestQueue;
|
||||||
cfdp::LocalEntityCfg localCfg;
|
cfdp::LocalEntityCfg localCfg;
|
||||||
cfdp::FsfwParams fsfwParams;
|
cfdp::FsfwParams fsfwParams;
|
||||||
SeqCountProviderU16 seqCntProvider;
|
SeqCountProviderU16 seqCntProvider;
|
||||||
|
@ -7,8 +7,13 @@ namespace cfdp {
|
|||||||
|
|
||||||
class EiveUserHandler : public cfdp::UserBase {
|
class EiveUserHandler : public cfdp::UserBase {
|
||||||
public:
|
public:
|
||||||
explicit EiveUserHandler(HasFileSystemIF& vfs) : cfdp::UserBase(vfs) {}
|
explicit EiveUserHandler(HasFileSystemIF& vfs, MessageQueueId_t cfdpRequestId)
|
||||||
virtual ~EiveUserHandler() = default;
|
: cfdp::UserBase(vfs) {
|
||||||
|
userQueue = QueueFactory::instance()->createMessageQueue(10);
|
||||||
|
userQueue->setDefaultDestination(cfdpRequestId);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual ~EiveUserHandler() { QueueFactory::instance()->deleteMessageQueue(userQueue); }
|
||||||
|
|
||||||
void transactionIndication(const cfdp::TransactionId& id) override {}
|
void transactionIndication(const cfdp::TransactionId& id) override {}
|
||||||
void eofSentIndication(const cfdp::TransactionId& id) override {}
|
void eofSentIndication(const cfdp::TransactionId& id) override {}
|
||||||
@ -16,6 +21,7 @@ class EiveUserHandler : public cfdp::UserBase {
|
|||||||
sif::info << "File transaction finished for transaction with " << params.id << std::endl;
|
sif::info << "File transaction finished for transaction with " << params.id << std::endl;
|
||||||
}
|
}
|
||||||
void metadataRecvdIndication(const cfdp::MetadataRecvdParams& params) override {
|
void metadataRecvdIndication(const cfdp::MetadataRecvdParams& params) override {
|
||||||
|
// TODO: Parse user messages and convert them into put requests where applicable.
|
||||||
sif::info << "Metadata received for transaction with " << params.id << std::endl;
|
sif::info << "Metadata received for transaction with " << params.id << std::endl;
|
||||||
}
|
}
|
||||||
void fileSegmentRecvdIndication(const cfdp::FileSegmentRecvdParams& params) override {}
|
void fileSegmentRecvdIndication(const cfdp::FileSegmentRecvdParams& params) override {}
|
||||||
@ -29,6 +35,9 @@ class EiveUserHandler : public cfdp::UserBase {
|
|||||||
void eofRecvIndication(const cfdp::TransactionId& id) override {
|
void eofRecvIndication(const cfdp::TransactionId& id) override {
|
||||||
sif::info << "EOF PDU received for transaction with " << id << std::endl;
|
sif::info << "EOF PDU received for transaction with " << id << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
MessageQueueIF* userQueue;
|
||||||
};
|
};
|
||||||
|
|
||||||
class EiveFaultHandler : public cfdp::FaultHandlerBase {
|
class EiveFaultHandler : public cfdp::FaultHandlerBase {
|
||||||
|
@ -85,7 +85,7 @@ EntityId REMOTE_CFDP_ID(UnsignedByteField<uint16_t>(config::EIVE_GROUND_CFDP_ENT
|
|||||||
RemoteEntityCfg GROUND_REMOTE_CFG(REMOTE_CFDP_ID);
|
RemoteEntityCfg GROUND_REMOTE_CFG(REMOTE_CFDP_ID);
|
||||||
OneRemoteConfigProvider REMOTE_CFG_PROVIDER(GROUND_REMOTE_CFG);
|
OneRemoteConfigProvider REMOTE_CFG_PROVIDER(GROUND_REMOTE_CFG);
|
||||||
HostFilesystem HOST_FS;
|
HostFilesystem HOST_FS;
|
||||||
EiveUserHandler USER_HANDLER(HOST_FS);
|
// EiveUserHandler USER_HANDLER(HOST_FS);
|
||||||
EiveFaultHandler EIVE_FAULT_HANDLER;
|
EiveFaultHandler EIVE_FAULT_HANDLER;
|
||||||
|
|
||||||
} // namespace cfdp
|
} // namespace cfdp
|
||||||
@ -274,14 +274,16 @@ void ObjectFactory::produceGenericObjects(HealthTableIF** healthTable_, PusTmFun
|
|||||||
CfdpDistribCfg distribCfg(objects::CFDP_DISTRIBUTOR, *tcStore, cfdpMsgQueue);
|
CfdpDistribCfg distribCfg(objects::CFDP_DISTRIBUTOR, *tcStore, cfdpMsgQueue);
|
||||||
new CfdpDistributor(distribCfg);
|
new CfdpDistributor(distribCfg);
|
||||||
|
|
||||||
auto* msgQueue = QueueFactory::instance()->createMessageQueue(32);
|
auto* tmtcQueue = QueueFactory::instance()->createMessageQueue(32);
|
||||||
|
auto* cfdpQueue = QueueFactory::instance()->createMessageQueue(16);
|
||||||
|
auto eiveUserHandler = new EiveUserHandler(HOST_FS, cfdpQueue->getId());
|
||||||
FsfwHandlerParams params(objects::CFDP_HANDLER, HOST_FS, **cfdpFunnel, *tcStore, **tmStore,
|
FsfwHandlerParams params(objects::CFDP_HANDLER, HOST_FS, **cfdpFunnel, *tcStore, **tmStore,
|
||||||
*msgQueue);
|
*tmtcQueue, *cfdpQueue);
|
||||||
cfdp::IndicationCfg indicationCfg;
|
cfdp::IndicationCfg indicationCfg;
|
||||||
UnsignedByteField<uint16_t> apid(config::EIVE_LOCAL_CFDP_ENTITY_ID);
|
UnsignedByteField<uint16_t> apid(config::EIVE_LOCAL_CFDP_ENTITY_ID);
|
||||||
cfdp::EntityId localId(apid);
|
cfdp::EntityId localId(apid);
|
||||||
GROUND_REMOTE_CFG.defaultChecksum = cfdp::ChecksumType::CRC_32;
|
GROUND_REMOTE_CFG.defaultChecksum = cfdp::ChecksumType::CRC_32;
|
||||||
CfdpHandlerCfg cfdpCfg(localId, indicationCfg, USER_HANDLER, EIVE_FAULT_HANDLER, PACKET_LIST,
|
CfdpHandlerCfg cfdpCfg(localId, indicationCfg, *eiveUserHandler, EIVE_FAULT_HANDLER, PACKET_LIST,
|
||||||
LOST_SEGMENTS, REMOTE_CFG_PROVIDER);
|
LOST_SEGMENTS, REMOTE_CFG_PROVIDER);
|
||||||
auto* cfdpHandler = new CfdpHandler(params, cfdpCfg);
|
auto* cfdpHandler = new CfdpHandler(params, cfdpCfg);
|
||||||
// All CFDP packets arrive wrapped inside CCSDS space packets
|
// All CFDP packets arrive wrapped inside CCSDS space packets
|
||||||
|
Loading…
x
Reference in New Issue
Block a user