SerialBufferAdapter can process uint32_t * buffers now

This commit is contained in:
Robin Müller 2019-12-01 17:48:05 +01:00
parent 10c24e39a3
commit 37a70df244
4 changed files with 44 additions and 11 deletions

View File

@ -29,7 +29,7 @@
* \brief This class represents the OBSW global data-pool. * \brief This class represents the OBSW global data-pool.
* *
* \details All variables are registered and space is allocated in an initialization * \details All variables are registered and space is allocated in an initialization
* function, which is passed do the constructor. * function, which is passed to the constructor.
* Space for the variables is allocated on the heap (with a new call). * Space for the variables is allocated on the heap (with a new call).
* The data is found by a data pool id, which uniquely represents a variable. * The data is found by a data pool id, which uniquely represents a variable.
* Data pool variables should be used with a blackboard logic in mind, * Data pool variables should be used with a blackboard logic in mind,

View File

@ -8,10 +8,9 @@
InternalErrorReporter::InternalErrorReporter(object_id_t setObjectId, InternalErrorReporter::InternalErrorReporter(object_id_t setObjectId,
uint32_t queuePoolId, uint32_t tmPoolId, uint32_t storePoolId) : uint32_t queuePoolId, uint32_t tmPoolId, uint32_t storePoolId) :
SystemObject(setObjectId), mutex(NULL), queuePoolId(queuePoolId), tmPoolId( SystemObject(setObjectId), mutex(NULL), queuePoolId(queuePoolId),
tmPoolId), storePoolId( tmPoolId(tmPoolId),storePoolId(storePoolId), queueHits(0), tmHits(0),
storePoolId), queueHits(0), tmHits(0), storeHits( storeHits(0) {
0) {
mutex = MutexFactory::instance()->createMutex(); mutex = MutexFactory::instance()->createMutex();
} }

View File

@ -1,8 +1,6 @@
#include <framework/serialize/SerialBufferAdapter.h> #include <framework/serialize/SerialBufferAdapter.h>
#include <cstring> #include <cstring>
template<typename T> template<typename T>
SerialBufferAdapter<T>::SerialBufferAdapter(const uint8_t* buffer, SerialBufferAdapter<T>::SerialBufferAdapter(const uint8_t* buffer,
T bufferLength, bool serializeLength) : T bufferLength, bool serializeLength) :
@ -17,6 +15,13 @@ SerialBufferAdapter<T>::SerialBufferAdapter(uint8_t* buffer, T bufferLength,
bufferLength) { bufferLength) {
} }
template<typename T>
SerialBufferAdapter<T>::SerialBufferAdapter(uint32_t* buffer,
T bufferLength, bool serializeLength) :
serializeLength(serializeLength), constBuffer(NULL), buffer(reinterpret_cast<uint8_t *>(buffer)),
bufferLength(bufferLength*4) {
}
template<typename T> template<typename T>
SerialBufferAdapter<T>::~SerialBufferAdapter() { SerialBufferAdapter<T>::~SerialBufferAdapter() {
} }
@ -86,6 +91,10 @@ ReturnValue_t SerialBufferAdapter<T>::deSerialize(const uint8_t** buffer,
} }
} }
template<typename T>
uint8_t * SerialBufferAdapter<T>::getBuffer() {
return buffer;
}
//forward Template declaration for linker //forward Template declaration for linker
template class SerialBufferAdapter<uint8_t>; template class SerialBufferAdapter<uint8_t>;

View File

@ -11,16 +11,39 @@
* Additionally, the buffer length can be serialized too and will be put in front of the serialized buffer. * Additionally, the buffer length can be serialized too and will be put in front of the serialized buffer.
* *
* Can be used with SerialLinkedListAdapter by declaring a SerializeElement with * Can be used with SerialLinkedListAdapter by declaring a SerializeElement with
* SerialElement<SerialBufferAdapter<T(will be uint8_t mostly)>> serialBufferElement * SerialElement<SerialBufferAdapter<bufferLengthType(will be uint8_t mostly)>> serialBufferElement
* *
* \ingroup serialize * \ingroup serialize
*/ */
template<typename T> template<typename T>
class SerialBufferAdapter: public SerializeIF { class SerialBufferAdapter: public SerializeIF {
public: public:
SerialBufferAdapter(const uint8_t * buffer, T bufferLength, bool serializeLenght = false); /**
SerialBufferAdapter(uint8_t* buffer, T bufferLength, * Constructor for constant uint8_t buffer. Length field can be serialized optionally.
bool serializeLenght = false); * Type of length can be supplied as template type.
* @param buffer
* @param bufferLength
* @param serializeLength
*/
SerialBufferAdapter(const uint8_t * buffer, T bufferLength, bool serializeLength = false);
/**
* Constructoor for non-constant uint8_t buffer. Length field can be serialized optionally.
* Type of length can be supplied as template type.
* @param buffer
* @param bufferLength
* @param serializeLength
*/
SerialBufferAdapter(uint8_t* buffer, T bufferLength, bool serializeLength = false);
/**
* Constructoor for non-constant uint32_t buffer. Length field can be serialized optionally.
* Type of length can be supplied as template type.
* @param buffer
* @param bufferLength
* @param serializeLength
*/
SerialBufferAdapter(uint32_t* buffer,T bufferLength, bool serializeLength = false);
virtual ~SerialBufferAdapter(); virtual ~SerialBufferAdapter();
@ -31,6 +54,8 @@ public:
virtual ReturnValue_t deSerialize(const uint8_t** buffer, int32_t* size, virtual ReturnValue_t deSerialize(const uint8_t** buffer, int32_t* size,
bool bigEndian); bool bigEndian);
uint8_t * getBuffer();
private: private:
bool serializeLength; bool serializeLength;
const uint8_t *constBuffer; const uint8_t *constBuffer;