apply auto-formatter

This commit is contained in:
Robin Müller 2022-07-18 16:07:26 +02:00
parent 490a80e49f
commit ddf38b65c3
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814
32 changed files with 242 additions and 192 deletions

View File

@ -104,8 +104,8 @@ if(FSFW_GENERATE_SECTIONS)
option(FSFW_REMOVE_UNUSED_CODE "Remove unused code" ON) option(FSFW_REMOVE_UNUSED_CODE "Remove unused code" ON)
endif() endif()
option(FSFW_BUILD_TESTS option(FSFW_BUILD_TESTS "Build unittest binary in addition to static library"
"Build unittest binary in addition to static library" OFF) OFF)
option(FSFW_CICD_BUILD "Build for CI/CD. This can disable problematic test" OFF) option(FSFW_CICD_BUILD "Build for CI/CD. This can disable problematic test" OFF)
option(FSFW_BUILD_DOCS "Build documentation with Sphinx and Doxygen" OFF) option(FSFW_BUILD_DOCS "Build documentation with Sphinx and Doxygen" OFF)
if(FSFW_BUILD_TESTS) if(FSFW_BUILD_TESTS)

View File

@ -16,8 +16,7 @@ cpp_format="clang-format"
file_selectors="-iname *.h -o -iname *.cpp -o -iname *.c -o -iname *.tpp" file_selectors="-iname *.h -o -iname *.cpp -o -iname *.c -o -iname *.tpp"
if command -v ${cpp_format} &> /dev/null; then if command -v ${cpp_format} &> /dev/null; then
find ./src ${file_selectors} | xargs ${cpp_format} --style=file -i find ./src ${file_selectors} | xargs ${cpp_format} --style=file -i
find ./hal ${file_selectors} | xargs ${cpp_format} --style=file -i find ./unittests ${file_selectors} | xargs ${cpp_format} --style=file -i
find ./tests ${file_selectors} | xargs ${cpp_format} --style=file -i
else else
echo "No ${cpp_format} tool found, not formatting C++/C files" echo "No ${cpp_format} tool found, not formatting C++/C files"
fi fi

View File

