2022-07-27 17:00:43 +02:00
|
|
|
#include "CcsdsPacketChecker.h"
|
|
|
|
|
|
|
|
#include "fsfw/tcdistribution/definitions.h"
|
|
|
|
#include "fsfw/tmtcpacket/ccsds/SpacePacketReader.h"
|
|
|
|
|
|
|
|
CcsdsPacketChecker::CcsdsPacketChecker(ccsds::PacketType packetType_, uint8_t ccsdsVersion_)
|
|
|
|
: packetType(packetType_), ccsdsVersion(ccsdsVersion_) {}
|
|
|
|
|
|
|
|
ReturnValue_t CcsdsPacketChecker::checkPacket(const SpacePacketReader& currentPacket,
|
|
|
|
size_t packetLen) {
|
|
|
|
if (checkApid) {
|
|
|
|
if (currentPacket.getApid() != apid) {
|
2022-08-03 15:12:29 +02:00
|
|
|
return tmtcdistrib::INVALID_APID;
|
2022-07-27 17:00:43 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (currentPacket.getVersion() != ccsdsVersion) {
|
2022-08-03 15:12:29 +02:00
|
|
|
return tmtcdistrib::INVALID_CCSDS_VERSION;
|
2022-07-27 17:00:43 +02:00
|
|
|
}
|
|
|
|
if (currentPacket.getPacketType() != packetType) {
|
2022-08-03 15:12:29 +02:00
|
|
|
return tmtcdistrib::INVALID_PACKET_TYPE;
|
2022-07-27 17:00:43 +02:00
|
|
|
}
|
|
|
|
// This assumes that the getFullPacketLen version uses the space packet data length field
|
|
|
|
if (currentPacket.getFullPacketLen() != packetLen) {
|
2022-08-03 15:12:29 +02:00
|
|
|
return tmtcdistrib::INCOMPLETE_PACKET;
|
2022-07-27 17:00:43 +02:00
|
|
|
}
|
2022-08-16 01:08:26 +02:00
|
|
|
return returnvalue::OK;
|
2022-07-27 17:00:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CcsdsPacketChecker::setApidToCheck(uint16_t apid_) {
|
|
|
|
apid = apid_;
|
|
|
|
checkApid = true;
|
|
|
|
}
|