1
0
forked from fsfw/fsfw

tc distribution improvements

This commit is contained in:
2020-10-01 13:23:06 +02:00
parent 7c3f99ed2d
commit 89c4370d91
10 changed files with 331 additions and 267 deletions

View File

@ -1,31 +1,33 @@
#include "TcPacketCheck.h"
#include "../globalfunctions/CRC.h"
#include "../serviceinterface/ServiceInterfaceStream.h"
#include "../storagemanager/StorageManagerIF.h"
#include "TcPacketCheck.h"
#include "../tmtcservices/VerificationCodes.h"
TcPacketCheck::TcPacketCheck( uint16_t set_apid ) : apid(set_apid) {
TcPacketCheck::TcPacketCheck( uint16_t setApid ) : apid(setApid) {
}
ReturnValue_t TcPacketCheck::checkPacket( TcPacketStored* current_packet ) {
uint16_t calculated_crc = CRC::crc16ccitt( current_packet->getWholeData(), current_packet->getFullSize() );
ReturnValue_t TcPacketCheck::checkPacket( TcPacketStored* currentPacket ) {
uint16_t calculated_crc = CRC::crc16ccitt( currentPacket->getWholeData(),
currentPacket->getFullSize() );
if ( calculated_crc != 0 ) {
return INCORRECT_CHECKSUM;
}
bool condition = !(current_packet->hasSecondaryHeader()) ||
current_packet->getPacketVersionNumber() != CCSDS_VERSION_NUMBER ||
!(current_packet->isTelecommand());
bool condition = (not currentPacket->hasSecondaryHeader()) or
(currentPacket->getPacketVersionNumber() != CCSDS_VERSION_NUMBER) or
(not currentPacket->isTelecommand());
if ( condition ) {
return INCORRECT_PRIMARY_HEADER;
}
if ( current_packet->getAPID() != this->apid )
if ( currentPacket->getAPID() != this->apid )
return ILLEGAL_APID;
if ( !current_packet->isSizeCorrect() ) {
if ( not currentPacket->isSizeCorrect() ) {
return INCOMPLETE_PACKET;
}
condition = (current_packet->getSecondaryHeaderFlag() != CCSDS_SECONDARY_HEADER_FLAG) ||
(current_packet->getPusVersionNumber() != PUS_VERSION_NUMBER);
condition = (currentPacket->getSecondaryHeaderFlag() != CCSDS_SECONDARY_HEADER_FLAG) ||
(currentPacket->getPusVersionNumber() != PUS_VERSION_NUMBER);
if ( condition ) {
return INCORRECT_SECONDARY_HEADER;
}