@ -2,54 +2,75 @@
#include "fsfw/serialize/SerializeAdapter.h" #include "fsfw/serialize/SerializeAdapter.h"
SpacePacketCreator::SpacePacketCreator(uint16_t packetId_, uint16_t packetSeqCtrl_, SpacePacketCreator::SpacePacketCreator(PacketId packetId_, PacketSeqCtrl psc_, uint16_t dataLen_,
uint16_t dataLen_, uint8_t version_) { uint8_t version_)
packetId = packetId_; : packetId(packetId_), packetSeqCtrl(psc_) {
packetSeqCtrl = packetSeqCtrl_;
dataLen = dataLen_; dataLen = dataLen_;
version = version_; version = version_;
valid = true; checkFieldValidity();
} }
SpacePacketCreator::SpacePacketCreator(ccsds::PacketType packetType, bool secHeaderFlag, SpacePacketCreator::SpacePacketCreator(ccsds::PacketType packetType, bool secHeaderFlag,
uint16_t apid, ccsds::SequenceFlags seqFlags, uint16_t apid, ccsds::SequenceFlags seqFlags,
uint16_t seqCount, uint16_t dataLen_, uint8_t version_) { uint16_t seqCount, uint16_t dataLen_, uint8_t version_)
if (apid > ccsds::LIMIT_APID) { : SpacePacketCreator(PacketId(packetType, secHeaderFlag, apid),
valid = false; PacketSeqCtrl(seqFlags, seqCount), dataLen_, version_) {
return;
}
if (seqCount > ccsds::LIMIT_SEQUENCE_COUNT) {
valid = false;
return;
}
version = version_; version = version_;
packetId = (static_cast<uint16_t>(packetType) << 12) | (static_cast<uint16_t>(secHeaderFlag) << 11) | apid;
packetSeqCtrl = static_cast<uint8_t>(seqFlags) << 14 | seqCount;
dataLen = dataLen_; dataLen = dataLen_;
} }
uint16_t SpacePacketCreator::getPacketId() const { return packetId; } uint16_t SpacePacketCreator::getPacketId() const { return packetId.raw(); }
uint16_t SpacePacketCreator::getPacketSeqCtrl() const { return packetSeqCtrl; } uint16_t SpacePacketCreator::getPacketSeqCtrl() const { return packetSeqCtrl.raw(); }
uint16_t SpacePacketCreator::getPacketDataLen() const { return dataLen; } uint16_t SpacePacketCreator::getPacketDataLen() const { return dataLen; }
ReturnValue_t SpacePacketCreator::serialize(uint8_t **buffer, size_t *size, size_t maxSize, ReturnValue_t SpacePacketCreator::serialize(uint8_t **buffer, size_t *size, size_t maxSize,
SerializeIF::Endianness streamEndianness) const { SerializeIF::Endianness streamEndianness) const {
uint16_t packetIdAndVersion = version << 13 | packetId; if (not isValid()) {
return HasReturnvaluesIF::RETURN_FAILED;
}
uint16_t packetIdAndVersion = (static_cast<uint16_t>(version) << 13) | packetId.raw();
ReturnValue_t result = ReturnValue_t result =
SerializeAdapter::serialize(&packetIdAndVersion, buffer, size, maxSize, streamEndianness); SerializeAdapter::serialize(&packetIdAndVersion, buffer, size, maxSize, streamEndianness);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
} }
result = SerializeAdapter::serialize(&packetSeqCtrl, buffer, size, maxSize, streamEndianness); uint16_t pscRaw = packetSeqCtrl.raw();
result = SerializeAdapter::serialize(&pscRaw, buffer, size, maxSize, streamEndianness);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
} }
return SerializeAdapter::serialize(&dataLen, buffer, size, maxSize, streamEndianness); return SerializeAdapter::serialize(&dataLen, buffer, size, maxSize, streamEndianness);
} }
size_t SpacePacketCreator::getSerializedSize() const { return 0; } size_t SpacePacketCreator::getSerializedSize() const { return 6; }
ReturnValue_t SpacePacketCreator::deSerialize(const uint8_t **buffer, size_t *size, ReturnValue_t SpacePacketCreator::deSerialize(const uint8_t **buffer, size_t *size,
SerializeIF::Endianness streamEndianness) { SerializeIF::Endianness streamEndianness) {
return HasReturnvaluesIF::RETURN_FAILED; return HasReturnvaluesIF::RETURN_FAILED;
} }
bool SpacePacketCreator::isValid() const { return valid; } bool SpacePacketCreator::isValid() const { return valid; }
ReturnValue_t SpacePacketCreator::serialize(uint8_t **buffer, size_t *size, size_t maxSize) const {
return serialize(buffer, size, maxSize, SerializeIF::Endianness::NETWORK);
}
void SpacePacketCreator::setApid(uint16_t apid) {
if (apid < ccsds::LIMIT_APID) {
packetId.apid = apid;
}
checkFieldValidity();
}
void SpacePacketCreator::setSeqCount(uint16_t seqCount) {
if (seqCount < ccsds::LIMIT_SEQUENCE_COUNT) {
packetSeqCtrl.seqCount = seqCount;
}
checkFieldValidity();
}
void SpacePacketCreator::setSeqFlags(ccsds::SequenceFlags flags) { packetSeqCtrl.seqFlags = flags; }
void SpacePacketCreator::setDataLen(uint16_t dataLen_) { dataLen = dataLen_; }
void SpacePacketCreator::checkFieldValidity() {
valid = true;
if (packetId.apid > ccsds::LIMIT_APID or packetSeqCtrl.seqCount > ccsds::LIMIT_SEQUENCE_COUNT) {
valid = false;
}
}

View File

