Compare commits

...

1 Commits

Author SHA1 Message Date
dfe7c378da
move CRC check 2023-11-10 11:27:54 +01:00

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; }