merged changes

This commit is contained in:
Robin Müller 2020-09-29 14:49:57 +02:00
parent 224248dfa1
commit 485e96f12f
9 changed files with 66 additions and 55 deletions

View File

@ -1,6 +1,7 @@
#include "ConstStorageAccessor.h"
#include "StorageManagerIF.h"
#include "../serviceinterface/ServiceInterfaceStream.h" #include "../serviceinterface/ServiceInterfaceStream.h"
#include "../storagemanager/ConstStorageAccessor.h"
#include "../storagemanager/StorageManagerIF.h"
#include "../globalfunctions/arrayprinter.h" #include "../globalfunctions/arrayprinter.h"
ConstStorageAccessor::ConstStorageAccessor(store_address_t storeId): ConstStorageAccessor::ConstStorageAccessor(store_address_t storeId):
@ -14,12 +15,7 @@ ConstStorageAccessor::ConstStorageAccessor(store_address_t storeId,
ConstStorageAccessor::~ConstStorageAccessor() { ConstStorageAccessor::~ConstStorageAccessor() {
if(deleteData and store != nullptr) { if(deleteData and store != nullptr) {
ReturnValue_t result = store->deleteData(storeId); store->deleteData(storeId);
if(result != HasReturnvaluesIF::RETURN_OK) {
// Configuration error.
sif::error << "ConstStorageAccessor::~ConstStorageAccessor: "
<< "Could not delete entry!" << std::endl;
}
} }
} }
@ -62,7 +58,8 @@ ReturnValue_t ConstStorageAccessor::getDataCopy(uint8_t *pointer,
return HasReturnvaluesIF::RETURN_FAILED; return HasReturnvaluesIF::RETURN_FAILED;
} }
if(size_ > maxSize) { if(size_ > maxSize) {
sif::error << "StorageAccessor: Supplied buffer not large enough" << std::endl; sif::error << "StorageAccessor: Supplied buffer not large enough"
<< std::endl;
return HasReturnvaluesIF::RETURN_FAILED; return HasReturnvaluesIF::RETURN_FAILED;
} }
std::copy(constDataPointer, constDataPointer + size_, pointer); std::copy(constDataPointer, constDataPointer + size_, pointer);

View File

@ -1,7 +1,7 @@
#ifndef FRAMEWORK_STORAGEMANAGER_CONSTSTORAGEACCESSOR_H_ #ifndef FSFW_STORAGEMANAGER_CONSTSTORAGEACCESSOR_H_
#define FRAMEWORK_STORAGEMANAGER_CONSTSTORAGEACCESSOR_H_ #define FSFW_STORAGEMANAGER_CONSTSTORAGEACCESSOR_H_
#include "../storagemanager/storeAddress.h" #include "storeAddress.h"
#include "../returnvalues/HasReturnvaluesIF.h" #include "../returnvalues/HasReturnvaluesIF.h"
#include <cstddef> #include <cstddef>
@ -113,4 +113,4 @@ protected:
}; };
#endif /* FRAMEWORK_STORAGEMANAGER_CONSTSTORAGEACCESSOR_H_ */ #endif /* FSFW_STORAGEMANAGER_CONSTSTORAGEACCESSOR_H_ */

View File

@ -1,14 +1,15 @@
#ifndef FRAMEWORK_STORAGEMANAGER_LOCALPOOL_H_ #ifndef FSFW_STORAGEMANAGER_LOCALPOOL_H_
#define FRAMEWORK_STORAGEMANAGER_LOCALPOOL_H_ #define FSFW_STORAGEMANAGER_LOCALPOOL_H_
#include "StorageManagerIF.h"
#include "../objectmanager/SystemObject.h" #include "../objectmanager/SystemObject.h"
#include "../serviceinterface/ServiceInterfaceStream.h"
#include "../storagemanager/StorageManagerIF.h"
#include "../objectmanager/ObjectManagerIF.h" #include "../objectmanager/ObjectManagerIF.h"
#include "../serviceinterface/ServiceInterfaceStream.h"
#include "../internalError/InternalErrorReporterIF.h" #include "../internalError/InternalErrorReporterIF.h"
#include "../storagemanager/StorageAccessor.h" #include "../storagemanager/StorageAccessor.h"
#include <cstring> #include <cstring>
/** /**
* @brief The LocalPool class provides an intermediate data storage with * @brief The LocalPool class provides an intermediate data storage with
* a fixed pool size policy. * a fixed pool size policy.
@ -184,6 +185,6 @@ private:
ReturnValue_t findEmpty(uint16_t pool_index, uint16_t* element); ReturnValue_t findEmpty(uint16_t pool_index, uint16_t* element);
}; };
#include "../storagemanager/LocalPool.tpp" #include "LocalPool.tpp"
#endif /* FRAMEWORK_STORAGEMANAGER_LOCALPOOL_H_ */ #endif /* FSFW_STORAGEMANAGER_LOCALPOOL_H_ */