@ -4,27 +4,77 @@
#include "SpacePacketIF.h" #include "SpacePacketIF.h"
#include "fsfw/serialize/SerializeIF.h" #include "fsfw/serialize/SerializeIF.h"
struct PacketId {
public:
/**
* Simple wrapper for Space Packet IDs. Does not check the APID for validity
* @param packetType_
* @param secHeaderFlag_
* @param apid_
*/
PacketId(ccsds::PacketType packetType_, bool secHeaderFlag_, uint16_t apid_)
: packetType(packetType_), secHeaderFlag(secHeaderFlag_), apid(apid_) {}
/**
* NOTE: If the APID has an invalid value, the invalid bits will be cut off
* @return
*/
[[nodiscard]] uint16_t raw() const {
return (static_cast<uint16_t>(packetType) << 12) |
(static_cast<uint16_t>(secHeaderFlag) << 11) | (apid & 0x7ff);
}
ccsds::PacketType packetType;
bool secHeaderFlag;
uint16_t apid;
};
struct PacketSeqCtrl {
public:
PacketSeqCtrl(ccsds::SequenceFlags seqFlags, uint16_t seqCount)
: seqFlags(seqFlags), seqCount(seqCount) {}
/**
* NOTE: If the sequence control has an invalid value, the invalid bits will be cut off
* @return
*/
[[nodiscard]] uint16_t raw() const {
return (static_cast<uint16_t>(seqFlags) << 14) | (seqCount & 0x3FFF);
}
ccsds::SequenceFlags seqFlags;
uint16_t seqCount;
};
class SpacePacketCreator : public SerializeIF, public SpacePacketIF { class SpacePacketCreator : public SerializeIF, public SpacePacketIF {
public: public:
SpacePacketCreator(ccsds::PacketType packetType, bool secHeaderFlag, uint16_t apid, SpacePacketCreator(ccsds::PacketType packetType, bool secHeaderFlag, uint16_t apid,
ccsds::SequenceFlags seqFlags, uint16_t seqCount, uint16_t dataLen, ccsds::SequenceFlags seqFlags, uint16_t seqCount, uint16_t dataLen,
uint8_t version = 0); uint8_t version = 0);
SpacePacketCreator(uint16_t packetId, uint16_t packetSeqCtrl, uint16_t dataLen, SpacePacketCreator(PacketId packetId, PacketSeqCtrl psc, uint16_t dataLen, uint8_t version = 0);
uint8_t version = 0);
[[nodiscard]] bool isValid() const; [[nodiscard]] bool isValid() const;
[[nodiscard]] uint16_t getPacketId() const override; [[nodiscard]] uint16_t getPacketId() const override;
[[nodiscard]] uint16_t getPacketSeqCtrl() const override; [[nodiscard]] uint16_t getPacketSeqCtrl() const override;
[[nodiscard]] uint16_t getPacketDataLen() const override; [[nodiscard]] uint16_t getPacketDataLen() const override;
void setApid(uint16_t apid);
void setSeqCount(uint16_t seqCount);
void setSeqFlags(ccsds::SequenceFlags flags);
void setDataLen(uint16_t dataLen);
ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize) const;
ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize, ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize,
Endianness streamEndianness) const override; Endianness streamEndianness) const override;
[[nodiscard]] size_t getSerializedSize() const override; [[nodiscard]] size_t getSerializedSize() const override;
ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size, ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size,
Endianness streamEndianness) override; Endianness streamEndianness) override;
private: private:
bool valid; void checkFieldValidity();
uint16_t packetId;
uint16_t packetSeqCtrl; bool valid{};
PacketId packetId;
PacketSeqCtrl packetSeqCtrl;
uint16_t dataLen; uint16_t dataLen;
uint8_t version; uint8_t version;
}; };

View File

@ -1,3 +1 @@
target_sources(${LIB_FSFW_NAME} PRIVATE target_sources(${LIB_FSFW_NAME} PRIVATE GpioCookie.cpp)
GpioCookie.cpp
)

