1
0
forked from fsfw/fsfw

Today's the day. Renamed platform to framework.

This commit is contained in:
Bastian Baetz
2016-06-15 23:48:41 +02:00
committed by Ulrich Mohr
parent 40987d0b27
commit 1d22a6c97e
356 changed files with 33946 additions and 3 deletions

View File

@ -0,0 +1,45 @@
/*
* TcPacketCheck.cpp
*
* Created on: 19.06.2012
* Author: baetz
*/
#include <framework/globalfunctions/crc_ccitt.h>
#include <framework/serviceinterface/ServiceInterfaceStream.h>
#include <framework/storagemanager/StorageManagerIF.h>
#include <framework/tcdistribution/TcPacketCheck.h>
#include <framework/tmtcservices/VerificationCodes.h>
TcPacketCheck::TcPacketCheck( uint16_t set_apid ) : apid(set_apid) {
}
ReturnValue_t TcPacketCheck::checkPacket( TcPacketStored* current_packet ) {
uint16_t calculated_crc = ::Calculate_CRC ( current_packet->getWholeData(), current_packet->getFullSize() );
if ( calculated_crc != 0 ) {
return INCORRECT_CHECKSUM;
}
bool condition = !(current_packet->hasSecondaryHeader()) ||
current_packet->getPacketVersionNumber() != CCSDS_VERSION_NUMBER ||
!(current_packet->isTelecommand());
if ( condition ) {
return INCORRECT_PRIMARY_HEADER;
}
if ( current_packet->getAPID() != this->apid )
return ILLEGAL_APID;
if ( !current_packet->isSizeCorrect() ) {
return INCOMPLETE_PACKET;
}
condition = (current_packet->getSecondaryHeaderFlag() != CCSDS_SECONDARY_HEADER_FLAG) ||
(current_packet->getPusVersionNumber() != PUS_VERSION_NUMBER);
if ( condition ) {
return INCORRECT_SECONDARY_HEADER;
}
return RETURN_OK;
}
uint16_t TcPacketCheck::getApid() const {
return apid;
}