Details
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.