2020-07-06 00:33:55 +02:00
|
|
|
#include <framework/tmtcservices/PusParser.h>
|
2020-07-06 16:34:11 +02:00
|
|
|
#include <framework/serviceinterface/ServiceInterfaceStream.h>
|
2020-07-06 00:33:55 +02:00
|
|
|
|
|
|
|
PusParser::PusParser(uint16_t maxExpectedPusPackets,
|
|
|
|
bool storeSplitPackets): indexSizePairFIFO(maxExpectedPusPackets) {
|
|
|
|
}
|
|
|
|
|
|
|
|
ReturnValue_t PusParser::parsePusPackets(const uint8_t *frame,
|
|
|
|
size_t frameSize) {
|
2020-07-06 16:34:11 +02:00
|
|
|
if(frame == nullptr) {
|
|
|
|
sif::error << "PusParser::parsePusPackets: Frame pointers in invalid!"
|
|
|
|
<< std::endl;
|
|
|
|
return HasReturnvaluesIF::RETURN_FAILED;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Size of a pus packet is the value in the packet length field plus 7.
|
|
|
|
uint16_t packetSize = (frame[4] << 8 | frame[5]) + 7;
|
|
|
|
if(packetSize > 0) {
|
|
|
|
indexSizePairFIFO.insert(indexSizePair(0, packetSize));
|
|
|
|
return HasReturnvaluesIF::RETURN_OK;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return NO_PACKET_FOUND;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(frameSize > packetSize) {
|
|
|
|
return readMultiplePackets(frameSize);
|
|
|
|
|
|
|
|
}
|
2020-07-06 00:33:55 +02:00
|
|
|
return HasReturnvaluesIF::RETURN_OK;
|
|
|
|
}
|
2020-07-06 16:34:11 +02:00
|
|
|
|
|
|
|
//ReturnValue_t PusParser::readMultiplePackets(size_t frameSize) {
|
|
|
|
// size_t endOfBuffer = frameSize - 1;
|
|
|
|
// size_t endIndex = firstPacketSize;
|
|
|
|
// size_t startIndex = 0;
|
|
|
|
// while (endIndex < endOfBuffer) {
|
|
|
|
// ReturnValue_t result = readNextPacket(&startIndex, &endIndex);
|
|
|
|
// if(result != RETURN_OK) {
|
|
|
|
// return;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//}
|