some more cleaning up
This commit is contained in:
parent
0fc5744719
commit
0af5d37b35
@ -17,9 +17,7 @@
|
|||||||
#include "fsfw/cfdp/pdu/MetadataPduReader.h"
|
#include "fsfw/cfdp/pdu/MetadataPduReader.h"
|
||||||
#include "fsfw/cfdp/pdu/PduConfig.h"
|
#include "fsfw/cfdp/pdu/PduConfig.h"
|
||||||
#include "fsfw/cfdp/tlv/MessageToUserTlv.h"
|
#include "fsfw/cfdp/tlv/MessageToUserTlv.h"
|
||||||
#include "fsfw/container/DynamicFIFO.h"
|
|
||||||
#include "fsfw/storagemanager/StorageManagerIF.h"
|
#include "fsfw/storagemanager/StorageManagerIF.h"
|
||||||
#include "fsfw/storagemanager/storeAddress.h"
|
|
||||||
#include "fsfw/tmtcservices/AcceptsTelemetryIF.h"
|
#include "fsfw/tmtcservices/AcceptsTelemetryIF.h"
|
||||||
|
|
||||||
namespace cfdp {
|
namespace cfdp {
|
||||||
@ -30,7 +28,6 @@ using LostSegmentsListBase = etl::iset<etl::pair<uint64_t, uint64_t>>;
|
|||||||
|
|
||||||
struct DestHandlerParams {
|
struct DestHandlerParams {
|
||||||
DestHandlerParams(LocalEntityCfg cfg, UserBase& user, RemoteConfigTableIF& remoteCfgTable,
|
DestHandlerParams(LocalEntityCfg cfg, UserBase& user, RemoteConfigTableIF& remoteCfgTable,
|
||||||
// PacketInfoListBase& packetList,
|
|
||||||
// TODO: This container can potentially take tons of space. For a better
|
// TODO: This container can potentially take tons of space. For a better
|
||||||
// memory efficient implementation, an additional abstraction could be
|
// memory efficient implementation, an additional abstraction could be
|
||||||
// be used so users can use uint32_t as the pair type
|
// be used so users can use uint32_t as the pair type
|
||||||
@ -41,14 +38,12 @@ struct DestHandlerParams {
|
|||||||
: cfg(std::move(cfg)),
|
: cfg(std::move(cfg)),
|
||||||
user(user),
|
user(user),
|
||||||
remoteCfgTable(remoteCfgTable),
|
remoteCfgTable(remoteCfgTable),
|
||||||
// packetListRef(packetList),
|
|
||||||
lostSegmentsContainer(lostSegmentsContainer) {}
|
lostSegmentsContainer(lostSegmentsContainer) {}
|
||||||
|
|
||||||
LocalEntityCfg cfg;
|
LocalEntityCfg cfg;
|
||||||
UserBase& user;
|
UserBase& user;
|
||||||
RemoteConfigTableIF& remoteCfgTable;
|
RemoteConfigTableIF& remoteCfgTable;
|
||||||
|
|
||||||
// PacketInfoListBase& packetListRef;
|
|
||||||
LostSegmentsListBase& lostSegmentsContainer;
|
LostSegmentsListBase& lostSegmentsContainer;
|
||||||
uint8_t maxTlvsInOnePdu = 20;
|
uint8_t maxTlvsInOnePdu = 20;
|
||||||
size_t maxFilenameLen = 255;
|
size_t maxFilenameLen = 255;
|
||||||
|
@ -14,7 +14,7 @@ cfdp::ReservedMessageParser::ReservedMessageParser(StorageManagerIF& ipcStore,
|
|||||||
: msgQueue(msgQueue), ipcStore(ipcStore), userDestination(userDestination) {}
|
: msgQueue(msgQueue), ipcStore(ipcStore), userDestination(userDestination) {}
|
||||||
|
|
||||||
ReturnValue_t cfdp::ReservedMessageParser::parse(const MessageToUserTlv* msgsToUserArray,
|
ReturnValue_t cfdp::ReservedMessageParser::parse(const MessageToUserTlv* msgsToUserArray,
|
||||||
size_t numMsgToUser) {
|
size_t numMsgToUser) const {
|
||||||
ReturnValue_t result = returnvalue::OK;
|
ReturnValue_t result = returnvalue::OK;
|
||||||
cfdp::StringLv sourceFileName;
|
cfdp::StringLv sourceFileName;
|
||||||
cfdp::StringLv destFileName;
|
cfdp::StringLv destFileName;
|
||||||
@ -23,31 +23,28 @@ ReturnValue_t cfdp::ReservedMessageParser::parse(const MessageToUserTlv* msgsToU
|
|||||||
size_t deserSize = 0;
|
size_t deserSize = 0;
|
||||||
bool needToSendPutRequest = false;
|
bool needToSendPutRequest = false;
|
||||||
for (size_t idx = 0; idx < numMsgToUser; idx++) {
|
for (size_t idx = 0; idx < numMsgToUser; idx++) {
|
||||||
if (&msgsToUserArray[idx] == nullptr) {
|
uint8_t messageType = 0;
|
||||||
|
if (not msgsToUserArray[idx].isReservedCfdpMessage(messageType, ¤tPtr, deserSize)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
uint8_t messageType = 0;
|
if (messageType == static_cast<uint8_t>(ProxyOpMessageType::PUT_REQUEST)) {
|
||||||
if (msgsToUserArray[idx].isReservedCfdpMessage(messageType, ¤tPtr, deserSize)) {
|
EntityId entityIdLv;
|
||||||
if (messageType == static_cast<uint8_t>(ProxyOpMessageType::PUT_REQUEST)) {
|
result = entityIdLv.deSerializeFromLv(¤tPtr, &deserSize);
|
||||||
EntityId entityIdLv;
|
if (result != returnvalue::OK) {
|
||||||
result = entityIdLv.deSerializeFromLv(¤tPtr, &deserSize);
|
return result;
|
||||||
if (result != returnvalue::OK) {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
putRequest.setDestId(entityIdLv);
|
|
||||||
result =
|
|
||||||
sourceFileName.deSerialize(¤tPtr, &deserSize, SerializeIF::Endianness::NETWORK);
|
|
||||||
if (result != OK) {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
result =
|
|
||||||
destFileName.deSerialize(¤tPtr, &deserSize, SerializeIF::Endianness::NETWORK);
|
|
||||||
if (result != OK) {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
putRequest.setSourceAndDestName(sourceFileName, destFileName);
|
|
||||||
needToSendPutRequest = true;
|
|
||||||
}
|
}
|
||||||
|
putRequest.setDestId(entityIdLv);
|
||||||
|
result =
|
||||||
|
sourceFileName.deSerialize(¤tPtr, &deserSize, SerializeIF::Endianness::NETWORK);
|
||||||
|
if (result != OK) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
result = destFileName.deSerialize(¤tPtr, &deserSize, SerializeIF::Endianness::NETWORK);
|
||||||
|
if (result != OK) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
putRequest.setSourceAndDestName(sourceFileName, destFileName);
|
||||||
|
needToSendPutRequest = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (needToSendPutRequest) {
|
if (needToSendPutRequest) {
|
||||||
|
@ -16,7 +16,7 @@ class ReservedMessageParser {
|
|||||||
ReservedMessageParser(StorageManagerIF& ipcStore, MessageQueueIF& msgQueue,
|
ReservedMessageParser(StorageManagerIF& ipcStore, MessageQueueIF& msgQueue,
|
||||||
MessageQueueId_t userDestination);
|
MessageQueueId_t userDestination);
|
||||||
|
|
||||||
ReturnValue_t parse(const MessageToUserTlv* msgsToUserArray, size_t numMsgsToUser);
|
ReturnValue_t parse(const MessageToUserTlv* msgsToUserArray, size_t numMsgsToUser) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MessageQueueIF& msgQueue;
|
MessageQueueIF& msgQueue;
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#ifndef FSFW_CFDP_HANDLER_DEFS_H
|
#pragma once
|
||||||
#define FSFW_CFDP_HANDLER_DEFS_H
|
|
||||||
|
|
||||||
#include <etl/list.h>
|
#include <etl/list.h>
|
||||||
|
|
||||||
@ -8,43 +7,18 @@
|
|||||||
#include "fsfw/tmtcservices/AcceptsTelemetryIF.h"
|
#include "fsfw/tmtcservices/AcceptsTelemetryIF.h"
|
||||||
|
|
||||||
namespace cfdp {
|
namespace cfdp {
|
||||||
|
|
||||||
enum class CfdpState { IDLE, BUSY_CLASS_1_NACKED, BUSY_CLASS_2_ACKED, SUSPENDED };
|
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 SSID = SUBSYSTEM_ID::CFDP;
|
||||||
static constexpr uint8_t CID = CLASS_ID::CFDP_HANDLER;
|
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 {
|
struct FsfwParams {
|
||||||
FsfwParams(EventReportingProxyIF* eventReporter) : eventReporter(eventReporter) {}
|
FsfwParams(EventReportingProxyIF* eventReporter) : eventReporter(eventReporter) {}
|
||||||
// AcceptsTelemetryIF& packetDest;
|
|
||||||
// uint8_t virtualChannelId;
|
|
||||||
// MessageQueueIF* msgQueue;
|
|
||||||
EventReportingProxyIF* eventReporter = nullptr;
|
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 {
|
namespace events {
|
||||||
|
|
||||||
static constexpr Event PDU_SEND_ERROR = event::makeEvent(SSID, 1, severity::LOW);
|
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 SERIALIZATION_ERROR = event::makeEvent(SSID, 2, severity::LOW);
|
||||||
static constexpr Event FILESTORE_ERROR = event::makeEvent(SSID, 3, 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);
|
static constexpr Event FILENAME_TOO_LARGE_ERROR = event::makeEvent(SSID, 4, severity::LOW);
|
||||||
//! [EXPORT] : [COMMENT] CFDP request handling failed. P2: Returncode.
|
//! [EXPORT] : [COMMENT] CFDP request handling failed. P2: Returncode.
|
||||||
static constexpr Event HANDLING_CFDP_REQUEST_FAILED = event::makeEvent(SSID, 5, severity::LOW);
|
static constexpr Event HANDLING_CFDP_REQUEST_FAILED = event::makeEvent(SSID, 5, severity::LOW);
|
||||||
|
|
||||||
} // namespace events
|
} // namespace events
|
||||||
|
|
||||||
static constexpr ReturnValue_t SOURCE_TRANSACTION_PENDING = returnvalue::makeCode(CID, 0);
|
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 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 DEST_NON_METADATA_PDU_AS_FIRST_PDU = returnvalue::makeCode(CID, 8);
|
||||||
static constexpr ReturnValue_t PDU_BUFFER_TOO_SMALL = returnvalue::makeCode(CID, 9);
|
static constexpr ReturnValue_t PDU_BUFFER_TOO_SMALL = returnvalue::makeCode(CID, 9);
|
||||||
|
|
||||||
} // namespace cfdp
|
} // namespace cfdp
|
||||||
#endif // FSFW_CFDP_HANDLER_DEFS_H
|
|
||||||
|
@ -192,8 +192,7 @@ TEST_CASE("CFDP Dest Handler", "[cfdp]") {
|
|||||||
std::vector<store_address_t> idsToCheck;
|
std::vector<store_address_t> idsToCheck;
|
||||||
{
|
{
|
||||||
Fss offset(0);
|
Fss offset(0);
|
||||||
FileDataInfo fdPduInfo(offset, (largerFileData.data()),
|
FileDataInfo fdPduInfo(offset, (largerFileData.data()), largerFileData.size() / 2);
|
||||||
largerFileData.size() / 2);
|
|
||||||
FileDataCreator fdPduCreator(conf, fdPduInfo);
|
FileDataCreator fdPduCreator(conf, fdPduInfo);
|
||||||
REQUIRE(fdPduCreator.serialize(pduBuf.data(), serLen, fdPduCreator.getSerializedSize()) ==
|
REQUIRE(fdPduCreator.serialize(pduBuf.data(), serLen, fdPduCreator.getSerializedSize()) ==
|
||||||
OK);
|
OK);
|
||||||
@ -204,8 +203,7 @@ TEST_CASE("CFDP Dest Handler", "[cfdp]") {
|
|||||||
|
|
||||||
{
|
{
|
||||||
Fss offset(512);
|
Fss offset(512);
|
||||||
FileDataInfo fdPduInfo(offset, largerFileData.data() + 512,
|
FileDataInfo fdPduInfo(offset, largerFileData.data() + 512, largerFileData.size() / 2);
|
||||||
largerFileData.size() / 2);
|
|
||||||
FileDataCreator fdPduCreator(conf, fdPduInfo);
|
FileDataCreator fdPduCreator(conf, fdPduInfo);
|
||||||
REQUIRE(fdPduCreator.serialize(pduBuf.data(), serLen, fdPduCreator.getSerializedSize()) ==
|
REQUIRE(fdPduCreator.serialize(pduBuf.data(), serLen, fdPduCreator.getSerializedSize()) ==
|
||||||
OK);
|
OK);
|
||||||
|
Loading…
Reference in New Issue
Block a user