eive-obsw/linux/payload/ScexHelper.h

47 lines
1.4 KiB
C
Raw Normal View History

2023-03-26 16:42:00 +02:00
#ifndef LINUX_PAYLOAD_SCEXHELPER_H_
#define LINUX_PAYLOAD_SCEXHELPER_H_
2022-04-21 19:47:09 +02:00
#include <fsfw/serialize/SerializeIF.h>
2023-03-26 16:42:00 +02:00
#include <mission/payload/scexHelpers.h>
2022-04-21 19:47:09 +02:00
#include <cstddef>
#include <cstdint>
#include <fstream>
#include <iostream>
2022-08-29 16:05:05 +02:00
class ScexHelper : public SerializeIF {
2022-04-21 19:47:09 +02:00
public:
2022-08-29 16:05:05 +02:00
static const ReturnValue_t INVALID_CRC = returnvalue::makeCode(0, 2);
2022-04-29 15:46:16 +02:00
2022-04-21 19:47:09 +02:00
ScexHelper();
ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize,
Endianness streamEndianness) const override;
size_t getSerializedSize() const override;
ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size,
Endianness streamEndianness = Endianness::BIG) override;
friend std::ostream &operator<<(std::ostream &os, const ScexHelper &h);
friend std::ofstream &operator<<(std::ofstream &os, const ScexHelper &h);
2022-04-29 15:46:16 +02:00
scex::Cmds getCmd() const;
2022-04-21 19:47:09 +02:00
uint8_t getCmdByteRaw() const;
uint16_t getCrc() const;
size_t getExpectedPacketLen() const;
uint8_t getPacketCounter() const;
uint16_t getPayloadLen() const;
const uint8_t *getStart() const;
uint8_t getTotalPacketCounter() const;
private:
const uint8_t *start = nullptr;
uint16_t crc = 0;
uint8_t cmdByteRaw = 0;
2022-04-29 15:46:16 +02:00
scex::Cmds cmd = scex::Cmds::INVALID;
2022-04-21 19:47:09 +02:00
int packetCounter = 0;
int totalPacketCounter = 0;
uint16_t payloadLen = 0;
2022-05-19 11:56:59 +02:00
const uint8_t *payloadStart = 0;
2022-04-21 19:47:09 +02:00
size_t totalPacketLen = 0;
};
2023-03-26 16:42:00 +02:00
#endif /* LINUX_PAYLOAD_SCEXHELPER_H_ */