fsfw/unittests/serialize/SerialLinkedListAdapterPacket.h

51 lines
1.4 KiB
C
Raw Permalink Normal View History

2020-10-20 17:11:23 +02:00
#ifndef UNITTEST_HOSTED_TESTSERIALLINKEDPACKET_H_
#define UNITTEST_HOSTED_TESTSERIALLINKEDPACKET_H_
#include <fsfw/objectmanager/SystemObjectIF.h>
#include <fsfw/parameters/HasParametersIF.h>
#include <fsfw/serialize/SerialBufferAdapter.h>
#include <fsfw/serialize/SerialLinkedListAdapter.h>
2022-02-02 10:29:30 +01:00
2020-10-20 17:11:23 +02:00
#include <cstdint>
2022-02-02 10:29:30 +01:00
class TestPacket : public SerialLinkedListAdapter<SerializeIF> {
public:
/**
* For Deserialization
*/
TestPacket(const uint8_t* somePacket, size_t size, uint8_t* storePointer, size_t storeSize)
: buffer(storePointer, storeSize) {
setLinks();
}
/**
* For Serialization
*/
TestPacket(uint32_t header, uint32_t tail, const uint8_t* parameters, size_t paramSize)
: header(header), buffer(parameters, paramSize), tail(tail) {
setLinks();
}
2022-07-23 10:34:19 +02:00
[[nodiscard]] uint32_t getHeader() const { return header.entry; }
2022-02-02 10:29:30 +01:00
2022-07-23 10:34:19 +02:00
[[nodiscard]] const uint8_t* getBuffer() const { return buffer.entry.getConstBuffer(); }
2022-02-02 10:29:30 +01:00
size_t getBufferLength() { return buffer.getSerializedSize(); }
2022-07-23 10:34:19 +02:00
[[nodiscard]] uint16_t getTail() const { return tail.entry; }
2022-02-02 10:29:30 +01:00
private:
void setLinks() {
setStart(&header);
header.setNext(&buffer);
buffer.setNext(&tail);
tail.setEnd();
}
SerializeElement<uint32_t> header = 0;
SerializeElement<SerialBufferAdapter<uint8_t>> buffer;
SerializeElement<uint32_t> tail = 0;
2020-10-20 17:11:23 +02:00
};
2022-07-23 10:34:19 +02:00
#endif /* UNITTEST_HOSTED_TESTSERIALLINKEDPACKET_H_ */