Bugfix for Packet ID getters

- Also added related unittests
This commit is contained in:
Robin Müller 2021-11-18 19:56:24 +01:00
parent 186b3565e0
commit 05c4f4fadc
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814
3 changed files with 13 additions and 2 deletions

View File

@ -73,7 +73,7 @@ namespace spacepacket {
constexpr uint16_t getSpacePacketIdFromApid(bool isTc, uint16_t apid, constexpr uint16_t getSpacePacketIdFromApid(bool isTc, uint16_t apid,
bool secondaryHeaderFlag = true) { bool secondaryHeaderFlag = true) {
return (((isTc << 5) & 0x10) | ((secondaryHeaderFlag << 4) & 0x08) | return ((isTc << 4) | (secondaryHeaderFlag << 3) |
((apid >> 8) & 0x07)) << 8 | (apid & 0x00ff); ((apid >> 8) & 0x07)) << 8 | (apid & 0x00ff);
} }

View File

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

View File

@ -0,0 +1,11 @@
#include <catch2/catch_test_macros.hpp>
#include "fsfw/tmtcpacket/SpacePacket.h"
TEST_CASE( "CCSDS Test" , "[ccsds]") {
REQUIRE(spacepacket::getTcSpacePacketIdFromApid(0x22) == 0x1822);
REQUIRE(spacepacket::getTmSpacePacketIdFromApid(0x22) == 0x0822);
REQUIRE(spacepacket::getTcSpacePacketIdFromApid(0x7ff) == 0x1fff);
REQUIRE(spacepacket::getTmSpacePacketIdFromApid(0x7ff) == 0xfff);
}