move CRC check

This commit is contained in:
Robin Müller 2023-11-10 11:27:54 +01:00
parent cc3e64e70d
commit dfe7c378da
Signed by: muellerr
GPG Key ID: A649FB78196E3849

View File

@ -57,6 +57,13 @@ ReturnValue_t PusTmReader::parseData(bool crcCheck) {
if (result != returnvalue::OK) {
return result;
}
if (crcCheck) {
uint16_t crc16 = CRC::crc16ccitt(spReader.getFullData(), getFullPacketLen());
if (crc16 != 0) {
// Checksum failure
return PusIF::INVALID_CRC_16;
}
}
size_t currentOffset = SpacePacketReader::getHeaderLen();
pointers.secHeaderStart = pointers.spHeaderStart + currentOffset;
currentOffset += PusTmIF::MIN_SEC_HEADER_LEN;
@ -77,13 +84,6 @@ ReturnValue_t PusTmReader::parseData(bool crcCheck) {
}
currentOffset += sourceDataLen;
pointers.crcStart = pointers.spHeaderStart + currentOffset;
if (crcCheck) {
uint16_t crc16 = CRC::crc16ccitt(spReader.getFullData(), getFullPacketLen());
if (crc16 != 0) {
// Checksum failure
return PusIF::INVALID_CRC_16;
}
}
return returnvalue::OK;
}
bool PusTmReader::isNull() const { return spReader.isNull() or pointers.secHeaderStart == nullptr; }