Merge branch 'master' into mueller/enhanced-controller
This commit is contained in:
commit
2eb1a5c1a0
@ -9,6 +9,7 @@ SharedRingBuffer::SharedRingBuffer(object_id_t objectId, const size_t size,
|
|||||||
mutex = MutexFactory::instance()->createMutex();
|
mutex = MutexFactory::instance()->createMutex();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SharedRingBuffer::SharedRingBuffer(object_id_t objectId, uint8_t *buffer,
|
SharedRingBuffer::SharedRingBuffer(object_id_t objectId, uint8_t *buffer,
|
||||||
const size_t size, bool overwriteOld, size_t maxExcessBytes):
|
const size_t size, bool overwriteOld, size_t maxExcessBytes):
|
||||||
SystemObject(objectId), SimpleRingBuffer(buffer, size, overwriteOld,
|
SystemObject(objectId), SimpleRingBuffer(buffer, size, overwriteOld,
|
||||||
@ -16,6 +17,11 @@ SharedRingBuffer::SharedRingBuffer(object_id_t objectId, uint8_t *buffer,
|
|||||||
mutex = MutexFactory::instance()->createMutex();
|
mutex = MutexFactory::instance()->createMutex();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SharedRingBuffer::setToUseReceiveSizeFIFO(size_t fifoDepth) {
|
||||||
|
this->fifoDepth = fifoDepth;
|
||||||
|
}
|
||||||
|
|
||||||
ReturnValue_t SharedRingBuffer::lockRingBufferMutex(
|
ReturnValue_t SharedRingBuffer::lockRingBufferMutex(
|
||||||
MutexIF::TimeoutType timeoutType, dur_millis_t timeout) {
|
MutexIF::TimeoutType timeoutType, dur_millis_t timeout) {
|
||||||
return mutex->lockMutex(timeoutType, timeout);
|
return mutex->lockMutex(timeoutType, timeout);
|
||||||
@ -25,6 +31,25 @@ ReturnValue_t SharedRingBuffer::unlockRingBufferMutex() {
|
|||||||
return mutex->unlockMutex();
|
return mutex->unlockMutex();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
MutexIF* SharedRingBuffer::getMutexHandle() const {
|
MutexIF* SharedRingBuffer::getMutexHandle() const {
|
||||||
return mutex;
|
return mutex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ReturnValue_t SharedRingBuffer::initialize() {
|
||||||
|
if(fifoDepth > 0) {
|
||||||
|
receiveSizesFIFO = new DynamicFIFO<size_t>(fifoDepth);
|
||||||
|
}
|
||||||
|
return SystemObject::initialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
DynamicFIFO<size_t>* SharedRingBuffer::getReceiveSizesFIFO() {
|
||||||
|
if(receiveSizesFIFO == nullptr) {
|
||||||
|
// Configuration error.
|
||||||
|
sif::warning << "SharedRingBuffer::getReceiveSizesFIFO: Ring buffer"
|
||||||
|
<< " was not configured to have sizes FIFO, returning nullptr!"
|
||||||
|
<< std::endl;
|
||||||
|
}
|
||||||
|
return receiveSizesFIFO;
|
||||||
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#define FSFW_CONTAINER_SHAREDRINGBUFFER_H_
|
#define FSFW_CONTAINER_SHAREDRINGBUFFER_H_
|
||||||
|
|
||||||
#include "SimpleRingBuffer.h"
|
#include "SimpleRingBuffer.h"
|
||||||
|
#include "DynamicFIFO.h"
|
||||||
#include "../ipc/MutexIF.h"
|
#include "../ipc/MutexIF.h"
|
||||||
#include "../objectmanager/SystemObject.h"
|
#include "../objectmanager/SystemObject.h"
|
||||||
#include "../timemanager/Clock.h"
|
#include "../timemanager/Clock.h"
|
||||||
@ -26,6 +27,16 @@ public:
|
|||||||
SharedRingBuffer(object_id_t objectId, const size_t size,
|
SharedRingBuffer(object_id_t objectId, const size_t size,
|
||||||
bool overwriteOld, size_t maxExcessBytes);
|
bool overwriteOld, size_t maxExcessBytes);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This function can be used to add an optional FIFO to the class
|
||||||
|
* @details
|
||||||
|
* This FIFO will be allocated in the initialize function (and will
|
||||||
|
* have a fixed maximum size after that). It can be used to store
|
||||||
|
* values like packet sizes, for example for a shared ring buffer
|
||||||
|
* used by producer/consumer tasks.
|
||||||
|
*/
|
||||||
|
void setToUseReceiveSizeFIFO(size_t fifoDepth);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This constructor takes an external buffer with the specified size.
|
* This constructor takes an external buffer with the specified size.
|
||||||
* @param buffer
|
* @param buffer
|
||||||
@ -59,8 +70,21 @@ public:
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
MutexIF* getMutexHandle() const;
|
MutexIF* getMutexHandle() const;
|
||||||
|
|
||||||
|
ReturnValue_t initialize() override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If the shared ring buffer was configured to have a sizes FIFO, a handle
|
||||||
|
* to that FIFO can be retrieved with this function.
|
||||||
|
* Do not forget to protect access with a lock if required!
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
DynamicFIFO<size_t>* getReceiveSizesFIFO();
|
||||||
private:
|
private:
|
||||||
MutexIF* mutex = nullptr;
|
MutexIF* mutex = nullptr;
|
||||||
|
|
||||||
|
size_t fifoDepth = 0;
|
||||||
|
DynamicFIFO<size_t>* receiveSizesFIFO = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user