Shared ring buffer improvements #32
@ -1,5 +1,6 @@
|
||||
#include "fsfw/container/SharedRingBuffer.h"
|
||||
|
||||
#include "SharedRingBuffer.h"
|
||||
#include "fsfw/ipc/MutexFactory.h"
|
||||
#include "fsfw/ipc/MutexGuard.h"
|
||||
|
||||
@ -15,7 +16,12 @@ SharedRingBuffer::SharedRingBuffer(object_id_t objectId, uint8_t* buffer, const
|
||||
mutex = MutexFactory::instance()->createMutex();
|
||||
}
|
||||
|
||||
SharedRingBuffer::~SharedRingBuffer() { MutexFactory::instance()->deleteMutex(mutex); }
|
||||
SharedRingBuffer::~SharedRingBuffer() {
|
||||
MutexFactory::instance()->deleteMutex(mutex);
|
||||
if (receiveSizesFIFO != nullptr) {
|
||||
delete (receiveSizesFIFO);
|
||||
}
|
||||
}
|
||||
|
||||
void SharedRingBuffer::setToUseReceiveSizeFIFO(size_t fifoDepth) { this->fifoDepth = fifoDepth; }
|
||||
|
||||
@ -45,3 +51,22 @@ DynamicFIFO<size_t>* SharedRingBuffer::getReceiveSizesFIFO() {
|
||||
}
|
||||
return receiveSizesFIFO;
|
||||
}
|
||||
ReturnValue_t SharedRingBuffer::lockedWrite(const uint8_t* data, size_t dataLen,
|
||||
MutexIF::TimeoutType lockType, uint32_t waitTimeMs) {
|
||||
MutexGuard mg(mutex, lockType, waitTimeMs);
|
||||
if (availableWriteSpace() < dataLen ||
|
||||
(receiveSizesFIFO != nullptr && receiveSizesFIFO->full())) {
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
// The following two operation should not fail..
|
||||
ReturnValue_t result = writeData(data, dataLen);
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
if (receiveSizesFIFO != nullptr) {
|
||||
result = receiveSizesFIFO->insert(dataLen);
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -80,6 +80,9 @@ class SharedRingBuffer : public SystemObject, public SimpleRingBuffer {
|
||||
*/
|
||||
DynamicFIFO<size_t>* getReceiveSizesFIFO();
|
||||
|
||||
ReturnValue_t lockedWrite(const uint8_t* data, size_t dataLen, MutexIF::TimeoutType lockType,
|
||||
uint32_t waitTimeMs);
|
||||
|
||||
private:
|
||||
MutexIF* mutex = nullptr;
|
||||
|
||||
|
@ -3,9 +3,9 @@
|
||||
|
||||
#include <atomic>
|
||||
#include <condition_variable>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
#include "fsfw/objectmanager/ObjectManagerIF.h"
|
||||
#include "fsfw/tasks/FixedSlotSequence.h"
|
||||
|
@ -3,9 +3,9 @@
|
||||
|
||||
#include <atomic>
|
||||
#include <condition_variable>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
#include "fsfw/objectmanager/ObjectManagerIF.h"
|
||||
#include "fsfw/tasks/PeriodicTaskBase.h"
|
||||
|
@ -3,8 +3,8 @@
|
||||
|
||||
#include <fsfw/returnvalues/returnvalue.h>
|
||||
|
||||
#include <thread>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
|
||||
namespace tasks {
|
||||
|
||||
|
@ -150,7 +150,7 @@ inline ReturnValue_t Service11TelecommandScheduling<MAX_NUM_TCS>::handleResetCom
|
||||
template <size_t MAX_NUM_TCS>
|
||||
inline ReturnValue_t Service11TelecommandScheduling<MAX_NUM_TCS>::doInsertActivity(
|
||||
const uint8_t *data, size_t size) {
|
||||
if(telecommandMap.full()) {
|
||||
if (telecommandMap.full()) {
|
||||
return MAP_IS_FULL;
|
||||
}
|
||||
uint32_t timestamp = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user