moved a size check
All checks were successful
EIVE/eive-obsw/pipeline/pr-develop This commit looks good
All checks were successful
EIVE/eive-obsw/pipeline/pr-develop This commit looks good
This commit is contained in:
parent
f9061d5494
commit
8ea6df273d
@ -1124,22 +1124,8 @@ class WriteMemory : public ploc::SpTcBase {
|
|||||||
uint8_t* updateData) {
|
uint8_t* updateData) {
|
||||||
size_t serializedSize = 0;
|
size_t serializedSize = 0;
|
||||||
uint8_t* data = payloadStart;
|
uint8_t* data = payloadStart;
|
||||||
SerializeAdapter::serialize(&memoryId, &data, &serializedSize, sizeof(memoryId),
|
|
||||||
SerializeIF::Endianness::BIG);
|
|
||||||
serializedSize = 0;
|
|
||||||
SerializeAdapter::serialize(&n, &data, &serializedSize, sizeof(n),
|
|
||||||
SerializeIF::Endianness::BIG);
|
|
||||||
serializedSize = 0;
|
|
||||||
SerializeAdapter::serialize(&startAddr, &data, &serializedSize, sizeof(startAddr),
|
|
||||||
SerializeIF::Endianness::BIG);
|
|
||||||
serializedSize = 0;
|
|
||||||
SerializeAdapter::serialize(&updateDataLen, &data, &serializedSize, sizeof(updateDataLen),
|
|
||||||
SerializeIF::Endianness::BIG);
|
|
||||||
if (updateDataLen % 2 != 0) {
|
if (updateDataLen % 2 != 0) {
|
||||||
spParams.setPayloadLen(META_DATA_LENGTH + updateDataLen + 1);
|
spParams.setPayloadLen(META_DATA_LENGTH + updateDataLen + 1);
|
||||||
// The data field must be two bytes aligned. Thus, in case the number of bytes to write is odd
|
|
||||||
// a value of zero is added here
|
|
||||||
*(data + updateDataLen + 1) = 0;
|
|
||||||
} else {
|
} else {
|
||||||
spParams.setPayloadLen(META_DATA_LENGTH + updateDataLen);
|
spParams.setPayloadLen(META_DATA_LENGTH + updateDataLen);
|
||||||
}
|
}
|
||||||
@ -1148,7 +1134,20 @@ class WriteMemory : public ploc::SpTcBase {
|
|||||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
SerializeAdapter::serialize(&memoryId, &data, &serializedSize, sizeof(memoryId),
|
||||||
|
SerializeIF::Endianness::BIG);
|
||||||
|
SerializeAdapter::serialize(&n, &data, &serializedSize, sizeof(n),
|
||||||
|
SerializeIF::Endianness::BIG);
|
||||||
|
SerializeAdapter::serialize(&startAddr, &data, &serializedSize, sizeof(startAddr),
|
||||||
|
SerializeIF::Endianness::BIG);
|
||||||
|
SerializeAdapter::serialize(&updateDataLen, &data, &serializedSize, sizeof(updateDataLen),
|
||||||
|
SerializeIF::Endianness::BIG);
|
||||||
std::memcpy(data, updateData, updateDataLen);
|
std::memcpy(data, updateData, updateDataLen);
|
||||||
|
if (updateDataLen % 2 != 0) {
|
||||||
|
// The data field must be two bytes aligned. Thus, in case the number of bytes to write is odd
|
||||||
|
// a value of zero is added here
|
||||||
|
data[updateDataLen + 1] = 0;
|
||||||
|
}
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user