hmm this is problematic
fsfw/fsfw/pipeline/head There was a failure building this commit Details

This commit is contained in:
Robin Müller 2022-07-18 14:05:43 +02:00
parent 3c72a42ce1
commit 7e2fdc06cd
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814
3 changed files with 25 additions and 7 deletions

View File

@ -23,8 +23,7 @@ SpacePacketCreator::SpacePacketCreator(ccsds::PacketType packetType, bool secHea
return;
}
version = version_;
packetId =
(version_ << 13) | (static_cast<uint8_t>(packetType) << 12) | (secHeaderFlag << 11) | apid;
packetId = (static_cast<uint16_t>(packetType) << 12) | (static_cast<uint16_t>(secHeaderFlag) << 11) | apid;
packetSeqCtrl = static_cast<uint8_t>(seqFlags) << 14 | seqCount;
dataLen = dataLen_;
}
@ -53,3 +52,4 @@ ReturnValue_t SpacePacketCreator::deSerialize(const uint8_t **buffer, size_t *si
SerializeIF::Endianness streamEndianness) {
return HasReturnvaluesIF::RETURN_FAILED;
}
bool SpacePacketCreator::isValid() const { return valid; }

View File

@ -11,7 +11,7 @@ class SpacePacketCreator : public SerializeIF, public SpacePacketIF {
uint8_t version = 0);
SpacePacketCreator(uint16_t packetId, uint16_t packetSeqCtrl, uint16_t dataLen,
uint8_t version = 0);
bool valid;
[[nodiscard]] bool isValid() const;
[[nodiscard]] uint16_t getPacketId() const override;
[[nodiscard]] uint16_t getPacketSeqCtrl() const override;
[[nodiscard]] uint16_t getPacketDataLen() const override;
@ -22,6 +22,7 @@ class SpacePacketCreator : public SerializeIF, public SpacePacketIF {
Endianness streamEndianness) override;
private:
bool valid;
uint16_t packetId;
uint16_t packetSeqCtrl;
uint16_t dataLen;

View File

@ -1,9 +1,14 @@
#include <array>
#include <catch2/catch_test_macros.hpp>
#include "fsfw/tmtcpacket/SpacePacketCreator.h"
#include "fsfw/tmtcpacket/SpacePacketReader.h"
TEST_CASE("CCSDS Test", "[ccsds]") {
SpacePacketCreator base = SpacePacketCreator(
ccsds::PacketType::TC, true, 0x02,
ccsds::SequenceFlags::FIRST_SEGMENT, 0x34, 0x16);
SECTION("Constexpr Helpers") {
REQUIRE(ccsds::getTcSpacePacketIdFromApid(0x22) == 0x1822);
REQUIRE(ccsds::getTmSpacePacketIdFromApid(0x22) == 0x0822);
@ -12,15 +17,27 @@ TEST_CASE("CCSDS Test", "[ccsds]") {
REQUIRE(ccsds::getTmSpacePacketIdFromApid(0x7ff) == 0xfff);
}
SECTION("Header Creator Tests") {
SpacePacketCreator base = SpacePacketCreator(
ccsds::PacketType::TC, true, 0x02,
ccsds::SequenceFlags::FIRST_SEGMENT, 0x34, 0x16);
SECTION("Basic Test") {
REQUIRE(base.isValid());
REQUIRE(base.getApid() == 0x02);
REQUIRE(base.getSequenceFlags() == ccsds::SequenceFlags::FIRST_SEGMENT);
REQUIRE(base.getVersion() == 0b000);
REQUIRE(base.getSequenceCount() == 0x34);
REQUIRE(base.getPacketDataLen() == 0x16);
REQUIRE(base.getPacketType() == ccsds::PacketType::TC);
REQUIRE(base.getPacketId() == 0x1802);
}
SECTION("Raw Output") {
std::array<uint8_t, 6> buf {};
uint8_t* bufPtr = buf.data();
size_t serLen = 0;
base.serialize(&bufPtr, &serLen, buf.size(), SerializeIF::Endianness::MACHINE);
REQUIRE(buf[0] == 0x18);
REQUIRE(buf[1] == 0x02);
REQUIRE(buf[2] == 0x40);
REQUIRE(buf[3] == 0x34);
REQUIRE(buf[4] == 0x00);
REQUIRE(buf[5] == 0x16);
}
}