View File

@ -1,7 +1,7 @@
#ifndef FRAMEWORK_STORAGEMANAGER_LOCALPOOL_TPP_ #ifndef FSFW_STORAGEMANAGER_LOCALPOOL_TPP_
#define FRAMEWORK_STORAGEMANAGER_LOCALPOOL_TPP_ #define FSFW_STORAGEMANAGER_LOCALPOOL_TPP_
#ifndef FRAMEWORK_STORAGEMANAGER_LOCALPOOL_H_ #ifndef FSFW_STORAGEMANAGER_LOCALPOOL_H_
#error Include LocalPool.h before LocalPool.tpp! #error Include LocalPool.h before LocalPool.tpp!
#endif #endif
@ -125,9 +125,10 @@ inline LocalPool<NUMBER_OF_POOLS>::~LocalPool(void) {
} }
} }
template<uint8_t NUMBER_OF_POOLS> inline template<uint8_t NUMBER_OF_POOLS>
ReturnValue_t LocalPool<NUMBER_OF_POOLS>::addData(store_address_t* storageId, inline ReturnValue_t LocalPool<NUMBER_OF_POOLS>::addData(
const uint8_t* data, size_t size, bool ignoreFault) { store_address_t* storageId, const uint8_t* data, size_t size,
bool ignoreFault) {
ReturnValue_t status = reserveSpace(size, storageId, ignoreFault); ReturnValue_t status = reserveSpace(size, storageId, ignoreFault);
if (status == RETURN_OK) { if (status == RETURN_OK) {
write(*storageId, data, size); write(*storageId, data, size);
@ -171,7 +172,7 @@ inline ReturnValue_t LocalPool<NUMBER_OF_POOLS>::getData(store_address_t storeId
template<uint8_t NUMBER_OF_POOLS> template<uint8_t NUMBER_OF_POOLS>
inline ReturnValue_t LocalPool<NUMBER_OF_POOLS>::getData( inline ReturnValue_t LocalPool<NUMBER_OF_POOLS>::getData(
store_address_t packet_id, const uint8_t** packet_ptr, size_t* size) { store_address_t packet_id, const uint8_t** packet_ptr, size_t* size) {
uint8_t* tempData = NULL; uint8_t* tempData = nullptr;
ReturnValue_t status = modifyData(packet_id, &tempData, size); ReturnValue_t status = modifyData(packet_id, &tempData, size);
*packet_ptr = tempData; *packet_ptr = tempData;
return status; return status;
@ -301,4 +302,4 @@ inline ReturnValue_t LocalPool<NUMBER_OF_POOLS>::initialize() {
return RETURN_OK; return RETURN_OK;
} }
#endif #endif /* FSFW_STORAGEMANAGER_LOCALPOOL_TPP_ */

View File

@ -1,9 +1,10 @@
#ifndef FRAMEWORK_STORAGEMANAGER_POOLMANAGER_H_ #ifndef FSFW_STORAGEMANAGER_POOLMANAGER_H_
#define FRAMEWORK_STORAGEMANAGER_POOLMANAGER_H_ #define FSFW_STORAGEMANAGER_POOLMANAGER_H_
#include "../storagemanager/LocalPool.h" #include "LocalPool.h"
#include "StorageAccessor.h"
#include "../ipc/MutexHelper.h" #include "../ipc/MutexHelper.h"
#include "../storagemanager/StorageAccessor.h"
/** /**
* @brief The PoolManager class provides an intermediate data storage with * @brief The PoolManager class provides an intermediate data storage with
@ -19,18 +20,24 @@ public:
const uint16_t element_sizes[NUMBER_OF_POOLS], const uint16_t element_sizes[NUMBER_OF_POOLS],
const uint16_t n_elements[NUMBER_OF_POOLS]); const uint16_t n_elements[NUMBER_OF_POOLS]);
//! @brief In the PoolManager's destructor all allocated memory is freed. /**
* @brief In the PoolManager's destructor all allocated memory
* is freed.
*/
virtual ~PoolManager(); virtual ~PoolManager();
//! @brief LocalPool overrides for thread-safety. Decorator function which /**
//! wraps LocalPool calls with a mutex protection. * @brief LocalPool overrides for thread-safety. Decorator function
* which wraps LocalPool calls with a mutex protection.
*/
ReturnValue_t deleteData(store_address_t) override; ReturnValue_t deleteData(store_address_t) override;
ReturnValue_t deleteData(uint8_t* buffer, size_t size, ReturnValue_t deleteData(uint8_t* buffer, size_t size,
store_address_t* storeId = nullptr) override; store_address_t* storeId = nullptr) override;
void setMutexTimeout(uint32_t mutexTimeoutMs);
protected: protected:
//! Default mutex timeout value to prevent permanent blocking. //! Default mutex timeout value to prevent permanent blocking.
static constexpr uint32_t mutexTimeout = 50; uint32_t mutexTimeoutMs = 20;
ReturnValue_t reserveSpace(const uint32_t size, store_address_t* address, ReturnValue_t reserveSpace(const uint32_t size, store_address_t* address,
bool ignoreFault) override; bool ignoreFault) override;
@ -46,4 +53,4 @@ protected:
#include "PoolManager.tpp" #include "PoolManager.tpp"
#endif /* POOLMANAGER_H_ */ #endif /* FSFW_STORAGEMANAGER_POOLMANAGER_H_ */

View File

@ -1,7 +1,7 @@
#ifndef FRAMEWORK_STORAGEMANAGER_POOLMANAGER_TPP_ #ifndef FRAMEWORK_STORAGEMANAGER_POOLMANAGER_TPP_
#define FRAMEWORK_STORAGEMANAGER_POOLMANAGER_TPP_ #define FRAMEWORK_STORAGEMANAGER_POOLMANAGER_TPP_
#ifndef FRAMEWORK_STORAGEMANAGER_POOLMANAGER_H_ #ifndef FSFW_STORAGEMANAGER_POOLMANAGER_H_
#error Include PoolManager.h before PoolManager.tpp! #error Include PoolManager.h before PoolManager.tpp!
#endif #endif
@ -21,8 +21,7 @@ inline PoolManager<NUMBER_OF_POOLS>::~PoolManager(void) {
template<uint8_t NUMBER_OF_POOLS> template<uint8_t NUMBER_OF_POOLS>
inline ReturnValue_t PoolManager<NUMBER_OF_POOLS>::reserveSpace( inline ReturnValue_t PoolManager<NUMBER_OF_POOLS>::reserveSpace(
const uint32_t size, store_address_t* address, bool ignoreFault) { const uint32_t size, store_address_t* address, bool ignoreFault) {
MutexHelper mutexHelper(mutex, MutexIF::TimeoutType::WAITING, MutexHelper mutexHelper(mutex,MutexIF::WAITING, mutexTimeoutMs);
mutexTimeout);
ReturnValue_t status = LocalPool<NUMBER_OF_POOLS>::reserveSpace(size, ReturnValue_t status = LocalPool<NUMBER_OF_POOLS>::reserveSpace(size,
address,ignoreFault); address,ignoreFault);
return status; return status;
@ -34,8 +33,7 @@ inline ReturnValue_t PoolManager<NUMBER_OF_POOLS>::deleteData(
// debug << "PoolManager( " << translateObject(getObjectId()) << // debug << "PoolManager( " << translateObject(getObjectId()) <<
// " )::deleteData from store " << packet_id.pool_index << // " )::deleteData from store " << packet_id.pool_index <<
// ". id is "<< packet_id.packet_index << std::endl; // ". id is "<< packet_id.packet_index << std::endl;
MutexHelper mutexHelper(mutex, MutexIF::TimeoutType::WAITING, MutexHelper mutexHelper(mutex,MutexIF::WAITING, mutexTimeoutMs);
mutexTimeout);
ReturnValue_t status = LocalPool<NUMBER_OF_POOLS>::deleteData(packet_id); ReturnValue_t status = LocalPool<NUMBER_OF_POOLS>::deleteData(packet_id);
return status; return status;
} }
@ -43,11 +41,16 @@ inline ReturnValue_t PoolManager<NUMBER_OF_POOLS>::deleteData(
template<uint8_t NUMBER_OF_POOLS> template<uint8_t NUMBER_OF_POOLS>
inline ReturnValue_t PoolManager<NUMBER_OF_POOLS>::deleteData(uint8_t* buffer, inline ReturnValue_t PoolManager<NUMBER_OF_POOLS>::deleteData(uint8_t* buffer,
size_t size, store_address_t* storeId) { size_t size, store_address_t* storeId) {
MutexHelper mutexHelper(mutex, MutexIF::TimeoutType::WAITING, MutexHelper mutexHelper(mutex,MutexIF::WAITING, mutexTimeoutMs);
mutexTimeout);
ReturnValue_t status = LocalPool<NUMBER_OF_POOLS>::deleteData(buffer, ReturnValue_t status = LocalPool<NUMBER_OF_POOLS>::deleteData(buffer,
size, storeId); size, storeId);
return status; return status;
} }
#endif template<uint8_t NUMBER_OF_POOLS>
inline void PoolManager<NUMBER_OF_POOLS>::setMutexTimeout(
uint32_t mutexTimeoutMs) {
this->mutexTimeout = mutexTimeoutMs;
}
#endif /* FRAMEWORK_STORAGEMANAGER_POOLMANAGER_TPP_ */

View File

@ -1,5 +1,5 @@
#include "../storagemanager/StorageAccessor.h" #include "StorageAccessor.h"
#include "../storagemanager/StorageManagerIF.h" #include "StorageManagerIF.h"
#include "../serviceinterface/ServiceInterfaceStream.h" #include "../serviceinterface/ServiceInterfaceStream.h"
StorageAccessor::StorageAccessor(store_address_t storeId): StorageAccessor::StorageAccessor(store_address_t storeId):

View File

@ -1,7 +1,7 @@
#ifndef FRAMEWORK_STORAGEMANAGER_STORAGEACCESSOR_H_ #ifndef FSFW_STORAGEMANAGER_STORAGEACCESSOR_H_
#define FRAMEWORK_STORAGEMANAGER_STORAGEACCESSOR_H_ #define FSFW_STORAGEMANAGER_STORAGEACCESSOR_H_
#include "../storagemanager/ConstStorageAccessor.h" #include "ConstStorageAccessor.h"
class StorageManagerIF; class StorageManagerIF;
@ -42,4 +42,4 @@ private:
void assignConstPointer(); void assignConstPointer();
}; };
#endif /* TEST_PROTOTYPES_STORAGEACCESSOR_H_ */ #endif /* FSFW_STORAGEMANAGER_STORAGEACCESSOR_H_ */

View File

@ -1,10 +1,12 @@
#ifndef STORAGEMANAGERIF_H_H #ifndef FSFW_STORAGEMANAGER_STORAGEMANAGERIF_H_
#define STORAGEMANAGERIF_H_H #define FSFW_STORAGEMANAGER_STORAGEMANAGERIF_H_
#include "StorageAccessor.h"
#include "storeAddress.h"
#include "../events/Event.h" #include "../events/Event.h"
#include "../returnvalues/HasReturnvaluesIF.h" #include "../returnvalues/HasReturnvaluesIF.h"
#include "../storagemanager/StorageAccessor.h"
#include "../storagemanager/storeAddress.h"
#include <utility> #include <utility>
#include <cstddef> #include <cstddef>
@ -164,4 +166,4 @@ public:
virtual void clearStore() = 0; virtual void clearStore() = 0;
}; };
#endif /* STORAGEMANAGERIF_H_ */ #endif /* FSFW_STORAGEMANAGER_STORAGEMANAGERIF_H_ */