View File

@ -1,5 +1,3 @@
target_sources(${LIB_FSFW_NAME} PRIVATE target_sources(
GyroL3GD20Handler.cpp ${LIB_FSFW_NAME} PRIVATE GyroL3GD20Handler.cpp MgmRM3100Handler.cpp
MgmRM3100Handler.cpp MgmLIS3MDLHandler.cpp)
MgmLIS3MDLHandler.cpp
)

View File

@ -2,20 +2,16 @@ if(FSFW_HAL_ADD_RASPBERRY_PI)
add_subdirectory(rpi) add_subdirectory(rpi)
endif() endif()
target_sources(${LIB_FSFW_NAME} PRIVATE target_sources(${LIB_FSFW_NAME} PRIVATE UnixFileGuard.cpp CommandExecutor.cpp
UnixFileGuard.cpp utility.cpp)
CommandExecutor.cpp
utility.cpp
)
if(FSFW_HAL_LINUX_ADD_PERIPHERAL_DRIVERS) if(FSFW_HAL_LINUX_ADD_PERIPHERAL_DRIVERS)
if(FSFW_HAL_LINUX_ADD_LIBGPIOD) if(FSFW_HAL_LINUX_ADD_LIBGPIOD)
add_subdirectory(gpio) add_subdirectory(gpio)
endif() endif()
add_subdirectory(uart) add_subdirectory(uart)
# Adding those does not really make sense on Apple systems which # Adding those does not really make sense on Apple systems which are generally
# are generally host systems. It won't even compile as the headers # host systems. It won't even compile as the headers are missing
# are missing
if(NOT APPLE) if(NOT APPLE)
add_subdirectory(i2c) add_subdirectory(i2c)
add_subdirectory(spi) add_subdirectory(spi)

View File

@ -1,16 +1,12 @@
# This abstraction layer requires the gpiod library. You can install this library # This abstraction layer requires the gpiod library. You can install this
# with "sudo apt-get install -y libgpiod-dev". If you are cross-compiling, you need # library with "sudo apt-get install -y libgpiod-dev". If you are
# to install the package before syncing the sysroot to your host computer. # cross-compiling, you need to install the package before syncing the sysroot to
# your host computer.
find_library(LIB_GPIO gpiod) find_library(LIB_GPIO gpiod)
if(${LIB_GPIO} MATCHES LIB_GPIO-NOTFOUND) if(${LIB_GPIO} MATCHES LIB_GPIO-NOTFOUND)
message(STATUS "gpiod library not found, not linking against it") message(STATUS "gpiod library not found, not linking against it")
else() else()
target_sources(${LIB_FSFW_NAME} PRIVATE target_sources(${LIB_FSFW_NAME} PRIVATE LinuxLibgpioIF.cpp)
LinuxLibgpioIF.cpp target_link_libraries(${LIB_FSFW_NAME} PRIVATE ${LIB_GPIO})
)
target_link_libraries(${LIB_FSFW_NAME} PRIVATE
${LIB_GPIO}
)
endif() endif()

View File

@ -1,8 +1 @@
target_sources(${LIB_FSFW_NAME} PUBLIC target_sources(${LIB_FSFW_NAME} PUBLIC I2cComIF.cpp I2cCookie.cpp)
I2cComIF.cpp
I2cCookie.cpp
)

View File

@ -1,3 +1 @@
target_sources(${LIB_FSFW_NAME} PRIVATE target_sources(${LIB_FSFW_NAME} PRIVATE GpioRPi.cpp)
GpioRPi.cpp
)

View File

@ -1,8 +1 @@
target_sources(${LIB_FSFW_NAME} PUBLIC target_sources(${LIB_FSFW_NAME} PUBLIC SpiComIF.cpp SpiCookie.cpp)
SpiComIF.cpp
SpiCookie.cpp
)

View File

