Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8145419

I2CCombinedMessage.transfer() would not trigger a stop condition if last recently added buffer's remaining() == 0

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • None
    • None
    • embedded
    • None
    • dio

      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.

            bkvartsk Boris Kvartskhava
            bkvartsk Boris Kvartskhava
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: