improved constexpr macros

This commit is contained in:
Robin Müller 2021-10-18 15:07:00 +02:00
parent 4924da1667
commit a077a1b587
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814

View File

@ -71,12 +71,20 @@ protected:
namespace spacepacket {
constexpr uint16_t getTcSpacePacketIdFromApid(uint16_t apid) {
return (0x18 << 8) | (((apid >> 8) & 0x07) << 8) | (apid & 0x00ff);
constexpr uint16_t getSpacePacketIdFromApid(bool isTc, uint16_t apid,
bool secondaryHeaderFlag = true) {
return (((isTc << 5) & 0x10) | ((secondaryHeaderFlag << 4) & 0x08) |
((apid >> 8) & 0x07)) << 8 | (apid & 0x00ff);
}
constexpr uint16_t getTmSpacePacketIdFromApid(uint16_t apid) {
return (0x08 << 8) | (((apid >> 8) & 0x07) << 8) | (apid & 0x00ff);
constexpr uint16_t getTcSpacketIdFromApid(uint16_t apid,
bool secondaryHeaderFlag = true) {
return getSpacePacketIdFromApid(true, apid, secondaryHeaderFlag);
}
constexpr uint16_t getTmSpacketIdFromApid(uint16_t apid,
bool secondaryHeaderFlag = true) {
return getSpacePacketIdFromApid(false, apid, secondaryHeaderFlag);
}
}