CFDP SOURCE handler #157

Merged
muellerr merged 107 commits from cfdp-source-handler into develop 2023-10-19 10:59:55 +02:00
6 changed files with 17 additions and 10 deletions
Showing only changes of commit 314cba363f - Show all commits

View File

@ -28,7 +28,7 @@ ReturnValue_t cfdp::ReservedMessageParser::parse(const uint8_t* msgsToUserPtr,
return result;
}
uint8_t messageType = 0;
if (tlv.isReservedCfdpMessage(messageType)) {
if (tlv.isReservedCfdpMessage(messageType, &currentPtr, deserSize)) {
if (messageType == static_cast<uint8_t>(ProxyOpMessageType::PUT_REQUEST)) {
cfdp::Lv entityIdLv;
result = entityIdLv.deSerialize(&currentPtr, &deserSize, SerializeIF::Endianness::NETWORK);

View File

@ -49,10 +49,8 @@ ReturnValue_t cfdp::Lv::serialize(uint8_t** buffer, size_t* size, size_t maxSize
}
size_t cfdp::Lv::getSerializedSize() const {
if (zeroLen) {
if (zeroLen or value.getConstBuffer() == nullptr) {
return 1;
} else if (value.getConstBuffer() == nullptr) {
return 0;
}
return value.getSerializedSize();
}
@ -85,7 +83,7 @@ ReturnValue_t cfdp::Lv::deSerialize(const uint8_t** buffer, size_t* size,
const uint8_t* cfdp::Lv::getValue(size_t* size) const {
if (size != nullptr) {
// Length without length field
*size = value.getSerializedSize() - 1;
*size = getSerializedSize() - 1;
}
return value.getConstBuffer();
}

View File

@ -11,12 +11,17 @@ MessageToUserTlv::MessageToUserTlv(const std::vector<uint8_t>& data)
MessageToUserTlv::MessageToUserTlv(const uint8_t* value, size_t size)
: Tlv(cfdp::TlvType::MSG_TO_USER, value, size) {}
bool MessageToUserTlv::isReservedCfdpMessage(uint8_t& messageType) const {
bool MessageToUserTlv::isReservedCfdpMessage(uint8_t& messageType, const uint8_t** msgDataStart,
size_t& msgLen) const {
if (cfdp::Tlv::getLengthField() < 5) {
return false;
}
if (std::strcmp(reinterpret_cast<const char*>(getValue()), "cfdp") == 0) {
messageType = getValue()[4];
if (msgDataStart != nullptr) {
*msgDataStart = getValue() + 5;
}
msgLen = cfdp::Tlv::getSerializedSize() - 5;
return true;
}
return false;

View File

@ -12,7 +12,8 @@ class MessageToUserTlv : public cfdp::Tlv {
MessageToUserTlv(const uint8_t* value, size_t size);
explicit MessageToUserTlv(const std::vector<uint8_t>& data);
bool isReservedCfdpMessage(uint8_t& messageType) const;
bool isReservedCfdpMessage(uint8_t& messageType, const uint8_t** msgDataStart,
size_t& msgLen) const;
private:
};

View File

@ -116,8 +116,8 @@ void ObjectManager::initialize() {
<< std::dec << std::setfill(' ') << std::endl;
#else
sif::printError(
"ObjectManager::initialize: Object 0x%08x failed to initialize with code 0x%04x\n", var,
it.first);
"ObjectManager::initialize: Object 0x%08x failed to initialize with code 0x%04x\n",
it.first, result);
#endif
#endif
errorCount++;

View File

@ -5,6 +5,7 @@
#include "fsfw/cfdp/tlv/Lv.h"
#include "fsfw/cfdp/tlv/ReservedMessageCreator.h"
#include "fsfw/cfdp/tlv/StringLv.h"
#include "fsfw/globalfunctions/arrayprinter.h"
#include "mocks/MessageQueueMock.h"
#include "mocks/StorageManagerMock.h"
@ -20,6 +21,7 @@ TEST_CASE("Reserved Message Parser", "[cfdp]") {
StorageManagerMock ipcStore(0, storeCfg);
std::array<uint8_t, 128> buffer{};
uint8_t msgBuf[32]{};
EntityId entityId(cfdp::WidthInBytes::ONE_BYTE, 5);
uint8_t* msgBufPtr = msgBuf;
size_t serLen = 0;
@ -35,7 +37,8 @@ TEST_CASE("Reserved Message Parser", "[cfdp]") {
serLen = 0;
ReturnValue_t result = creator.serializeBe(buffer.data(), serLen, buffer.size());
CHECK(result == returnvalue::OK);
arrayprinter::print(buffer.data(), serLen);
ReservedMessageParser parser(ipcStore, msgQueue, destQueueId);
CHECK(parser.parse(buffer.data(), buffer.max_size()) == OK);
CHECK(parser.parse(buffer.data(), serLen) == OK);
}