added additional calls

This commit is contained in:
Robin Müller 2020-08-04 11:47:47 +02:00
parent 6b475792a4
commit 4dcfa5125e
4 changed files with 21 additions and 3 deletions

View File

@ -43,6 +43,16 @@ ReturnValue_t SharedRingBuffer::deleteDataProtected(size_t amount,
return SimpleRingBuffer::deleteData(amount, deleteRemaining, trueAmount);
}
size_t SharedRingBuffer::getExcessBytes() const {
MutexHelper(mutex, mutexTimeout);
return SimpleRingBuffer::getExcessBytes();
}
void SharedRingBuffer::moveExcessBytesToStart() {
MutexHelper(mutex, mutexTimeout);
return SimpleRingBuffer::moveExcessBytesToStart();
}
size_t SharedRingBuffer::getAvailableReadDataProtected(uint8_t n) const {
MutexHelper(mutex, mutexTimeout);
return ((write + size) - read[n]) % size;

View File

@ -34,6 +34,14 @@ public:
void setMutexTimeout(dur_millis_t newTimeout);
virtual size_t getExcessBytes() const override;
/**
* Helper functions which moves any excess bytes to the start
* of the ring buffer.
* @return
*/
virtual void moveExcessBytesToStart() override;
/** Performs mutex protected SimpleRingBuffer::getFreeElement call */
ReturnValue_t getFreeElementProtected(uint8_t** writePtr, size_t amount);

View File

@ -39,7 +39,7 @@ ReturnValue_t SimpleRingBuffer::getFreeElement(uint8_t **writePointer,
if((amount - amountTillWrap + excessBytes) > maxExcessBytes) {
return HasReturnvaluesIF::RETURN_FAILED;
}
excessBytes += amount - amountTillWrap;
excessBytes = amount - amountTillWrap;
}
*writePointer = &buffer[write];
incrementWrite(amount);

View File

@ -64,13 +64,13 @@ public:
*/
ReturnValue_t getFreeElement(uint8_t** writePointer, size_t amount);
size_t getExcessBytes() const;
virtual size_t getExcessBytes() const;
/**
* Helper functions which moves any excess bytes to the start
* of the ring buffer.
* @return
*/
void moveExcessBytesToStart();
virtual void moveExcessBytesToStart();
/**
* Read from circular buffer at read pointer.