From cb691db807d562c8f84178d48650464c4cb58ecc Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Mon, 6 Jul 2020 23:07:38 +0200 Subject: [PATCH] fifo tweaks, pus parser fixes --- container/FIFO.h | 6 ++---- container/FIFOBase.h | 4 +++- container/FIFOBase.tpp | 5 +++++ tmtcservices/PusParser.cpp | 3 --- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/container/FIFO.h b/container/FIFO.h index 7251321f..19daaf1b 100644 --- a/container/FIFO.h +++ b/container/FIFO.h @@ -19,10 +19,8 @@ namespace fsfw { template class FIFO: public FIFOBase { public: - FIFO(size_t maxCapacity): FIFOBase(values.data(), maxCapacity) { - values.reserve(maxCapacity); - values.resize(maxCapacity); - }; + FIFO(size_t maxCapacity): FIFOBase(values.data(), maxCapacity), + values(maxCapacity) {}; private: std::vector values; diff --git a/container/FIFOBase.h b/container/FIFOBase.h index ac5c6e2c..6ed7d924 100644 --- a/container/FIFOBase.h +++ b/container/FIFOBase.h @@ -45,9 +45,11 @@ public: bool full(); size_t size(); + size_t getMaxCapacity() const; + private: T* values; - size_t maxCapacity; + size_t maxCapacity = 0; size_t readIndex = 0; size_t writeIndex = 0; diff --git a/container/FIFOBase.tpp b/container/FIFOBase.tpp index 011ce6de..48a060ff 100644 --- a/container/FIFOBase.tpp +++ b/container/FIFOBase.tpp @@ -73,4 +73,9 @@ inline size_t FIFOBase::next(size_t current) { return current; } +template +inline size_t FIFOBase::getMaxCapacity() const { + return maxCapacity; +} + #endif diff --git a/tmtcservices/PusParser.cpp b/tmtcservices/PusParser.cpp index b43b0519..175c2893 100644 --- a/tmtcservices/PusParser.cpp +++ b/tmtcservices/PusParser.cpp @@ -45,12 +45,10 @@ ReturnValue_t PusParser::parsePusPackets(const uint8_t *frame, { indexSizePairFIFO.insert(indexSizePair(0, packetSize)); if(packetSize == frameSize) { - sif::info << "test2" << std::endl; return HasReturnvaluesIF::RETURN_OK; } } - // packet size is smaller than frame size, parse for more packets. 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, size_t frameSize, size_t startIndex) { while (startIndex < frameSize) { - sif::info << "test" << std::endl; ReturnValue_t result = readNextPacket(frame, frameSize, startIndex); if(result != HasReturnvaluesIF::RETURN_OK) { return result;