some more cleaning up

This commit is contained in:
Robin Müller 2024-10-25 16:33:16 +02:00
parent 0fc5744719
commit 0af5d37b35
Signed by: muellerr
GPG Key ID: A649FB78196E3849
5 changed files with 27 additions and 66 deletions

View File

@ -17,9 +17,7 @@
#include "fsfw/cfdp/pdu/MetadataPduReader.h"
#include "fsfw/cfdp/pdu/PduConfig.h"
#include "fsfw/cfdp/tlv/MessageToUserTlv.h"
#include "fsfw/container/DynamicFIFO.h"
#include "fsfw/storagemanager/StorageManagerIF.h"
#include "fsfw/storagemanager/storeAddress.h"
#include "fsfw/tmtcservices/AcceptsTelemetryIF.h"
namespace cfdp {
@ -30,7 +28,6 @@ using LostSegmentsListBase = etl::iset<etl::pair<uint64_t, uint64_t>>;
struct DestHandlerParams {
DestHandlerParams(LocalEntityCfg cfg, UserBase& user, RemoteConfigTableIF& remoteCfgTable,
// PacketInfoListBase& packetList,
// TODO: This container can potentially take tons of space. For a better
// memory efficient implementation, an additional abstraction could be
// be used so users can use uint32_t as the pair type
@ -41,14 +38,12 @@ struct DestHandlerParams {
: cfg(std::move(cfg)),
user(user),
remoteCfgTable(remoteCfgTable),
// packetListRef(packetList),
lostSegmentsContainer(lostSegmentsContainer) {}
LocalEntityCfg cfg;
UserBase& user;
RemoteConfigTableIF& remoteCfgTable;
// PacketInfoListBase& packetListRef;
LostSegmentsListBase& lostSegmentsContainer;
uint8_t maxTlvsInOnePdu = 20;
size_t maxFilenameLen = 255;

View File

@ -14,7 +14,7 @@ cfdp::ReservedMessageParser::ReservedMessageParser(StorageManagerIF& ipcStore,
: msgQueue(msgQueue), ipcStore(ipcStore), userDestination(userDestination) {}
ReturnValue_t cfdp::ReservedMessageParser::parse(const MessageToUserTlv* msgsToUserArray,
size_t numMsgToUser) {
size_t numMsgToUser) const {
ReturnValue_t result = returnvalue::OK;
cfdp::StringLv sourceFileName;
cfdp::StringLv destFileName;
@ -23,31 +23,28 @@ ReturnValue_t cfdp::ReservedMessageParser::parse(const MessageToUserTlv* msgsToU
size_t deserSize = 0;
bool needToSendPutRequest = false;
for (size_t idx = 0; idx < numMsgToUser; idx++) {
if (&msgsToUserArray[idx] == nullptr) {
uint8_t messageType = 0;
if (not msgsToUserArray[idx].isReservedCfdpMessage(messageType, &currentPtr, deserSize)) {
continue;
}
uint8_t messageType = 0;
if (msgsToUserArray[idx].isReservedCfdpMessage(messageType, &currentPtr, deserSize)) {
if (messageType == static_cast<uint8_t>(ProxyOpMessageType::PUT_REQUEST)) {
EntityId entityIdLv;
result = entityIdLv.deSerializeFromLv(&currentPtr, &deserSize);
if (result != returnvalue::OK) {
return result;
}
putRequest.setDestId(entityIdLv);
result =
sourceFileName.deSerialize(&currentPtr, &deserSize, SerializeIF::Endianness::NETWORK);
if (result != OK) {
return result;
}
result =
destFileName.deSerialize(&currentPtr, &deserSize, SerializeIF::Endianness::NETWORK);
if (result != OK) {
return result;
}
putRequest.setSourceAndDestName(sourceFileName, destFileName);
needToSendPutRequest = true;
if (messageType == static_cast<uint8_t>(ProxyOpMessageType::PUT_REQUEST)) {
EntityId entityIdLv;
result = entityIdLv.deSerializeFromLv(&currentPtr, &deserSize);
if (result != returnvalue::OK) {
return result;
}
putRequest.setDestId(entityIdLv);
result =
sourceFileName.deSerialize(&currentPtr, &deserSize, SerializeIF::Endianness::NETWORK);
if (result != OK) {
return result;
}
result = destFileName.deSerialize(&currentPtr, &deserSize, SerializeIF::Endianness::NETWORK);
if (result != OK) {
return result;
}
putRequest.setSourceAndDestName(sourceFileName, destFileName);
needToSendPutRequest = true;
}
}
if (needToSendPutRequest) {

View File

@ -16,7 +16,7 @@ class ReservedMessageParser {
ReservedMessageParser(StorageManagerIF& ipcStore, MessageQueueIF& msgQueue,
MessageQueueId_t userDestination);
ReturnValue_t parse(const MessageToUserTlv* msgsToUserArray, size_t numMsgsToUser);
ReturnValue_t parse(const MessageToUserTlv* msgsToUserArray, size_t numMsgsToUser) const;
private:
MessageQueueIF& msgQueue;

View File

@ -1,5 +1,4 @@
#ifndef FSFW_CFDP_HANDLER_DEFS_H
#define FSFW_CFDP_HANDLER_DEFS_H
#pragma once
#include <etl/list.h>
@ -8,43 +7,18 @@
#include "fsfw/tmtcservices/AcceptsTelemetryIF.h"
namespace cfdp {
enum class CfdpState { IDLE, BUSY_CLASS_1_NACKED, BUSY_CLASS_2_ACKED, SUSPENDED };
static constexpr uint8_t SSID = SUBSYSTEM_ID::CFDP;
static constexpr uint8_t CID = CLASS_ID::CFDP_HANDLER;
/*
struct PacketInfo {
PacketInfo(PduType type, store_address_t storeId,
std::optional<FileDirective> directive = std::nullopt)
: pduType(type), directiveType(directive), storeId(storeId) {}
PduType pduType = PduType::FILE_DATA;
std::optional<FileDirective> directiveType = FileDirective::INVALID_DIRECTIVE;
store_address_t storeId = store_address_t::invalid();
PacketInfo() = default;
};
*/
struct FsfwParams {
FsfwParams(EventReportingProxyIF* eventReporter) : eventReporter(eventReporter) {}
// AcceptsTelemetryIF& packetDest;
// uint8_t virtualChannelId;
// MessageQueueIF* msgQueue;
EventReportingProxyIF* eventReporter = nullptr;
// StorageManagerIF* tcStore = nullptr;
// StorageManagerIF* tmStore = nullptr;
};
// template <size_t SIZE>
// using PacketInfoList = etl::list<PacketInfo, SIZE>;
// using PacketInfoListBase = etl::ilist<PacketInfo>;
// enum class CallStatus { DONE, CALL_AFTER_DELAY, CALL_AGAIN };
namespace events {
static constexpr Event PDU_SEND_ERROR = event::makeEvent(SSID, 1, severity::LOW);
static constexpr Event SERIALIZATION_ERROR = event::makeEvent(SSID, 2, severity::LOW);
static constexpr Event FILESTORE_ERROR = event::makeEvent(SSID, 3, severity::LOW);
@ -52,7 +26,6 @@ static constexpr Event FILESTORE_ERROR = event::makeEvent(SSID, 3, severity::LOW
static constexpr Event FILENAME_TOO_LARGE_ERROR = event::makeEvent(SSID, 4, severity::LOW);
//! [EXPORT] : [COMMENT] CFDP request handling failed. P2: Returncode.
static constexpr Event HANDLING_CFDP_REQUEST_FAILED = event::makeEvent(SSID, 5, severity::LOW);
} // namespace events
static constexpr ReturnValue_t SOURCE_TRANSACTION_PENDING = returnvalue::makeCode(CID, 0);
@ -65,6 +38,4 @@ static constexpr ReturnValue_t TARGET_MSG_QUEUE_FULL = returnvalue::makeCode(CID
static constexpr ReturnValue_t TM_STORE_FULL = returnvalue::makeCode(CID, 7);
static constexpr ReturnValue_t DEST_NON_METADATA_PDU_AS_FIRST_PDU = returnvalue::makeCode(CID, 8);
static constexpr ReturnValue_t PDU_BUFFER_TOO_SMALL = returnvalue::makeCode(CID, 9);
} // namespace cfdp
#endif // FSFW_CFDP_HANDLER_DEFS_H

View File

@ -192,8 +192,7 @@ TEST_CASE("CFDP Dest Handler", "[cfdp]") {
std::vector<store_address_t> idsToCheck;
{
Fss offset(0);
FileDataInfo fdPduInfo(offset, (largerFileData.data()),
largerFileData.size() / 2);
FileDataInfo fdPduInfo(offset, (largerFileData.data()), largerFileData.size() / 2);
FileDataCreator fdPduCreator(conf, fdPduInfo);
REQUIRE(fdPduCreator.serialize(pduBuf.data(), serLen, fdPduCreator.getSerializedSize()) ==
OK);
@ -204,8 +203,7 @@ TEST_CASE("CFDP Dest Handler", "[cfdp]") {
{
Fss offset(512);
FileDataInfo fdPduInfo(offset, largerFileData.data() + 512,
largerFileData.size() / 2);
FileDataInfo fdPduInfo(offset, largerFileData.data() + 512, largerFileData.size() / 2);
FileDataCreator fdPduCreator(conf, fdPduInfo);
REQUIRE(fdPduCreator.serialize(pduBuf.data(), serLen, fdPduCreator.getSerializedSize()) ==
OK);