diff --git a/container/SharedRingBuffer.cpp b/container/SharedRingBuffer.cpp index 64cbc669..86277a80 100644 --- a/container/SharedRingBuffer.cpp +++ b/container/SharedRingBuffer.cpp @@ -3,19 +3,26 @@ #include SharedRingBuffer::SharedRingBuffer(object_id_t objectId, const size_t size, - bool overwriteOld, dur_millis_t mutexTimeout): - SystemObject(objectId), SimpleRingBuffer(size, overwriteOld), - mutexTimeout(mutexTimeout) { + bool overwriteOld, size_t maxExcessBytes, dur_millis_t mutexTimeout): + SystemObject(objectId), SimpleRingBuffer(size, overwriteOld, + maxExcessBytes), mutexTimeout(mutexTimeout) { mutex = MutexFactory::instance()->createMutex(); } SharedRingBuffer::SharedRingBuffer(object_id_t objectId, uint8_t *buffer, - const size_t size, bool overwriteOld, dur_millis_t mutexTimeout): - SystemObject(objectId), SimpleRingBuffer(buffer, size, overwriteOld), - mutexTimeout(mutexTimeout) { + const size_t size, bool overwriteOld, size_t maxExcessBytes, + dur_millis_t mutexTimeout): + SystemObject(objectId), SimpleRingBuffer(buffer, size, overwriteOld, + maxExcessBytes), mutexTimeout(mutexTimeout) { mutex = MutexFactory::instance()->createMutex(); } +ReturnValue_t SharedRingBuffer::getFreeElementProtected(uint8_t** writePtr, + size_t amount) { + MutexHelper(mutex, mutexTimeout); + return SimpleRingBuffer::getFreeElement(writePtr,amount); +} + ReturnValue_t SharedRingBuffer::writeDataProtected(const uint8_t *data, size_t amount) { MutexHelper(mutex, mutexTimeout); diff --git a/container/SharedRingBuffer.h b/container/SharedRingBuffer.h index f7d3bc3c..7fed7b22 100644 --- a/container/SharedRingBuffer.h +++ b/container/SharedRingBuffer.h @@ -17,7 +17,8 @@ public: * will be overwritten. */ SharedRingBuffer(object_id_t objectId, const size_t size, - bool overwriteOld, dur_millis_t mutexTimeout = 10); + bool overwriteOld, size_t maxExcessBytes, + dur_millis_t mutexTimeout = 10); /** * This constructor takes an external buffer with the specified size. @@ -28,10 +29,14 @@ public: * will be overwritten. */ SharedRingBuffer(object_id_t objectId, uint8_t* buffer, const size_t size, - bool overwriteOld, dur_millis_t mutexTimeout = 10); + bool overwriteOld, size_t maxExcessBytes, + dur_millis_t mutexTimeout = 10); void setMutexTimeout(dur_millis_t newTimeout); + /** Performs mutex protected SimpleRingBuffer::getFreeElement call */ + ReturnValue_t getFreeElementProtected(uint8_t** writePtr, size_t amount); + /** Performs mutex protected SimpleRingBuffer::writeData call */ ReturnValue_t writeDataProtected(const uint8_t* data, size_t amount);