The situation is following:
the code snippet:
...
inBuffer.position(inBuffer.limit());
message.appendWrite(goodBuffer).appendRead(inBuffer).transfer();
...
will result in incomplete i2c transaction due to stop condition will not be generated.
The problem is that
impl/I2CCombinedMessage.transfer() marks last message as to be followed by stop condition by doing:
flag = I2CSlaveImpl.I2C_COMBINED_END;
and calls to
int res = ((I2CSlaveImpl)message.device).transfer(flag, skip, message.buf);
============
In it's turn, I2CSlaveImpl.transfer() would immediately return 0 (a Message is not being processed on native layer) if provided buffer's remaining() is equal to 0:
int transfer(int flag, int skip, ByteBuffer buf) throws
UnavailableDeviceException, ClosedDeviceException, IOException {
int ret = 0;
ByteBuffer toSend;
if (!buf.hasRemaining()) {
return 0;
}
...
}
===============
As the consequence, real life sensor will still wait for stop condition to
reset, and further attempts to communicate to it result in communication
errors/hang ups.
the code snippet:
...
inBuffer.position(inBuffer.limit());
message.appendWrite(goodBuffer).appendRead(inBuffer).transfer();
...
will result in incomplete i2c transaction due to stop condition will not be generated.
The problem is that
impl/I2CCombinedMessage.transfer() marks last message as to be followed by stop condition by doing:
flag = I2CSlaveImpl.I2C_COMBINED_END;
and calls to
int res = ((I2CSlaveImpl)message.device).transfer(flag, skip, message.buf);
============
In it's turn, I2CSlaveImpl.transfer() would immediately return 0 (a Message is not being processed on native layer) if provided buffer's remaining() is equal to 0:
int transfer(int flag, int skip, ByteBuffer buf) throws
UnavailableDeviceException, ClosedDeviceException, IOException {
int ret = 0;
ByteBuffer toSend;
if (!buf.hasRemaining()) {
return 0;
}
...
}
===============
As the consequence, real life sensor will still wait for stop condition to
reset, and further attempts to communicate to it result in communication
errors/hang ups.
- relates to
-
JDK-8144994 Unexpected IllegalArgumentException if same buffer was provided to multiple appendRead/appendWrite calls as a parameter
- Open