Fix bug with wrong read after write in STM32 I2C
@@ -302,6 +302,11 @@ HRESULT Library_win_dev_i2c_native_Windows_Devices_I2c_I2cDevice::NativeTransmit
// get the size of the buffer by reading the number of elements in the CLR_RT_HeapBlock_Array
palI2c->WriteSize = writeBuffer->m_numOfElements;
}
+ else
+ {
+ // nothing to write, have to zero this
+ palI2c->WriteSize = 0;
+ }
readBuffer = stack.Arg2().DereferenceArray();
if (readBuffer != NULL)
@@ -309,6 +314,11 @@ HRESULT Library_win_dev_i2c_native_Windows_Devices_I2c_I2cDevice::NativeTransmit
// get the size of the buffer by reading the number of elements in the CLR_RT_HeapBlock_Array
palI2c->ReadSize = readBuffer->m_numOfElements;
}
+ else
+ {
+ // nothing to read, have to zero this
+ palI2c->ReadSize = 0;
+ }
// check if this is a long running operation
isLongRunningOperation = IsLongRunningOperation(palI2c->WriteSize, palI2c->ReadSize, palI2c->ByteTime, (int&)estimatedDurationMiliseconds);
