important bugfix (endianness)
Using size_t now.
This commit is contained in:
parent
a37f007f06
commit
48320cc8ee
|
@ -24,8 +24,8 @@ PoolRawAccessHelper::~PoolRawAccessHelper() {
|
|||
ReturnValue_t PoolRawAccessHelper::serialize(uint8_t **buffer, size_t *size,
|
||||
const size_t max_size, bool bigEndian) {
|
||||
SerializationArgs serializationArgs = {buffer, size, max_size, bigEndian};
|
||||
ReturnValue_t result;
|
||||
ssize_t remainingParametersSize = numberOfParameters * 4;
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
size_t remainingParametersSize = numberOfParameters * 4;
|
||||
for(uint8_t count=0; count < numberOfParameters; count++) {
|
||||
result = serializeCurrentPoolEntryIntoBuffer(serializationArgs,
|
||||
&remainingParametersSize, false);
|
||||
|
@ -34,7 +34,8 @@ ReturnValue_t PoolRawAccessHelper::serialize(uint8_t **buffer, size_t *size,
|
|||
}
|
||||
}
|
||||
if(remainingParametersSize != 0) {
|
||||
debug << "Pool Raw Access: Remaining parameters size not 0 !" << std::endl;
|
||||
sif::debug << "PoolRawAccessHelper: "
|
||||
"Remaining parameters size not 0 !" << std::endl;
|
||||
result = RETURN_FAILED;
|
||||
}
|
||||
return result;
|
||||
|
@ -42,9 +43,9 @@ ReturnValue_t PoolRawAccessHelper::serialize(uint8_t **buffer, size_t *size,
|
|||
|
||||
ReturnValue_t PoolRawAccessHelper::serializeWithValidityMask(uint8_t ** buffer,
|
||||
size_t * size, const size_t max_size, bool bigEndian) {
|
||||
ReturnValue_t result;
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
SerializationArgs argStruct = {buffer, size, max_size, bigEndian};
|
||||
ssize_t remainingParametersSize = numberOfParameters * 4;
|
||||
size_t remainingParametersSize = numberOfParameters * 4;
|
||||
uint8_t validityMaskSize = ceil((float)numberOfParameters/8.0);
|
||||
uint8_t validityMask[validityMaskSize];
|
||||
memset(validityMask,0, validityMaskSize);
|
||||
|
@ -56,7 +57,8 @@ ReturnValue_t PoolRawAccessHelper::serializeWithValidityMask(uint8_t ** buffer,
|
|||
}
|
||||
}
|
||||
if(remainingParametersSize != 0) {
|
||||
debug << "Pool Raw Access: Remaining parameters size not 0 !" << std::endl;
|
||||
sif::debug << "PoolRawAccessHelper: Remaining "
|
||||
"parameters size not 0 !" << std::endl;
|
||||
result = RETURN_FAILED;
|
||||
}
|
||||
|
||||
|
@ -67,49 +69,59 @@ ReturnValue_t PoolRawAccessHelper::serializeWithValidityMask(uint8_t ** buffer,
|
|||
return result;
|
||||
}
|
||||
|
||||
ReturnValue_t PoolRawAccessHelper::serializeCurrentPoolEntryIntoBuffer(SerializationArgs argStruct,
|
||||
ssize_t * remainingParameters, bool withValidMask, uint8_t * validityMask) {
|
||||
ReturnValue_t PoolRawAccessHelper::serializeCurrentPoolEntryIntoBuffer(
|
||||
SerializationArgs argStruct, size_t * remainingParameters,
|
||||
bool withValidMask, uint8_t * validityMask) {
|
||||
uint32_t currentPoolId;
|
||||
// Deserialize current pool ID from pool ID buffer
|
||||
ReturnValue_t result = AutoSerializeAdapter::deSerialize(¤tPoolId,
|
||||
&poolIdBuffer,remainingParameters,true);
|
||||
&poolIdBuffer,remainingParameters, false);
|
||||
if(result != RETURN_OK) {
|
||||
debug << std::hex << "Pool Raw Access Helper: Error deSeralizing pool IDs" << std::dec << std::endl;
|
||||
sif::debug << std::hex << "PoolRawAccessHelper: Error deSeralizing "
|
||||
"pool IDs" << std::dec << std::endl;
|
||||
return result;
|
||||
}
|
||||
result = handlePoolEntrySerialization(currentPoolId, argStruct, withValidMask, validityMask);
|
||||
result = handlePoolEntrySerialization(currentPoolId, argStruct,
|
||||
withValidMask, validityMask);
|
||||
return result;
|
||||
}
|
||||
|
||||
ReturnValue_t PoolRawAccessHelper::handlePoolEntrySerialization(uint32_t currentPoolId,SerializationArgs argStruct,
|
||||
bool withValidMask, uint8_t * validityMask) {
|
||||
ReturnValue_t PoolRawAccessHelper::handlePoolEntrySerialization(
|
||||
uint32_t currentPoolId,SerializationArgs argStruct, bool withValidMask,
|
||||
uint8_t * validityMask) {
|
||||
ReturnValue_t result = RETURN_FAILED;
|
||||
uint8_t arrayPosition = 0;
|
||||
uint8_t counter = 0;
|
||||
bool poolEntrySerialized = false;
|
||||
//debug << "Pool Raw Access Helper: Handling Pool ID: " << std::hex << currentPoolId << std::endl;
|
||||
//debug << "Pool Raw Access Helper: Handling Pool ID: "
|
||||
// << std::hex << currentPoolId << std::endl;
|
||||
while(not poolEntrySerialized) {
|
||||
|
||||
if(counter > DataSet::DATA_SET_MAX_SIZE) {
|
||||
error << "Pool Raw Access Helper: Config error, max. number of possible data set variables exceeded" << std::endl;
|
||||
sif::error << "PoolRawAccessHelper: Config error, "
|
||||
"max. number of possible data set variables exceeded"
|
||||
<< std::endl;
|
||||
return result;
|
||||
}
|
||||
counter ++;
|
||||
|
||||
DataSet currentDataSet = DataSet();
|
||||
//debug << "Current array position: " << (int)arrayPosition << std::endl;
|
||||
PoolRawAccess currentPoolRawAccess(currentPoolId,arrayPosition,¤tDataSet,PoolVariableIF::VAR_READ);
|
||||
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 with returncode 0x"
|
||||
<< result << std::dec << std::endl;
|
||||
sif::debug << std::hex << "PoolRawAccessHelper: Error reading raw "
|
||||
"dataset with returncode 0x" << result << std::dec << std::endl;
|
||||
return result;
|
||||
}
|
||||
|
||||
result = checkRemainingSize(¤tPoolRawAccess, &poolEntrySerialized, &arrayPosition);
|
||||
result = checkRemainingSize(¤tPoolRawAccess, &poolEntrySerialized,
|
||||
&arrayPosition);
|
||||
if(result != RETURN_OK) {
|
||||
error << "Pool Raw Access Helper: Configuration Error at pool ID " << std::hex << currentPoolId
|
||||
sif::error << "Pool Raw Access Helper: Configuration Error at pool ID "
|
||||
<< std::hex << currentPoolId
|
||||
<< ". Size till end smaller than 0" << std::dec << std::endl;
|
||||
return result;
|
||||
}
|
||||
|
@ -125,8 +137,9 @@ ReturnValue_t PoolRawAccessHelper::handlePoolEntrySerialization(uint32_t current
|
|||
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 with ID 0x" << std::hex <<
|
||||
currentPoolId << " into send buffer with return code " << result << std::dec << std::endl;
|
||||
sif::debug << "Pool Raw Access Helper: Error serializing pool data with "
|
||||
"ID 0x" << std::hex << currentPoolId << " into send buffer "
|
||||
"with return code " << result << std::dec << std::endl;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -134,9 +147,10 @@ ReturnValue_t PoolRawAccessHelper::handlePoolEntrySerialization(uint32_t current
|
|||
return result;
|
||||
}
|
||||
|
||||
ReturnValue_t PoolRawAccessHelper::checkRemainingSize(PoolRawAccess * currentPoolRawAccess,
|
||||
bool * isSerialized, uint8_t * arrayPosition) {
|
||||
int8_t remainingSize = currentPoolRawAccess->getSizeTillEnd() - currentPoolRawAccess->getSizeOfType();
|
||||
ReturnValue_t PoolRawAccessHelper::checkRemainingSize(PoolRawAccess*
|
||||
currentPoolRawAccess, bool * isSerialized, uint8_t * arrayPosition) {
|
||||
int8_t remainingSize = currentPoolRawAccess->getSizeTillEnd() -
|
||||
currentPoolRawAccess->getSizeOfType();
|
||||
if(remainingSize == 0) {
|
||||
*isSerialized = true;
|
||||
}
|
||||
|
@ -158,9 +172,10 @@ void PoolRawAccessHelper::handleMaskModification(uint8_t * validityMask) {
|
|||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
debug << "Pool Raw Access: Bit setting invalid position" << std::endl;
|
||||
sif::debug << "Pool Raw Access: Bit setting invalid position" << std::endl;
|
||||
return byte;
|
||||
}
|
||||
uint8_t shiftNumber = position + (6 - 2 * (position - 1));
|
||||
|
|
|
@ -69,7 +69,7 @@ private:
|
|||
struct SerializationArgs {
|
||||
uint8_t ** buffer;
|
||||
size_t * size;
|
||||
const uint32_t max_size;
|
||||
const size_t max_size;
|
||||
bool bigEndian;
|
||||
};
|
||||
/**
|
||||
|
@ -80,13 +80,15 @@ private:
|
|||
* @param hkDataSize
|
||||
* @param max_size
|
||||
* @param bigEndian
|
||||
* @param withValidMask Can be set optionally to set a provided validity mask
|
||||
* @param validityMask Can be supplied and will be set if @c withValidMask is set to true
|
||||
* @param withValidMask Can be set optionally to set a
|
||||
* provided validity mask
|
||||
* @param validityMask Can be supplied and will be set if
|
||||
* @c withValidMask is set to true
|
||||
* @return
|
||||
*/
|
||||
ReturnValue_t serializeCurrentPoolEntryIntoBuffer(SerializationArgs argStruct,
|
||||
ssize_t * remainingParameters, bool withValidMask = false,
|
||||
uint8_t * validityMask = nullptr);
|
||||
ReturnValue_t serializeCurrentPoolEntryIntoBuffer(
|
||||
SerializationArgs argStruct, size_t * remainingParameters,
|
||||
bool withValidMask = false, uint8_t * validityMask = nullptr);
|
||||
|
||||
ReturnValue_t handlePoolEntrySerialization(uint32_t currentPoolId,
|
||||
SerializationArgs argStruct, bool withValidMask = false,
|
||||
|
|
Loading…
Reference in New Issue
Block a user