@ -1,4 +1 @@
target_sources(${LIB_FSFW_NAME} PUBLIC target_sources(${LIB_FSFW_NAME} PUBLIC UartComIF.cpp UartCookie.cpp)
UartComIF.cpp
UartCookie.cpp
)

View File

@ -1,3 +1 @@
target_sources(${LIB_FSFW_NAME} PUBLIC target_sources(${LIB_FSFW_NAME} PUBLIC UioMapper.cpp)
UioMapper.cpp
)

View File

@ -2,6 +2,4 @@ add_subdirectory(spi)
add_subdirectory(gpio) add_subdirectory(gpio)
add_subdirectory(devicetest) add_subdirectory(devicetest)
target_sources(${LIB_FSFW_NAME} PRIVATE target_sources(${LIB_FSFW_NAME} PRIVATE dma.cpp)
dma.cpp
)

View File

@ -1,3 +1 @@
target_sources(${LIB_FSFW_NAME} PRIVATE target_sources(${LIB_FSFW_NAME} PRIVATE GyroL3GD20H.cpp)
GyroL3GD20H.cpp
)

View File

@ -1,3 +1 @@
target_sources(${LIB_FSFW_NAME} PRIVATE target_sources(${LIB_FSFW_NAME} PRIVATE gpio.cpp)
gpio.cpp
)

View File

@ -1,2 +1 @@
target_sources(${LIB_FSFW_NAME} PRIVATE target_sources(${LIB_FSFW_NAME} PRIVATE)
)

View File

@ -1,9 +1,9 @@
target_sources(${LIB_FSFW_NAME} PRIVATE target_sources(
spiCore.cpp ${LIB_FSFW_NAME}
PRIVATE spiCore.cpp
spiDefinitions.cpp spiDefinitions.cpp
spiInterrupts.cpp spiInterrupts.cpp
mspInit.cpp mspInit.cpp
SpiCookie.cpp SpiCookie.cpp
SpiComIF.cpp SpiComIF.cpp
stm32h743zi.cpp stm32h743zi.cpp)
)

View File

@ -1,2 +1 @@
target_sources(${LIB_FSFW_NAME} PRIVATE target_sources(${LIB_FSFW_NAME} PRIVATE)
)

View File

@ -1,3 +1 @@
target_sources(${LIB_FSFW_NAME} PRIVATE target_sources(${LIB_FSFW_NAME} PRIVATE TestAssembly.cpp)
TestAssembly.cpp
)

View File

@ -1,3 +1 @@
target_sources(${LIB_FSFW_NAME} PRIVATE target_sources(${LIB_FSFW_NAME} PRIVATE TestController.cpp)
TestController.cpp
)

View File

@ -1,5 +1,2 @@
target_sources(${LIB_FSFW_NAME} PRIVATE target_sources(${LIB_FSFW_NAME} PRIVATE TestCookie.cpp TestDeviceHandler.cpp
TestCookie.cpp TestEchoComIF.cpp)
TestDeviceHandler.cpp
TestEchoComIF.cpp
)

View File

@ -1,3 +1 @@
target_sources(${LIB_FSFW_NAME} PRIVATE target_sources(${LIB_FSFW_NAME} PRIVATE TestTask.cpp)
TestTask.cpp
)

View File

@ -1,7 +1,5 @@
target_sources(${LIB_FSFW_NAME} PRIVATE target_sources(${LIB_FSFW_NAME} PRIVATE InternalUnitTester.cpp
InternalUnitTester.cpp UnittDefinitions.cpp)
UnittDefinitions.cpp
)
add_subdirectory(osal) add_subdirectory(osal)
add_subdirectory(serialize) add_subdirectory(serialize)

View File

@ -1,3 +1 @@
target_sources(${LIB_FSFW_NAME} PRIVATE target_sources(${LIB_FSFW_NAME} PRIVATE TestArrayPrinter.cpp)
TestArrayPrinter.cpp
)

View File

