Pool Raw Access Helper serialization of vectors implemented
This commit is contained in:
parent
666341d03d
commit
2425685e44
@ -19,11 +19,12 @@ PoolRawAccessHelper::~PoolRawAccessHelper() {
|
|||||||
|
|
||||||
ReturnValue_t PoolRawAccessHelper::serialize(uint8_t **buffer, uint32_t *size,
|
ReturnValue_t PoolRawAccessHelper::serialize(uint8_t **buffer, uint32_t *size,
|
||||||
const uint32_t max_size, bool bigEndian) {
|
const uint32_t max_size, bool bigEndian) {
|
||||||
|
SerializationArgs serializationArgs = {buffer, size, max_size, bigEndian};
|
||||||
ReturnValue_t result;
|
ReturnValue_t result;
|
||||||
int32_t remainingParametersSize = numberOfParameters * 4;
|
int32_t remainingParametersSize = numberOfParameters * 4;
|
||||||
for(uint8_t count=0; count < numberOfParameters; count++) {
|
for(uint8_t count=0; count < numberOfParameters; count++) {
|
||||||
result = serializeCurrentPoolEntryIntoBuffer(buffer,
|
result = serializeCurrentPoolEntryIntoBuffer(serializationArgs,
|
||||||
&remainingParametersSize,size,max_size, bigEndian, false);
|
&remainingParametersSize, false);
|
||||||
if(result != RETURN_OK) {
|
if(result != RETURN_OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -35,16 +36,17 @@ ReturnValue_t PoolRawAccessHelper::serialize(uint8_t **buffer, uint32_t *size,
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t PoolRawAccessHelper::serializeWithValidityMask(uint8_t **buffer,
|
ReturnValue_t PoolRawAccessHelper::serializeWithValidityMask(uint8_t ** buffer, uint32_t * size,
|
||||||
uint32_t *size, const uint32_t max_size, bool bigEndian) {
|
const uint32_t max_size, bool bigEndian) {
|
||||||
ReturnValue_t result;
|
ReturnValue_t result;
|
||||||
|
SerializationArgs argStruct = {buffer, size, max_size, bigEndian};
|
||||||
int32_t remainingParametersSize = numberOfParameters * 4;
|
int32_t remainingParametersSize = numberOfParameters * 4;
|
||||||
uint8_t validityMaskSize = numberOfParameters/8;
|
uint8_t validityMaskSize = numberOfParameters/8;
|
||||||
uint8_t validityMask[validityMaskSize];
|
uint8_t validityMask[validityMaskSize];
|
||||||
memset(validityMask,0, validityMaskSize);
|
memset(validityMask,0, validityMaskSize);
|
||||||
for(uint8_t count = 0; count < numberOfParameters; count++) {
|
for(uint8_t count = 0; count < numberOfParameters; count++) {
|
||||||
result = serializeCurrentPoolEntryIntoBuffer(buffer,
|
result = serializeCurrentPoolEntryIntoBuffer(argStruct,
|
||||||
&remainingParametersSize,size,max_size, bigEndian,true,validityMask);
|
&remainingParametersSize,true,validityMask);
|
||||||
if (result != RETURN_OK) {
|
if (result != RETURN_OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -60,11 +62,9 @@ ReturnValue_t PoolRawAccessHelper::serializeWithValidityMask(uint8_t **buffer,
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t PoolRawAccessHelper::serializeCurrentPoolEntryIntoBuffer(uint8_t ** buffer,
|
ReturnValue_t PoolRawAccessHelper::serializeCurrentPoolEntryIntoBuffer(SerializationArgs argStruct,
|
||||||
int32_t * remainingParameters, uint32_t * hkDataSize,
|
int32_t * remainingParameters, bool withValidMask, uint8_t * validityMask) {
|
||||||
const uint32_t max_size, bool bigEndian, bool withValidMask, uint8_t * validityMask) {
|
|
||||||
uint32_t currentPoolId;
|
uint32_t currentPoolId;
|
||||||
DataSet currentDataSet = DataSet();
|
|
||||||
// Deserialize current pool ID from pool ID buffer
|
// Deserialize current pool ID from pool ID buffer
|
||||||
ReturnValue_t result = AutoSerializeAdapter::deSerialize(¤tPoolId,
|
ReturnValue_t result = AutoSerializeAdapter::deSerialize(¤tPoolId,
|
||||||
&poolIdBuffer,remainingParameters,true);
|
&poolIdBuffer,remainingParameters,true);
|
||||||
@ -72,13 +72,52 @@ ReturnValue_t PoolRawAccessHelper::serializeCurrentPoolEntryIntoBuffer(uint8_t *
|
|||||||
debug << std::hex << "Pool Raw Access Helper: Error deSeralizing pool IDs" << std::dec << std::endl;
|
debug << std::hex << "Pool Raw Access Helper: Error deSeralizing pool IDs" << std::dec << std::endl;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
result = handlePoolEntrySerialization(currentPoolId, argStruct, withValidMask, validityMask);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
// info << "Pool Raw Access Helper: Handling Pool ID: " << std::hex << currentPoolId << std::endl;
|
ReturnValue_t PoolRawAccessHelper::handlePoolEntrySerialization(uint32_t currentPoolId,SerializationArgs argStruct,
|
||||||
PoolRawAccess currentPoolRawAccess(currentPoolId,0,¤tDataSet,PoolVariableIF::VAR_READ);
|
bool withValidMask, uint8_t * validityMask) {
|
||||||
|
ReturnValue_t result;
|
||||||
|
uint8_t arrayPosition = 0;
|
||||||
|
bool poolEntrySerialized = false;
|
||||||
|
info << "Pool Raw Access Helper: Handling Pool ID: " << std::hex << currentPoolId << std::endl;
|
||||||
|
while(not poolEntrySerialized) {
|
||||||
|
DataSet currentDataSet = DataSet();
|
||||||
|
PoolRawAccess currentPoolRawAccess(currentPoolId,arrayPosition,¤tDataSet,PoolVariableIF::VAR_READ);
|
||||||
|
result = currentDataSet.read();
|
||||||
|
if (result != RETURN_OK) {
|
||||||
|
debug << std::hex << "Pool Raw Access Helper: Error reading raw dataset" << std::dec << std::endl;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
uint8_t remainingSize = currentPoolRawAccess.getSizeTillEnd() - currentPoolRawAccess.getSizeOfType();
|
||||||
|
if(remainingSize == 0) {
|
||||||
|
poolEntrySerialized = true;
|
||||||
|
}
|
||||||
|
else if(remainingSize > 0) {
|
||||||
|
arrayPosition += currentPoolRawAccess.getSizeOfType() / 8;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
error << "Pool Raw Access Helper: Configuration Error. Size till end smaller than 0" << std::endl;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
// set valid mask bit if necessary
|
// set valid mask bit if necessary
|
||||||
if(withValidMask) {
|
if(withValidMask) {
|
||||||
if(currentPoolRawAccess.isValid()) {
|
if(currentPoolRawAccess.isValid()) {
|
||||||
|
handleMaskModification(validityMask);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
result = currentDataSet.serialize(argStruct.buffer, argStruct.size,
|
||||||
|
argStruct.max_size, argStruct.bigEndian);
|
||||||
|
if (result != RETURN_OK) {
|
||||||
|
debug << "Pool Raw Access Helper: Error serializing pool data into send buffer" << std::endl;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PoolRawAccessHelper::handleMaskModification(uint8_t * validityMask) {
|
||||||
validityMask[validBufferIndex] =
|
validityMask[validBufferIndex] =
|
||||||
bitSetter(validityMask[validBufferIndex], validBufferIndexBit, true);
|
bitSetter(validityMask[validBufferIndex], validBufferIndexBit, true);
|
||||||
validBufferIndexBit ++;
|
validBufferIndexBit ++;
|
||||||
@ -87,20 +126,6 @@ ReturnValue_t PoolRawAccessHelper::serializeCurrentPoolEntryIntoBuffer(uint8_t *
|
|||||||
validBufferIndexBit = 1;
|
validBufferIndexBit = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
result = currentDataSet.read();
|
|
||||||
if (result != RETURN_OK) {
|
|
||||||
debug << std::hex << "Pool Raw Access Helper: Error read raw dataset" << std::dec << std::endl;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
result = currentDataSet.serialize(buffer, hkDataSize,
|
|
||||||
max_size, bigEndian);
|
|
||||||
if (result != RETURN_OK) {
|
|
||||||
debug << "Pool Raw Access Helper: Error serializing pool data into send buffer" << std::endl;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t PoolRawAccessHelper::bitSetter(uint8_t byte, uint8_t position, bool value) {
|
uint8_t PoolRawAccessHelper::bitSetter(uint8_t byte, uint8_t position, bool value) {
|
||||||
if(position < 1 or position > 8) {
|
if(position < 1 or position > 8) {
|
||||||
|
@ -66,6 +66,12 @@ private:
|
|||||||
uint8_t validBufferIndex;
|
uint8_t validBufferIndex;
|
||||||
uint8_t validBufferIndexBit;
|
uint8_t validBufferIndexBit;
|
||||||
|
|
||||||
|
struct SerializationArgs {
|
||||||
|
uint8_t ** buffer;
|
||||||
|
uint32_t * size;
|
||||||
|
const uint32_t max_size;
|
||||||
|
bool bigEndian;
|
||||||
|
};
|
||||||
/**
|
/**
|
||||||
* Helper function to serialize single pool entries
|
* Helper function to serialize single pool entries
|
||||||
* @param pPoolIdBuffer
|
* @param pPoolIdBuffer
|
||||||
@ -78,10 +84,13 @@ private:
|
|||||||
* @param validityMask Can be supplied and will be set if @c withValidMask is set to true
|
* @param validityMask Can be supplied and will be set if @c withValidMask is set to true
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
ReturnValue_t serializeCurrentPoolEntryIntoBuffer(uint8_t ** buffer,
|
ReturnValue_t serializeCurrentPoolEntryIntoBuffer(SerializationArgs argStruct,
|
||||||
int32_t * remainingParameters, uint32_t * hkDataSize,const uint32_t max_size,
|
int32_t * remainingParameters, bool withValidMask = false, uint8_t * validityMask = NULL);
|
||||||
bool bigEndian, bool withValidMask = false, uint8_t * validityMask = NULL);
|
|
||||||
|
|
||||||
|
ReturnValue_t handlePoolEntrySerialization(uint32_t currentPoolId,SerializationArgs argStruct,
|
||||||
|
bool withValidMask = false, uint8_t * validityMask = NULL);
|
||||||
|
|
||||||
|
void handleMaskModification(uint8_t * validityMask);
|
||||||
/**
|
/**
|
||||||
* Sets specific bit of a byte
|
* Sets specific bit of a byte
|
||||||
* @param byte
|
* @param byte
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
* buffers with a header containing the buffer length.
|
* buffers with a header containing the buffer length.
|
||||||
* @details
|
* @details
|
||||||
* Can be used by SerialLinkedListAdapter by using this type in
|
* Can be used by SerialLinkedListAdapter by using this type in
|
||||||
* SerializeElement<>
|
* SerializeElement<>.
|
||||||
* Buffers with a size header inside that class can be declared with
|
* Buffers with a size header inside that class can be declared with
|
||||||
* SerialFixedArrayListAdapter<bufferType,MAX_BUFFER_LENGTH,typeOfMaxData>.
|
* SerialFixedArrayListAdapter<bufferType,MAX_BUFFER_LENGTH,typeOfMaxData>.
|
||||||
* typeOfMaxData specifies the data type of the buffer header containing the buffer size that follows
|
* typeOfMaxData specifies the data type of the buffer header containing the buffer size that follows
|
||||||
|
Loading…
Reference in New Issue
Block a user