Merge remote-tracking branch 'origin/feature_EndianSwapper_UINT32_BUFFER_PoolRawAccess_Modification_For_Vectors' into mueller_framework
This commit is contained in:
commit
6abb3cc525
@ -5,13 +5,27 @@
|
|||||||
#include <framework/osal/Endiness.h>
|
#include <framework/osal/Endiness.h>
|
||||||
|
|
||||||
PoolRawAccess::PoolRawAccess(uint32_t set_id, uint8_t setArrayEntry,
|
PoolRawAccess::PoolRawAccess(uint32_t set_id, uint8_t setArrayEntry,
|
||||||
DataSetIF* data_set, ReadWriteMode_t setReadWriteMode) :
|
DataSetIF* data_set, ReadWriteMode_t setReadWriteMode,
|
||||||
|
bool registerVectors) :
|
||||||
dataPoolId(set_id), arrayEntry(setArrayEntry), valid(false), type(Type::UNKNOWN_TYPE), typeSize(
|
dataPoolId(set_id), arrayEntry(setArrayEntry), valid(false), type(Type::UNKNOWN_TYPE), typeSize(
|
||||||
0), arraySize(0), sizeTillEnd(0), readWriteMode(setReadWriteMode) {
|
0), arraySize(0), sizeTillEnd(0), readWriteMode(setReadWriteMode) {
|
||||||
memset(value, 0, sizeof(value));
|
memset(value, 0, sizeof(value));
|
||||||
if (data_set != NULL) {
|
if (data_set != NULL) {
|
||||||
data_set->registerVariable(this);
|
data_set->registerVariable(this);
|
||||||
}
|
}
|
||||||
|
if(registerVectors == true) {
|
||||||
|
this->read();
|
||||||
|
if(arraySize > 1) {
|
||||||
|
for(uint16_t vectorCount = typeSize;vectorCount < arraySize;vectorCount += typeSize)
|
||||||
|
{
|
||||||
|
PoolRawAccess * newPoolRawAccess =
|
||||||
|
new PoolRawAccess(set_id, setArrayEntry + typeSize,
|
||||||
|
data_set,setReadWriteMode,true);
|
||||||
|
if(newPoolRawAccess) {};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PoolRawAccess::~PoolRawAccess() {
|
PoolRawAccess::~PoolRawAccess() {
|
||||||
@ -31,9 +45,10 @@ ReturnValue_t PoolRawAccess::read() {
|
|||||||
sizeTillEnd = read_out->getByteSize() - arrayPosition;
|
sizeTillEnd = read_out->getByteSize() - arrayPosition;
|
||||||
uint8_t* ptr =
|
uint8_t* ptr =
|
||||||
&((uint8_t*) read_out->getRawData())[arrayPosition];
|
&((uint8_t*) read_out->getRawData())[arrayPosition];
|
||||||
for(uint8_t arrayCount = 0; arrayCount < arraySize; arrayCount++) {
|
memcpy(value, ptr, typeSize);
|
||||||
memcpy(value + typeSize * arrayCount, ptr + typeSize * arrayCount, typeSize);
|
//for(uint8_t arrayCount = 0; arrayCount < arraySize; arrayCount++) {
|
||||||
}
|
// memcpy(value + typeSize * arrayCount, ptr + typeSize * arrayCount, typeSize);
|
||||||
|
//}
|
||||||
|
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
} else {
|
} else {
|
||||||
@ -155,20 +170,25 @@ ReturnValue_t PoolRawAccess::serialize(uint8_t** buffer, uint32_t* size,
|
|||||||
#ifndef BYTE_ORDER_SYSTEM
|
#ifndef BYTE_ORDER_SYSTEM
|
||||||
#error BYTE_ORDER_SYSTEM not defined
|
#error BYTE_ORDER_SYSTEM not defined
|
||||||
#elif BYTE_ORDER_SYSTEM == LITTLE_ENDIAN
|
#elif BYTE_ORDER_SYSTEM == LITTLE_ENDIAN
|
||||||
for(uint8_t arrayCount = 0; arrayCount < arraySize; arrayCount++) {
|
for (uint8_t count = 0; count < typeSize; count++) {
|
||||||
for (uint8_t count = 0; count < typeSize; count++) {
|
(*buffer)[count] = value[typeSize - count - 1];
|
||||||
(*buffer)[typeSize * (arrayCount + 1) - count - 1] =
|
|
||||||
value[typeSize * arrayCount + count];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
//for(uint8_t arrayCount = 0; arrayCount < arraySize; arrayCount++) {
|
||||||
|
// for (uint8_t count = 0; count < typeSize; count++) {
|
||||||
|
// (*buffer)[typeSize * (arrayCount + 1) - count - 1] =
|
||||||
|
// value[typeSize * arrayCount + count];
|
||||||
|
// }
|
||||||
|
//}
|
||||||
#elif BYTE_ORDER_SYSTEM == BIG_ENDIAN
|
#elif BYTE_ORDER_SYSTEM == BIG_ENDIAN
|
||||||
memcpy(*buffer, value, typeSize * arraySize);
|
memcpy(*buffer, value, typeSize);
|
||||||
|
//memcpy(*buffer, value, typeSize * arraySize);
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
memcpy(*buffer, value, typeSize * arraySize);
|
memcpy(*buffer, value, typeSize);
|
||||||
|
//memcpy(*buffer, value, typeSize * arraySize);
|
||||||
}
|
}
|
||||||
*size += typeSize * arraySize;
|
*size += typeSize;// * arraySize;
|
||||||
(*buffer) += typeSize * arraySize;
|
(*buffer) += typeSize;// * arraySize;
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
} else {
|
} else {
|
||||||
return SerializeIF::BUFFER_TOO_SHORT;
|
return SerializeIF::BUFFER_TOO_SHORT;
|
||||||
|
@ -6,10 +6,14 @@
|
|||||||
#include <framework/globalfunctions/Type.h>
|
#include <framework/globalfunctions/Type.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class allows accessing Data Pool variables as raw bytes.
|
* @brief This class allows accessing Data Pool variables as raw bytes.
|
||||||
|
* @details
|
||||||
* This is necessary to have an access method for HK data, as the PID's alone do not
|
* This is necessary to have an access method for HK data, as the PID's alone do not
|
||||||
* provide a type information.
|
* provide a type information. Please note that the the raw pool access read() and commit()
|
||||||
* \ingroup data_pool
|
* calls are not thread-safe and therefore private.
|
||||||
|
* Please supply a data set and use the data set read(), commit() calls for thread-safe
|
||||||
|
* data pool access.
|
||||||
|
* @ingroup data_pool
|
||||||
*/
|
*/
|
||||||
class PoolRawAccess: public PoolVariableIF {
|
class PoolRawAccess: public PoolVariableIF {
|
||||||
private:
|
private:
|
||||||
@ -48,6 +52,18 @@ private:
|
|||||||
ReadWriteMode_t readWriteMode;
|
ReadWriteMode_t readWriteMode;
|
||||||
static const uint8_t RAW_MAX_SIZE = sizeof(double);
|
static const uint8_t RAW_MAX_SIZE = sizeof(double);
|
||||||
protected:
|
protected:
|
||||||
|
/**
|
||||||
|
* \brief This is a call to read the value from the global data pool.
|
||||||
|
* \details When executed, this operation tries to fetch the pool entry with matching
|
||||||
|
* data pool id from the global data pool and copies the value and the valid
|
||||||
|
* information to its local attributes. In case of a failure (wrong type or
|
||||||
|
* pool id not found), the variable is set to zero and invalid.
|
||||||
|
* The operation does NOT provide any mutual exclusive protection by itself !
|
||||||
|
* If reading from the data pool without information about the type is desired,
|
||||||
|
* initialize the raw pool access by supplying a data set and using the data set
|
||||||
|
* read function, which calls this read function.
|
||||||
|
*/
|
||||||
|
ReturnValue_t read();
|
||||||
/**
|
/**
|
||||||
* \brief The commit call writes back the variable's value to the data pool.
|
* \brief The commit call writes back the variable's value to the data pool.
|
||||||
* \details It checks type and size, as well as if the variable is writable. If so,
|
* \details It checks type and size, as well as if the variable is writable. If so,
|
||||||
@ -62,23 +78,25 @@ public:
|
|||||||
static const ReturnValue_t INCORRECT_SIZE = MAKE_RETURN_CODE(0x01);
|
static const ReturnValue_t INCORRECT_SIZE = MAKE_RETURN_CODE(0x01);
|
||||||
static const ReturnValue_t DATA_POOL_ACCESS_FAILED = MAKE_RETURN_CODE(0x02);
|
static const ReturnValue_t DATA_POOL_ACCESS_FAILED = MAKE_RETURN_CODE(0x02);
|
||||||
uint8_t value[RAW_MAX_SIZE];
|
uint8_t value[RAW_MAX_SIZE];
|
||||||
|
//uint8_t value[RAW_MAX_SIZE*3];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This constructor is used to access a data pool entry with a
|
||||||
|
* given ID if the target type is not known. A DataSet object is supplied
|
||||||
|
* and the data pool entry with the given ID is registered to that data set
|
||||||
|
* @param data_pool_id Target data pool entry ID
|
||||||
|
* @param arrayEntry
|
||||||
|
* @param data_set Dataset to register data pool entry to
|
||||||
|
* @param setReadWriteMode
|
||||||
|
*/
|
||||||
PoolRawAccess(uint32_t data_pool_id, uint8_t arrayEntry,
|
PoolRawAccess(uint32_t data_pool_id, uint8_t arrayEntry,
|
||||||
DataSetIF* data_set, ReadWriteMode_t setReadWriteMode =
|
DataSetIF* data_set, ReadWriteMode_t setReadWriteMode =
|
||||||
PoolVariableIF::VAR_READ);
|
PoolVariableIF::VAR_READ,bool registerVectors = false);
|
||||||
/**
|
/**
|
||||||
* \brief The classes destructor is empty. If commit() was not called, the local value is
|
* \brief The classes destructor is empty. If commit() was not called, the local value is
|
||||||
* discarded and not written back to the data pool.
|
* discarded and not written back to the data pool.
|
||||||
*/
|
*/
|
||||||
~PoolRawAccess();
|
~PoolRawAccess();
|
||||||
/**
|
|
||||||
* \brief This is a call to read the value from the global data pool.
|
|
||||||
* \details When executed, this operation tries to fetch the pool entry with matching
|
|
||||||
* data pool id from the global data pool and copies the value and the valid
|
|
||||||
* information to its local attributes. In case of a failure (wrong type or
|
|
||||||
* pool id not found), the variable is set to zero and invalid.
|
|
||||||
* The operation does NOT provide any mutual exclusive protection by itself.
|
|
||||||
*/
|
|
||||||
ReturnValue_t read();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Serialize raw pool entry into provided buffer directly
|
* @brief Serialize raw pool entry into provided buffer directly
|
||||||
|
Loading…
Reference in New Issue
Block a user