fifo tweaks, pus parser fixes

This commit is contained in:
Robin Müller 2020-07-06 23:07:38 +02:00
parent fd1e612ea5
commit cb691db807
4 changed files with 10 additions and 8 deletions

View File

@ -19,10 +19,8 @@ namespace fsfw {
template<typename T> template<typename T>
class FIFO: public FIFOBase<T> { class FIFO: public FIFOBase<T> {
public: public:
FIFO(size_t maxCapacity): FIFOBase<T>(values.data(), maxCapacity) { FIFO(size_t maxCapacity): FIFOBase<T>(values.data(), maxCapacity),
values.reserve(maxCapacity); values(maxCapacity) {};
values.resize(maxCapacity);
};
private: private:
std::vector<T> values; std::vector<T> values;

View File

@ -45,9 +45,11 @@ public:
bool full(); bool full();
size_t size(); size_t size();
size_t getMaxCapacity() const;
private: private:
T* values; T* values;
size_t maxCapacity; size_t maxCapacity = 0;
size_t readIndex = 0; size_t readIndex = 0;
size_t writeIndex = 0; size_t writeIndex = 0;

View File

@ -73,4 +73,9 @@ inline size_t FIFOBase<T>::next(size_t current) {
return current; return current;
} }
template<typename T>
inline size_t FIFOBase<T>::getMaxCapacity() const {
return maxCapacity;
}
#endif #endif

View File

@ -45,12 +45,10 @@ ReturnValue_t PusParser::parsePusPackets(const uint8_t *frame,
{ {
indexSizePairFIFO.insert(indexSizePair(0, packetSize)); indexSizePairFIFO.insert(indexSizePair(0, packetSize));
if(packetSize == frameSize) { if(packetSize == frameSize) {
sif::info << "test2" << std::endl;
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
} }
// packet size is smaller than frame size, parse for more packets. // packet size is smaller than frame size, parse for more packets.
return readMultiplePackets(frame, frameSize, packetSize); return readMultiplePackets(frame, frameSize, packetSize);
} }
@ -58,7 +56,6 @@ ReturnValue_t PusParser::parsePusPackets(const uint8_t *frame,
ReturnValue_t PusParser::readMultiplePackets(const uint8_t *frame, ReturnValue_t PusParser::readMultiplePackets(const uint8_t *frame,
size_t frameSize, size_t startIndex) { size_t frameSize, size_t startIndex) {
while (startIndex < frameSize) { while (startIndex < frameSize) {
sif::info << "test" << std::endl;
ReturnValue_t result = readNextPacket(frame, frameSize, startIndex); ReturnValue_t result = readNextPacket(frame, frameSize, startIndex);
if(result != HasReturnvaluesIF::RETURN_OK) { if(result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;