start implementing reserved message creator
This commit is contained in:
parent
844c90a625
commit
8581f9a6f3
@ -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 uint8_t* msgsToUserPtr,
|
ReturnValue_t cfdp::ReservedMessageParser::parse(const uint8_t* msgsToUserPtr,
|
||||||
size_t sizeOfMessages) {
|
size_t sizeOfMessages) {
|
||||||
ReturnValue_t result;
|
ReturnValue_t result;
|
||||||
size_t currentIdx = 0;
|
size_t currentIdx = 0;
|
||||||
const uint8_t* currentPtr = msgsToUserPtr;
|
const uint8_t* currentPtr = msgsToUserPtr;
|
||||||
|
@ -8,4 +8,5 @@ target_sources(
|
|||||||
StringLv.cpp
|
StringLv.cpp
|
||||||
FlowLabelTlv.cpp
|
FlowLabelTlv.cpp
|
||||||
MessageToUserTlv.cpp
|
MessageToUserTlv.cpp
|
||||||
FaultHandlerOverrideTlv.cpp)
|
FaultHandlerOverrideTlv.cpp
|
||||||
|
ReservedMessageCreator.cpp)
|
||||||
|
23
src/fsfw/cfdp/tlv/ReservedMessageCreator.cpp
Normal file
23
src/fsfw/cfdp/tlv/ReservedMessageCreator.cpp
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
#include "ReservedMessageCreator.h"
|
||||||
|
|
||||||
|
cfdp::ReservedMessageCreator::ReservedMessageCreator(uint8_t messageType, uint8_t *msgData,
|
||||||
|
size_t msgLen)
|
||||||
|
: messageType(messageType), msgData(msgData), msgSize(msgLen) {}
|
||||||
|
ReturnValue_t cfdp::ReservedMessageCreator::serialize(
|
||||||
|
uint8_t **buffer, size_t *size, size_t maxSize,
|
||||||
|
SerializeIF::Endianness streamEndianness) const {
|
||||||
|
if (*size + getSerializedSize() > maxSize) {
|
||||||
|
return SerializeIF::BUFFER_TOO_SHORT;
|
||||||
|
}
|
||||||
|
return returnvalue::OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t cfdp::ReservedMessageCreator::getSerializedSize() const {
|
||||||
|
// 3 bytes type and length and value, 4 bytes CFDP, 1 byte reserved message type, message data.
|
||||||
|
return 3 + 5 + msgSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
ReturnValue_t cfdp::ReservedMessageCreator::deSerialize(const uint8_t **buffer, size_t *size,
|
||||||
|
SerializeIF::Endianness streamEndianness) {
|
||||||
|
return returnvalue::FAILED;
|
||||||
|
}
|
22
src/fsfw/cfdp/tlv/ReservedMessageCreator.h
Normal file
22
src/fsfw/cfdp/tlv/ReservedMessageCreator.h
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Tlv.h"
|
||||||
|
|
||||||
|
namespace cfdp {
|
||||||
|
|
||||||
|
class ReservedMessageCreator : public SerializeIF {
|
||||||
|
public:
|
||||||
|
ReservedMessageCreator(uint8_t messageType, uint8_t *msgData, size_t msgLen);
|
||||||
|
[[nodiscard]] ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize,
|
||||||
|
Endianness streamEndianness) const override;
|
||||||
|
[[nodiscard]] size_t getSerializedSize() const override;
|
||||||
|
ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size,
|
||||||
|
Endianness streamEndianness) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
uint8_t messageType;
|
||||||
|
uint8_t *msgData;
|
||||||
|
size_t msgSize;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace cfdp
|
@ -1,3 +1,4 @@
|
|||||||
target_sources(
|
target_sources(
|
||||||
${FSFW_TEST_TGT} PRIVATE testDistributor.cpp testDestHandler.cpp
|
${FSFW_TEST_TGT}
|
||||||
testSourceHandler.cpp testFaultHandler.cpp)
|
PRIVATE testDistributor.cpp testDestHandler.cpp testReservedMsgParser.cpp
|
||||||
|
testSourceHandler.cpp testFaultHandler.cpp)
|
||||||
|
18
unittests/cfdp/handler/testReservedMsgParser.cpp
Normal file
18
unittests/cfdp/handler/testReservedMsgParser.cpp
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
#include <catch2/catch_test_macros.hpp>
|
||||||
|
|
||||||
|
#include "fsfw/cfdp/handler/ReservedMessageParser.h"
|
||||||
|
#include "mocks/MessageQueueMock.h"
|
||||||
|
#include "mocks/StorageManagerMock.h"
|
||||||
|
|
||||||
|
TEST_CASE("Reserved Message Parser", "[cfdp]") {
|
||||||
|
using namespace cfdp;
|
||||||
|
using namespace returnvalue;
|
||||||
|
|
||||||
|
MessageQueueId_t destQueueId = 2;
|
||||||
|
MessageQueueMock msgQueue(destQueueId);
|
||||||
|
LocalPool::LocalPoolConfig storeCfg = {{10, 32}, {10, 64}, {10, 128}, {10, 1024}};
|
||||||
|
StorageManagerMock ipcStore(0, storeCfg);
|
||||||
|
ReservedMessageParser parser(ipcStore, msgQueue, destQueueId);
|
||||||
|
|
||||||
|
// parser.parse()
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user