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

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: embedded
    • Labels:
      None
    • Subcomponent:
      dio

      Description

      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.

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                Created:
                Updated:
                Resolved: