allow deferred init

This commit is contained in:
Robin Müller 2022-09-07 18:20:38 +02:00
parent 770463e618
commit 11a4b27642
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC
3 changed files with 18 additions and 6 deletions

View File

@ -116,6 +116,10 @@ ReturnValue_t cfdp::DestHandler::initialize() {
return FAILED;
}
}
if (fp.msgQueue == nullptr) {
return FAILED;
}
return OK;
}
@ -421,7 +425,7 @@ ReturnValue_t cfdp::DestHandler::sendFinishedPdu() {
return result;
}
TmTcMessage msg(storeId);
result = fp.msgQueue.sendMessage(fp.packetDest.getReportReceptionQueue(), &msg);
result = fp.msgQueue->sendMessage(fp.packetDest.getReportReceptionQueue(), &msg);
if (result != OK) {
// TODO: Error handling and event, this is a non CFDP specific error (most likely store is full)
return result;
@ -451,3 +455,9 @@ void cfdp::DestHandler::checkAndHandleError(ReturnValue_t result, uint8_t& error
errorIdx++;
}
}
void cfdp::DestHandler::setMsgQueue(MessageQueueIF& queue) { fp.msgQueue = &queue; }
void cfdp::DestHandler::setEventReporter(EventReportingProxyIF& reporter) {
fp.eventReporter = &reporter;
}

View File

@ -62,12 +62,12 @@ struct DestHandlerParams {
};
struct FsfwParams {
FsfwParams(AcceptsTelemetryIF& packetDest, MessageQueueIF& msgQueue,
EventReportingProxyIF& eventReporter)
FsfwParams(AcceptsTelemetryIF& packetDest, MessageQueueIF* msgQueue,
EventReportingProxyIF* eventReporter)
: packetDest(packetDest), msgQueue(msgQueue), eventReporter(eventReporter) {}
AcceptsTelemetryIF& packetDest;
MessageQueueIF& msgQueue;
EventReportingProxyIF& eventReporter;
MessageQueueIF* msgQueue;
EventReportingProxyIF* eventReporter = nullptr;
StorageManagerIF* tcStore = nullptr;
StorageManagerIF* tmStore = nullptr;
};
@ -116,6 +116,8 @@ class DestHandler {
* - @c CALL_FSM_AGAIN State machine should be called again.
*/
const FsmResult& performStateMachine();
void setMsgQueue(MessageQueueIF& queue);
void setEventReporter(EventReportingProxyIF& reporter);
ReturnValue_t passPacket(PacketInfo packet);

View File

@ -38,7 +38,7 @@ TEST_CASE("CFDP Dest Handler", "[cfdp]") {
LocalPool::LocalPoolConfig storeCfg = {{10, 32}, {10, 64}, {10, 128}, {10, 1024}};
StorageManagerMock tcStore(2, storeCfg);
StorageManagerMock tmStore(3, storeCfg);
FsfwParams fp(tmReceiver, mqMock, eventReporterMock);
FsfwParams fp(tmReceiver, &mqMock, &eventReporterMock);
RemoteEntityCfg cfg;
cfg.remoteId = remoteId;
remoteCfgTableMock.addRemoteConfig(cfg);