documentation and bugfixes
This commit is contained in:
parent
f02852d8d2
commit
a4d6421510
@ -44,7 +44,7 @@ ReturnValue_t SpacePacketParser::parseSpacePackets(const uint8_t **buffer, const
|
|||||||
foundSize = packetSize;
|
foundSize = packetSize;
|
||||||
}
|
}
|
||||||
*buffer += foundSize;
|
*buffer += foundSize;
|
||||||
readLen += foundSize;
|
readLen += idx + foundSize;
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -8,19 +8,11 @@
|
|||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This small helper class scans a given buffer for PUS packets.
|
* @brief This small helper class scans a given buffer for space packets.
|
||||||
* Can be used if PUS packets are serialized in a tightly packed frame.
|
* Can be used if space packets are serialized in a tightly packed frame.
|
||||||
* @details
|
* @details
|
||||||
* The parser uses the length field field of the space packets to find
|
* The parser uses the length field field and the 16-bit TC packet ID of the space packets to find
|
||||||
* the respective space packet sizes.
|
* find space packets in a given data stream
|
||||||
*
|
|
||||||
* The parser parses a buffer by taking a pointer and the maximum size to scan.
|
|
||||||
* If space packets are found, they are stored in a FIFO which stores pairs
|
|
||||||
* consisting of the index in the buffer and the respective packet sizes.
|
|
||||||
*
|
|
||||||
* If the parser detects split packets (which means that the size of the
|
|
||||||
* next packet is larger than the remaining size to scan), it can either
|
|
||||||
* store that split packet or throw away the packet.
|
|
||||||
* @author R. Mueller
|
* @author R. Mueller
|
||||||
*/
|
*/
|
||||||
class SpacePacketParser {
|
class SpacePacketParser {
|
||||||
@ -35,62 +27,52 @@ public:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Parser constructor.
|
* @brief Parser constructor.
|
||||||
* @param maxExpectedPusPackets
|
* @param validPacketIds This vector contains the allowed 16-bit TC packet ID start markers
|
||||||
* Maximum expected number of PUS packets. A good estimate is to divide
|
* The parser will search for these stark markers to detect the start of a space packet.
|
||||||
* the frame size by the minimum size of a PUS packet (12 bytes)
|
* It is also possible to pass an empty vector here, but this is not recommended.
|
||||||
* @param storeSplitPackets
|
* If an empty vector is passed, the parser will assume that the start of the given stream
|
||||||
* Specifies whether split packets are also stored inside the FIFO,
|
* contains the start of a new space packet.
|
||||||
* with the size being the remaining frame size.
|
|
||||||
*/
|
*/
|
||||||
SpacePacketParser(std::vector<uint16_t> validPacketIds);
|
SpacePacketParser(std::vector<uint16_t> validPacketIds);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse a given frame for space packets but also increment the given buffer and assign the
|
||||||
|
* total number of bytes read so far
|
||||||
|
* @param buffer Parser will look for space packets in this buffer
|
||||||
|
* @param maxSize Maximum size of the buffer
|
||||||
|
* @param startIndex Start index of a found space packet
|
||||||
|
* @param foundSize Found size of the space packet
|
||||||
|
* @param readLen Length read so far. This value is incremented by the number of parsed
|
||||||
|
* bytes which also includes the size of a found packet
|
||||||
|
* -@c NO_PACKET_FOUND if no packet was found in the given buffer or the length field is
|
||||||
|
* invalid. foundSize will be set to the size of the space packet header. buffer and
|
||||||
|
* readLen will be incremented accordingly.
|
||||||
|
* -@c SPLIT_PACKET if a packet was found but the detected size exceeds maxSize. foundSize
|
||||||
|
* will be set to the detected packet size and startIndex will be set to the start of the
|
||||||
|
* detected packet. buffer and read length will not be incremented but the found length
|
||||||
|
* will be assigned.
|
||||||
|
* -@c RETURN_OK if a packet was found
|
||||||
|
*/
|
||||||
|
ReturnValue_t parseSpacePackets(const uint8_t **buffer, const size_t maxSize,
|
||||||
|
size_t& startIndex, size_t& foundSize, size_t& readLen);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse a given frame for PUS packets
|
* Parse a given frame for space packets
|
||||||
* @param frame
|
* @param buffer Parser will look for space packets in this buffer
|
||||||
* @param frameSize
|
* @param maxSize Maximum size of the buffer
|
||||||
* @param foundPackets The number of found packets will be stored here
|
* @param startIndex Start index of a found space packet
|
||||||
* @return
|
* @param foundSize Found size of the space packet
|
||||||
* -@c NO_PACKET_FOUND if no packet was found
|
* -@c NO_PACKET_FOUND if no packet was found in the given buffer or the length field is
|
||||||
* -@c SPLIT_PACKET if splitting is enabled and a split packet was found
|
* invalid. foundSize will be set to the size of the space packet header
|
||||||
* -@c RETURN_OK if a packet was found. The index and sizes are stored in the internal FIFO
|
* -@c SPLIT_PACKET if a packet was found but the detected size exceeds maxSize. foundSize
|
||||||
|
* will be set to the detected packet size and startIndex will be set to the start of the
|
||||||
|
* detected packet
|
||||||
|
* -@c RETURN_OK if a packet was found
|
||||||
*/
|
*/
|
||||||
ReturnValue_t parseSpacePackets(const uint8_t* buffer, const size_t maxSize,
|
ReturnValue_t parseSpacePackets(const uint8_t* buffer, const size_t maxSize,
|
||||||
size_t& startIndex, size_t& foundSize);
|
size_t& startIndex, size_t& foundSize);
|
||||||
|
|
||||||
ReturnValue_t parseSpacePackets(const uint8_t **buffer, const size_t maxSize,
|
|
||||||
size_t& startIndex, size_t& foundSize, size_t& readLen);
|
|
||||||
/**
|
|
||||||
* Accessor function to get a reference to the internal FIFO which
|
|
||||||
* stores pairs of index and packet sizes. This FIFO is filled
|
|
||||||
* by the #parsePusPackets function.
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
//DynamicFIFO<IndexSizePair>& fifo();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieve the next index and packet size pair from the FIFO.
|
|
||||||
* This also removes it from the FIFO. Please note that if the FIFO
|
|
||||||
* is empty, an empty pair will be returned.
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
//IndexSizePair getNextFifoPair();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
|
||||||
* A FIFO is used to store information about multiple PUS packets
|
|
||||||
* inside the receive buffer. The maximum number of entries is defined
|
|
||||||
* by the first constructor argument.
|
|
||||||
*/
|
|
||||||
//DynamicFIFO<IndexSizePair> indexSizePairFIFO;
|
|
||||||
|
|
||||||
std::vector<uint16_t> validPacketIds;
|
std::vector<uint16_t> validPacketIds;
|
||||||
|
|
||||||
//bool storeSplitPackets = false;
|
|
||||||
|
|
||||||
// ReturnValue_t readMultiplePackets(const uint8_t *frame, size_t frameSize,
|
|
||||||
// size_t startIndex, uint32_t& foundPackets);
|
|
||||||
// ReturnValue_t readNextPacket(const uint8_t *frame,
|
|
||||||
// size_t frameSize, size_t& startIndex, uint32_t& foundPackets);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* FRAMEWORK_TMTCSERVICES_PUSPARSER_H_ */
|
#endif /* FRAMEWORK_TMTCSERVICES_PUSPARSER_H_ */
|
||||||
|
Loading…
Reference in New Issue
Block a user