Bump FSFW #31

Merged
muellerr merged 139 commits from bump-fsfw into develop 2023-12-18 13:16:28 +01:00
6 changed files with 21 additions and 9 deletions
Showing only changes of commit daf75547a4 - Show all commits

View File

@ -153,3 +153,5 @@ bool cfdp::VarLenField::operator==(const cfdp::VarLenField &other) const {
bool cfdp::VarLenField::operator!=(const cfdp::VarLenField &other) const { bool cfdp::VarLenField::operator!=(const cfdp::VarLenField &other) const {
return not(*this == other); return not(*this == other);
} }
void cfdp::VarLenField::setWidth(cfdp::WidthInBytes width_) { this->width = width_; }

View File

@ -32,6 +32,7 @@ class VarLenField : public SerializeIF {
bool operator<(const VarLenField &other) const; bool operator<(const VarLenField &other) const;
ReturnValue_t setValueAndWidth(cfdp::WidthInBytes width, uint64_t value); ReturnValue_t setValueAndWidth(cfdp::WidthInBytes width, uint64_t value);
void setWidth(cfdp::WidthInBytes width);
ReturnValue_t setValue(uint64_t value); ReturnValue_t setValue(uint64_t value);
ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize, ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize,

View File

@ -19,12 +19,15 @@ cfdp::SourceHandler::SourceHandler(SourceHandlerParams params, FsfwParams fsfwPa
: sourceParams(std::move(params)), fsfwParams(fsfwParams) { : sourceParams(std::move(params)), fsfwParams(fsfwParams) {
// The entity ID portion of the transaction ID will always remain fixed. // The entity ID portion of the transaction ID will always remain fixed.
transactionParams.id.entityId = sourceParams.cfg.localId; transactionParams.id.entityId = sourceParams.cfg.localId;
transactionParams.pduConf.sourceId = sourceParams.cfg.localId;
if (sourceParams.seqCountProvider.bitWidth() == 8) { if (sourceParams.seqCountProvider.bitWidth() == 8) {
transactionParams.seqCountWidth = cfdp::WidthInBytes::ONE_BYTE; transactionParams.pduConf.seqNum.setWidth(cfdp::WidthInBytes::ONE_BYTE);
} else if (sourceParams.seqCountProvider.bitWidth() == 16) { } else if (sourceParams.seqCountProvider.bitWidth() == 16) {
transactionParams.seqCountWidth = cfdp::WidthInBytes::TWO_BYTES; transactionParams.pduConf.seqNum.setWidth(cfdp::WidthInBytes::TWO_BYTES);
} else if (sourceParams.seqCountProvider.bitWidth() == 32) { } else if (sourceParams.seqCountProvider.bitWidth() == 32) {
transactionParams.seqCountWidth = cfdp::WidthInBytes::FOUR_BYTES; transactionParams.pduConf.seqNum.setWidth(cfdp::WidthInBytes::FOUR_BYTES);
} else if (sourceParams.seqCountProvider.bitWidth() == 64) {
transactionParams.pduConf.seqNum.setWidth(cfdp::WidthInBytes::EIGHT_BYTES);
} else { } else {
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "cfdp::SourceHandler: Seq count provider bit width " sif::error << "cfdp::SourceHandler: Seq count provider bit width "
@ -34,7 +37,7 @@ cfdp::SourceHandler::SourceHandler(SourceHandlerParams params, FsfwParams fsfwPa
sourceParams.seqCountProvider.bitWidth()); sourceParams.seqCountProvider.bitWidth());
#endif #endif
// Yeah, what am I supposed to do here? Can't throw an exception in the FSFW.. // Yeah, what am I supposed to do here? Can't throw an exception in the FSFW..
transactionParams.seqCountWidth = cfdp::WidthInBytes::ONE_BYTE; transactionParams.pduConf.seqNum.setWidth(cfdp::WidthInBytes::ONE_BYTE);
} }
} }
@ -172,10 +175,13 @@ ReturnValue_t cfdp::SourceHandler::transactionStart(PutRequest& putRequest, Remo
if (not putRequest.getClosureRequested(transactionParams.closureRequested)) { if (not putRequest.getClosureRequested(transactionParams.closureRequested)) {
transactionParams.closureRequested = cfg.closureRequested; transactionParams.closureRequested = cfg.closureRequested;
} }
transactionParams.pduConf.destId = putRequest.getDestId(); const EntityId& destId = putRequest.getDestId();
transactionParams.pduConf.destId = destId;
// Adapt source ID width to necessary width. The width of the source and destination ID must be
// the same.
transactionParams.pduConf.sourceId.setWidth(destId.getWidth());
// Only used for PDU forwarding, file is sent to file receiver regularly here. // Only used for PDU forwarding, file is sent to file receiver regularly here.
transactionParams.pduConf.direction = Direction::TOWARDS_RECEIVER; transactionParams.pduConf.direction = Direction::TOWARDS_RECEIVER;
transactionParams.pduConf.sourceId = sourceParams.cfg.localId;
transactionParams.id.seqNum.setValue(sourceParams.seqCountProvider.getAndIncrement()); transactionParams.id.seqNum.setValue(sourceParams.seqCountProvider.getAndIncrement());
if (transactionParams.pduConf.mode == TransmissionMode::ACKNOWLEDGED) { if (transactionParams.pduConf.mode == TransmissionMode::ACKNOWLEDGED) {

View File

@ -76,7 +76,7 @@ class SourceHandler {
RemoteEntityCfg remoteCfg; RemoteEntityCfg remoteCfg;
PduConfig pduConf; PduConfig pduConf;
cfdp::TransactionId id{}; cfdp::TransactionId id{};
cfdp::WidthInBytes seqCountWidth{}; // cfdp::WidthInBytes seqCountWidth{};
void reset() { void reset() {
sourceNameSize = 0; sourceNameSize = 0;

View File

@ -61,7 +61,7 @@ TEST_CASE("CFDP Source Handler", "[cfdp]") {
FilesystemParams srcFileName("/tmp/cfdp-test.txt"); FilesystemParams srcFileName("/tmp/cfdp-test.txt");
fsMock.createFile(srcFileName); fsMock.createFile(srcFileName);
cfdp::StringLv srcNameLv(srcFileName.path, std::strlen(srcFileName.path)); cfdp::StringLv srcNameLv(srcFileName.path, std::strlen(srcFileName.path));
FilesystemParams destFileName("/tmp/cfdp-test.txt"); FilesystemParams destFileName("/tmp/cfdp-test2.txt");
cfdp::StringLv destNameLv(destFileName.path, std::strlen(destFileName.path)); cfdp::StringLv destNameLv(destFileName.path, std::strlen(destFileName.path));
PutRequest putRequest(id, srcNameLv, destNameLv); PutRequest putRequest(id, srcNameLv, destNameLv);
CHECK(sourceHandler.transactionStart(putRequest, cfg) == OK); CHECK(sourceHandler.transactionStart(putRequest, cfg) == OK);
@ -73,6 +73,7 @@ TEST_CASE("CFDP Source Handler", "[cfdp]") {
auto accessor = tmStore.getData(tmtcMessage.getStorageId()); auto accessor = tmStore.getData(tmtcMessage.getStorageId());
REQUIRE(accessor.first == OK); REQUIRE(accessor.first == OK);
const uint8_t* pduPtr = accessor.second.data(); const uint8_t* pduPtr = accessor.second.data();
CHECK(accessor.second.size() == 55);
MetadataGenericInfo metadataInfo; MetadataGenericInfo metadataInfo;
MetadataPduReader metadataReader(pduPtr, accessor.second.size(), metadataInfo, nullptr, 0); MetadataPduReader metadataReader(pduPtr, accessor.second.size(), metadataInfo, nullptr, 0);
size_t srcFileSize = 0; size_t srcFileSize = 0;

View File

@ -56,10 +56,12 @@ TEST_CASE("Metadata PDU", "[cfdp][pdu]") {
REQUIRE(mdBuffer[24] == 'x'); REQUIRE(mdBuffer[24] == 'x');
REQUIRE(mdBuffer[25] == 't'); REQUIRE(mdBuffer[25] == 't');
}; };
SECTION("Serialize with empty dest name") { SECTION("Serialize with empty dest name") {
MetadataPduCreator serializer(pduConf, info, sourceFileName, destFileName, nullptr, 0); MetadataPduCreator serializer(pduConf, info, sourceFileName, destFileName, nullptr, 0);
result = serializer.serialize(&buffer, &sz, mdBuffer.size(), SerializeIF::Endianness::NETWORK); result = serializer.serialize(&buffer, &sz, mdBuffer.size(), SerializeIF::Endianness::NETWORK);
REQUIRE(result == returnvalue::OK); REQUIRE(result == returnvalue::OK);
CHECK(sz == serializer.getSerializedSize());
// 10 byte heater + 1 byte PDU directive field + 1 byte PDU content + FSS field (4) + source // 10 byte heater + 1 byte PDU directive field + 1 byte PDU content + FSS field (4) + source
// name field (10) + dest name field (1). // name field (10) + dest name field (1).
REQUIRE(serializer.getWholePduSize() == 27); REQUIRE(serializer.getWholePduSize() == 27);
@ -81,6 +83,7 @@ TEST_CASE("Metadata PDU", "[cfdp][pdu]") {
// 10 byte heater + 1 byte PDU directive field + 1 byte PDU content + FSS field (4) + source // 10 byte heater + 1 byte PDU directive field + 1 byte PDU content + FSS field (4) + source
// name field (10) + dest name field (11). // name field (10) + dest name field (11).
REQUIRE(serializer.getWholePduSize() == 37); REQUIRE(serializer.getWholePduSize() == 37);
CHECK(sz == serializer.getSerializedSize());
REQUIRE((mdBuffer[1] << 8 | mdBuffer[2]) == 27); REQUIRE((mdBuffer[1] << 8 | mdBuffer[2]) == 27);
REQUIRE(serializer.getSerializedSize() == serializer.getWholePduSize()); REQUIRE(serializer.getSerializedSize() == serializer.getWholePduSize());
metadataCheckPartOne(); metadataCheckPartOne();
@ -161,7 +164,6 @@ TEST_CASE("Metadata PDU", "[cfdp][pdu]") {
info.setClosureRequested(true); info.setClosureRequested(true);
serializer.updateDirectiveFieldLen(); serializer.updateDirectiveFieldLen();
// info.setSourceFileName(sourceFileName);
result = serializer.serialize(&buffer, &sz, mdBuffer.size(), SerializeIF::Endianness::NETWORK); result = serializer.serialize(&buffer, &sz, mdBuffer.size(), SerializeIF::Endianness::NETWORK);
REQUIRE(result == returnvalue::OK); REQUIRE(result == returnvalue::OK);