Uploaded image for project: 'MINA'
  1. MINA
  2. DIRMINA-647

WriteFuture.isWritten() never returns true even when data is actually sent on the serial port using serial transport

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.0.0-M3
    • 2.0.0-M5
    • Transport
    • None
    • MINA : 2.0.0-M3
      Netbeans 6.5
      Serial port (both hardware COM1 and using com0com's virtual serial ports)
      JDK 1.6.10
      Windows XP (Service Pack 3)

    Description

      The serial transport never sets the WriteFuture.isWritten() to true, even when the data has been written on the serial port. The WriteFuture.awaitUninterruptibly() without any timeout never returns and if WriteFuture.awaitUninterruptibly() is used with a timeout, then it returns but specifies the WriteFuture.isWritten() as false.

      The following code is the basic usage of serial transport:

      -----------------------------------------------------------------------
      SerialAddress a = new SerialAddress("COM1", 115200, SerialAddress.DataBits.DATABITS_8, SerialAddress.StopBits.BITS_1, SerialAddress.Parity.NONE, SerialAddress.FlowControl.NONE);
      IoConnector c = new SerialConnector();
      c.setHandler(this);
      ConnectFuture cf = c.connect(a);
      cf.awaitUninterruptibly();

      System.out.println("Connection = " + cf.isConnected());

      if (cf.isConnected())
      {
      IoSession s = cf.getSession();
      IoBuffer b = IoBuffer.allocate(32);
      b.put(new String("this is a test message").getBytes());
      b.flip();

      WriteFuture wf = s.write(b);
      wf.awaitUninterruptibly(5, TimeUnit.SECONDS);
      System.out.println("Message Written = " + wf.isWritten());
      }
      -----------------------------------------------------------------------

      Using a cross serial cable, the serial data does reach the other end, but the WriteFuture does not say so. I think the problem may be with the file SerialSessionImpl.java after the line 185. After the buffer data has been written to the serial port's output stream and the buffer position has been adjusted, the WriteFuture in the write request is not notified. If I add the line:

      -----------------------------------------------------------------------
      req.getFuture().setWritten();
      -----------------------------------------------------------------------

      right after the line # 185, it starts to work for all my examples.

      Thanks,
      Akbar.

      Attachments

        Activity

          People

            vrm Julien Vermillard
            akbar Akbar Munir Chaudhary
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: