added sp reader unittests
This commit is contained in:
@ -22,6 +22,12 @@ class SpacePacketIF {
|
||||
|
||||
virtual ~SpacePacketIF() = default;
|
||||
|
||||
/**
|
||||
* CCSDS header always has 6 bytes
|
||||
* @return
|
||||
*/
|
||||
static constexpr size_t getHeaderLen() { return ccsds::HEADER_LEN; }
|
||||
|
||||
/**
|
||||
* Returns the complete first two bytes of the packet, which together form
|
||||
* the CCSDS packet ID
|
||||
|
@ -8,6 +8,9 @@ SpacePacketReader::SpacePacketReader(const uint8_t* setAddress, size_t maxSize_)
|
||||
}
|
||||
|
||||
ReturnValue_t SpacePacketReader::checkSize() const {
|
||||
if (isNull()) {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
if (getFullPacketLen() > bufSize) {
|
||||
return SerializeIF::STREAM_TOO_SHORT;
|
||||
}
|
||||
@ -33,7 +36,9 @@ uint16_t SpacePacketReader::getPacketDataLen() const { return ccsds::getPacketLe
|
||||
ReturnValue_t SpacePacketReader::setInternalFields(const uint8_t* data, size_t maxSize_) {
|
||||
bufSize = maxSize_;
|
||||
spHeader = reinterpret_cast<const ccsds::PrimaryHeader*>(data);
|
||||
packetDataField = data + ccsds::HEADER_LEN;
|
||||
if (maxSize_ > 6) {
|
||||
packetDataField = data + ccsds::HEADER_LEN;
|
||||
}
|
||||
return checkSize();
|
||||
}
|
||||
|
||||
|
@ -62,11 +62,6 @@ class SpacePacketReader : public SpacePacketIF,
|
||||
*/
|
||||
[[nodiscard]] size_t getBufSize() const;
|
||||
|
||||
/**
|
||||
* CCSDS header always has 6 bytes
|
||||
* @return
|
||||
*/
|
||||
static constexpr size_t getHeaderLen() { return ccsds::HEADER_LEN; }
|
||||
[[nodiscard]] uint16_t getPacketIdRaw() const override;
|
||||
[[nodiscard]] uint16_t getPacketSeqCtrlRaw() const override;
|
||||
[[nodiscard]] uint16_t getPacketDataLen() const override;
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "header.h"
|
||||
|
||||
uint16_t ccsds::getPacketId(const PrimaryHeader &header) {
|
||||
return ((header.packetIdHAndVersion & 0x1F00) << 8) + header.packetIdL;
|
||||
return ((header.packetIdHAndVersion & 0x1F) << 8) + header.packetIdL;
|
||||
}
|
||||
|
||||
uint16_t ccsds::getPacketSeqCtrl(const PrimaryHeader &header) {
|
||||
|
Reference in New Issue
Block a user