@ -1,5 +1,2 @@
target_sources(${LIB_FSFW_NAME} PRIVATE target_sources(${LIB_FSFW_NAME} PRIVATE testMq.cpp testMutex.cpp
testMq.cpp testSemaphore.cpp)
testMutex.cpp
testSemaphore.cpp
)

View File

@ -1,3 +1 @@
target_sources(${LIB_FSFW_NAME} PRIVATE target_sources(${LIB_FSFW_NAME} PRIVATE IntTestSerialization.cpp)
IntTestSerialization.cpp
)

View File

@ -1,3 +1,3 @@
target_sources(${FSFW_TEST_TGT} PRIVATE target_sources(${FSFW_TEST_TGT} PRIVATE
testCcsds.cpp testCcsdsReader.cpp
) )

View File

@ -1,43 +0,0 @@
#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);
REQUIRE(ccsds::getTcSpacePacketIdFromApid(0x7ff) == 0x1fff);
REQUIRE(ccsds::getTmSpacePacketIdFromApid(0x7ff) == 0xfff);
}
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);
}
}

View File

@ -0,0 +1,82 @@
#include <array>
#include <cmath>
#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);
std::array<uint8_t, 6> buf {};
uint8_t* bufPtr = buf.data();
size_t serLen = 0;
SECTION("Constexpr Helpers") {
REQUIRE(ccsds::getTcSpacePacketIdFromApid(0x22) == 0x1822);
REQUIRE(ccsds::getTmSpacePacketIdFromApid(0x22) == 0x0822);
REQUIRE(ccsds::getTcSpacePacketIdFromApid(0x7ff) == 0x1fff);
REQUIRE(ccsds::getTmSpacePacketIdFromApid(0x7ff) == 0xfff);
}
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") {
REQUIRE(base.serialize(&bufPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK);
// TC, and secondary header flag is set -> 0b0001100 -> 0x18
REQUIRE(buf[0] == 0x18);
// APID 0x02
REQUIRE(buf[1] == 0x02);
// Sequence count is one byte value, so the only set bit here is the bit
// from the Sequence flag argument, which is the second bit for
// SequenceFlags.FIRST_SEGMENT
REQUIRE(buf[2] == 0x40);
// Sequence Count specified above
REQUIRE(buf[3] == 0x34);
// This byte and the next byte should be 22 big endian (packet length)
REQUIRE(buf[4] == 0x00);
REQUIRE(buf[5] == 0x16);
}
SECTION("All Ones Output") {
base.setApid(static_cast<int>(std::pow(2, 11)) - 1);
base.setSeqCount(static_cast<int>(std::pow(2, 14)) - 1);
base.setSeqFlags(ccsds::SequenceFlags::UNSEGMENTED);
base.setDataLen(static_cast<int>(std::pow(2, 16)) - 1);
REQUIRE(base.isValid());
REQUIRE(base.serialize(&bufPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK);
REQUIRE(buf[0] == 0x1F);
REQUIRE(buf[1] == 0xFF);
REQUIRE(buf[2] == 0xFF);
REQUIRE(buf[3] == 0xFF);
REQUIRE(buf[4] == 0xFF);
REQUIRE(buf[5] == 0xFF);
}
SECTION("Invalid APID") {
SpacePacketCreator invalid = SpacePacketCreator(
PacketId(ccsds::PacketType::TC, true, 0xFFFF),
PacketSeqCtrl(ccsds::SequenceFlags::FIRST_SEGMENT, 0x34), 0x16);
REQUIRE(not invalid.isValid());
REQUIRE(invalid.serialize(&bufPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_FAILED);
}
SECTION("Invalid Seq Count") {
SpacePacketCreator invalid = SpacePacketCreator(
PacketId(ccsds::PacketType::TC, true, 0x02),
PacketSeqCtrl(ccsds::SequenceFlags::FIRST_SEGMENT, 0xFFFF), 0x16);
REQUIRE(not invalid.isValid());
REQUIRE(invalid.serialize(&bufPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_FAILED);
}
}