You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by "Akbar Munir Chaudhary (JIRA)" <ji...@apache.org> on 2008/12/11 07:53:44 UTC
[jira] Created: (DIRMINA-646) More than required data sent on
serial port through serial transport
More than required data sent on serial port through serial transport
--------------------------------------------------------------------
Key: DIRMINA-646
URL: https://issues.apache.org/jira/browse/DIRMINA-646
Project: MINA
Issue Type: Bug
Components: Transport
Affects Versions: 2.0.0-M3
Environment: 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)
Reporter: Akbar Munir Chaudhary
The serial transport sends more then required data when IoSession.write() is called with the IoBuffer. The following code is the basic usage of serial transport:
<code>
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());
}
</code>
The message <code>this is a test message</code> should have been sent on the serial port COM1. But the actual output received is (output captured through HDD Free Serial Port Monitor) :
<code>
74 68 69 73 20 69 73 20 61 20 74 65 73 74 20 6D this is a test m
65 73 73 61 67 65 00 00 00 00 00 00 00 00 00 00 essage..........
</code>
I have looked into the code, and the reason appears to be the following statement on line # 18 in the file SerialSessionImpl.java.
<code>
outputStream.write(buf.array());
</code>
Since buf.array() returns the complete array in the IoBuffer, regardless of the actual count of valid data, so all bytes are sent. I changed this statement to:
<code>
outputStream.write(buf.array(), buf.position(), writtenBytes);
</code>
to ensure that only the required bytes starting from the first unread position is sent on the serial port. This works so far for all my cases.
Thanks,
Akbar.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (DIRMINA-646) More than required data sent on
serial port through serial transport
Posted by "Akbar Munir Chaudhary (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/DIRMINA-646?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Akbar Munir Chaudhary updated DIRMINA-646:
------------------------------------------
Description:
The serial transport sends more then required data when IoSession.write() is called with the IoBuffer. The following code is the basic usage of serial transport:
<hr>
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());
}
</TT>
The message <code>this is a test message</code> should have been sent on the serial port COM1. But the actual output received is (output captured through HDD Free Serial Port Monitor) :
<code>
74 68 69 73 20 69 73 20 61 20 74 65 73 74 20 6D this is a test m
65 73 73 61 67 65 00 00 00 00 00 00 00 00 00 00 essage..........
</code>
I have looked into the code, and the reason appears to be the following statement on line # 18 in the file SerialSessionImpl.java.
<code>
outputStream.write(buf.array());
</code>
Since buf.array() returns the complete array in the IoBuffer, regardless of the actual count of valid data, so all bytes are sent. I changed this statement to:
<code>
outputStream.write(buf.array(), buf.position(), writtenBytes);
</code>
to ensure that only the required bytes starting from the first unread position is sent on the serial port. This works so far for all my cases.
Thanks,
Akbar.
was:
The serial transport sends more then required data when IoSession.write() is called with the IoBuffer. The following code is the basic usage of serial transport:
<TT>
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());
}
</TT>
The message <code>this is a test message</code> should have been sent on the serial port COM1. But the actual output received is (output captured through HDD Free Serial Port Monitor) :
<code>
74 68 69 73 20 69 73 20 61 20 74 65 73 74 20 6D this is a test m
65 73 73 61 67 65 00 00 00 00 00 00 00 00 00 00 essage..........
</code>
I have looked into the code, and the reason appears to be the following statement on line # 18 in the file SerialSessionImpl.java.
<code>
outputStream.write(buf.array());
</code>
Since buf.array() returns the complete array in the IoBuffer, regardless of the actual count of valid data, so all bytes are sent. I changed this statement to:
<code>
outputStream.write(buf.array(), buf.position(), writtenBytes);
</code>
to ensure that only the required bytes starting from the first unread position is sent on the serial port. This works so far for all my cases.
Thanks,
Akbar.
> More than required data sent on serial port through serial transport
> --------------------------------------------------------------------
>
> Key: DIRMINA-646
> URL: https://issues.apache.org/jira/browse/DIRMINA-646
> Project: MINA
> Issue Type: Bug
> Components: Transport
> Affects Versions: 2.0.0-M3
> Environment: 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)
> Reporter: Akbar Munir Chaudhary
>
> The serial transport sends more then required data when IoSession.write() is called with the IoBuffer. The following code is the basic usage of serial transport:
> <hr>
> 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());
> }
> </TT>
> The message <code>this is a test message</code> should have been sent on the serial port COM1. But the actual output received is (output captured through HDD Free Serial Port Monitor) :
> <code>
> 74 68 69 73 20 69 73 20 61 20 74 65 73 74 20 6D this is a test m
> 65 73 73 61 67 65 00 00 00 00 00 00 00 00 00 00 essage..........
> </code>
> I have looked into the code, and the reason appears to be the following statement on line # 18 in the file SerialSessionImpl.java.
> <code>
> outputStream.write(buf.array());
> </code>
> Since buf.array() returns the complete array in the IoBuffer, regardless of the actual count of valid data, so all bytes are sent. I changed this statement to:
> <code>
> outputStream.write(buf.array(), buf.position(), writtenBytes);
> </code>
> to ensure that only the required bytes starting from the first unread position is sent on the serial port. This works so far for all my cases.
> Thanks,
> Akbar.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Assigned: (DIRMINA-646) More than required data sent on
serial port through serial transport
Posted by "Julien Vermillard (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/DIRMINA-646?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Julien Vermillard reassigned DIRMINA-646:
-----------------------------------------
Assignee: Julien Vermillard
> More than required data sent on serial port through serial transport
> --------------------------------------------------------------------
>
> Key: DIRMINA-646
> URL: https://issues.apache.org/jira/browse/DIRMINA-646
> Project: MINA
> Issue Type: Bug
> Components: Transport
> Affects Versions: 2.0.0-M3
> Environment: 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)
> Reporter: Akbar Munir Chaudhary
> Assignee: Julien Vermillard
>
> The serial transport sends more then required data when IoSession.write() is called with the IoBuffer. 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());
> }
> -----------------------------------------------------------------------
> The message <code>this is a test message</code> should have been sent on the serial port COM1. But the actual output received is (output captured through HDD Free Serial Port Monitor) :
> -----------------------------------------------------------------------
> 74 68 69 73 20 69 73 20 61 20 74 65 73 74 20 6D this is a test m
> 65 73 73 61 67 65 00 00 00 00 00 00 00 00 00 00 essage..........
> -----------------------------------------------------------------------
> I have looked into the code, and the reason appears to be the following statement on line # 184 in the file SerialSessionImpl.java.
> -----------------------------------------------------------------------
> outputStream.write(buf.array());
> -----------------------------------------------------------------------
> Since buf.array() returns the complete array in the IoBuffer, regardless of the actual count of valid data, so all bytes are sent. I changed this statement to:
> -----------------------------------------------------------------------
> outputStream.write(buf.array(), buf.position(), writtenBytes);
> -----------------------------------------------------------------------
> to ensure that only the required bytes starting from the first unread position is sent on the serial port. This works so far for all my cases.
> Thanks,
> Akbar.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Closed: (DIRMINA-646) More than required data sent on serial
port through serial transport
Posted by "Emmanuel Lecharny (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/DIRMINA-646?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Emmanuel Lecharny closed DIRMINA-646.
-------------------------------------
> More than required data sent on serial port through serial transport
> --------------------------------------------------------------------
>
> Key: DIRMINA-646
> URL: https://issues.apache.org/jira/browse/DIRMINA-646
> Project: MINA
> Issue Type: Bug
> Components: Transport
> Affects Versions: 2.0.0-M3
> Environment: 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)
> Reporter: Akbar Munir Chaudhary
> Assignee: Julien Vermillard
> Fix For: 2.0.0-M5
>
>
> The serial transport sends more then required data when IoSession.write() is called with the IoBuffer. 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());
> }
> -----------------------------------------------------------------------
> The message <code>this is a test message</code> should have been sent on the serial port COM1. But the actual output received is (output captured through HDD Free Serial Port Monitor) :
> -----------------------------------------------------------------------
> 74 68 69 73 20 69 73 20 61 20 74 65 73 74 20 6D this is a test m
> 65 73 73 61 67 65 00 00 00 00 00 00 00 00 00 00 essage..........
> -----------------------------------------------------------------------
> I have looked into the code, and the reason appears to be the following statement on line # 184 in the file SerialSessionImpl.java.
> -----------------------------------------------------------------------
> outputStream.write(buf.array());
> -----------------------------------------------------------------------
> Since buf.array() returns the complete array in the IoBuffer, regardless of the actual count of valid data, so all bytes are sent. I changed this statement to:
> -----------------------------------------------------------------------
> outputStream.write(buf.array(), buf.position(), writtenBytes);
> -----------------------------------------------------------------------
> to ensure that only the required bytes starting from the first unread position is sent on the serial port. This works so far for all my cases.
> Thanks,
> Akbar.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (DIRMINA-646) More than required data sent on
serial port through serial transport
Posted by "Akbar Munir Chaudhary (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/DIRMINA-646?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Akbar Munir Chaudhary updated DIRMINA-646:
------------------------------------------
Description:
The serial transport sends more then required data when IoSession.write() is called with the IoBuffer. The following code is the basic usage of serial transport:
<TT>
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());
}
</TT>
The message <code>this is a test message</code> should have been sent on the serial port COM1. But the actual output received is (output captured through HDD Free Serial Port Monitor) :
<code>
74 68 69 73 20 69 73 20 61 20 74 65 73 74 20 6D this is a test m
65 73 73 61 67 65 00 00 00 00 00 00 00 00 00 00 essage..........
</code>
I have looked into the code, and the reason appears to be the following statement on line # 18 in the file SerialSessionImpl.java.
<code>
outputStream.write(buf.array());
</code>
Since buf.array() returns the complete array in the IoBuffer, regardless of the actual count of valid data, so all bytes are sent. I changed this statement to:
<code>
outputStream.write(buf.array(), buf.position(), writtenBytes);
</code>
to ensure that only the required bytes starting from the first unread position is sent on the serial port. This works so far for all my cases.
Thanks,
Akbar.
was:
The serial transport sends more then required data when IoSession.write() is called with the IoBuffer. The following code is the basic usage of serial transport:
<code>
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());
}
</code>
The message <code>this is a test message</code> should have been sent on the serial port COM1. But the actual output received is (output captured through HDD Free Serial Port Monitor) :
<code>
74 68 69 73 20 69 73 20 61 20 74 65 73 74 20 6D this is a test m
65 73 73 61 67 65 00 00 00 00 00 00 00 00 00 00 essage..........
</code>
I have looked into the code, and the reason appears to be the following statement on line # 18 in the file SerialSessionImpl.java.
<code>
outputStream.write(buf.array());
</code>
Since buf.array() returns the complete array in the IoBuffer, regardless of the actual count of valid data, so all bytes are sent. I changed this statement to:
<code>
outputStream.write(buf.array(), buf.position(), writtenBytes);
</code>
to ensure that only the required bytes starting from the first unread position is sent on the serial port. This works so far for all my cases.
Thanks,
Akbar.
> More than required data sent on serial port through serial transport
> --------------------------------------------------------------------
>
> Key: DIRMINA-646
> URL: https://issues.apache.org/jira/browse/DIRMINA-646
> Project: MINA
> Issue Type: Bug
> Components: Transport
> Affects Versions: 2.0.0-M3
> Environment: 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)
> Reporter: Akbar Munir Chaudhary
>
> The serial transport sends more then required data when IoSession.write() is called with the IoBuffer. The following code is the basic usage of serial transport:
> <TT>
> 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());
> }
> </TT>
> The message <code>this is a test message</code> should have been sent on the serial port COM1. But the actual output received is (output captured through HDD Free Serial Port Monitor) :
> <code>
> 74 68 69 73 20 69 73 20 61 20 74 65 73 74 20 6D this is a test m
> 65 73 73 61 67 65 00 00 00 00 00 00 00 00 00 00 essage..........
> </code>
> I have looked into the code, and the reason appears to be the following statement on line # 18 in the file SerialSessionImpl.java.
> <code>
> outputStream.write(buf.array());
> </code>
> Since buf.array() returns the complete array in the IoBuffer, regardless of the actual count of valid data, so all bytes are sent. I changed this statement to:
> <code>
> outputStream.write(buf.array(), buf.position(), writtenBytes);
> </code>
> to ensure that only the required bytes starting from the first unread position is sent on the serial port. This works so far for all my cases.
> Thanks,
> Akbar.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Resolved: (DIRMINA-646) More than required data sent on
serial port through serial transport
Posted by "Julien Vermillard (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/DIRMINA-646?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Julien Vermillard resolved DIRMINA-646.
---------------------------------------
Resolution: Fixed
Fix Version/s: 2.0.0-RC1
Fixed, thanks !
> More than required data sent on serial port through serial transport
> --------------------------------------------------------------------
>
> Key: DIRMINA-646
> URL: https://issues.apache.org/jira/browse/DIRMINA-646
> Project: MINA
> Issue Type: Bug
> Components: Transport
> Affects Versions: 2.0.0-M3
> Environment: 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)
> Reporter: Akbar Munir Chaudhary
> Assignee: Julien Vermillard
> Fix For: 2.0.0-RC1
>
>
> The serial transport sends more then required data when IoSession.write() is called with the IoBuffer. 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());
> }
> -----------------------------------------------------------------------
> The message <code>this is a test message</code> should have been sent on the serial port COM1. But the actual output received is (output captured through HDD Free Serial Port Monitor) :
> -----------------------------------------------------------------------
> 74 68 69 73 20 69 73 20 61 20 74 65 73 74 20 6D this is a test m
> 65 73 73 61 67 65 00 00 00 00 00 00 00 00 00 00 essage..........
> -----------------------------------------------------------------------
> I have looked into the code, and the reason appears to be the following statement on line # 184 in the file SerialSessionImpl.java.
> -----------------------------------------------------------------------
> outputStream.write(buf.array());
> -----------------------------------------------------------------------
> Since buf.array() returns the complete array in the IoBuffer, regardless of the actual count of valid data, so all bytes are sent. I changed this statement to:
> -----------------------------------------------------------------------
> outputStream.write(buf.array(), buf.position(), writtenBytes);
> -----------------------------------------------------------------------
> to ensure that only the required bytes starting from the first unread position is sent on the serial port. This works so far for all my cases.
> Thanks,
> Akbar.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (DIRMINA-646) More than required data sent on
serial port through serial transport
Posted by "Akbar Munir Chaudhary (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/DIRMINA-646?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Akbar Munir Chaudhary updated DIRMINA-646:
------------------------------------------
Description:
The serial transport sends more then required data when IoSession.write() is called with the IoBuffer. 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());
}
-----------------------------------------------------------------------
The message <code>this is a test message</code> should have been sent on the serial port COM1. But the actual output received is (output captured through HDD Free Serial Port Monitor) :
-----------------------------------------------------------------------
74 68 69 73 20 69 73 20 61 20 74 65 73 74 20 6D this is a test m
65 73 73 61 67 65 00 00 00 00 00 00 00 00 00 00 essage..........
-----------------------------------------------------------------------
I have looked into the code, and the reason appears to be the following statement on line # 184 in the file SerialSessionImpl.java.
-----------------------------------------------------------------------
outputStream.write(buf.array());
-----------------------------------------------------------------------
Since buf.array() returns the complete array in the IoBuffer, regardless of the actual count of valid data, so all bytes are sent. I changed this statement to:
-----------------------------------------------------------------------
outputStream.write(buf.array(), buf.position(), writtenBytes);
-----------------------------------------------------------------------
to ensure that only the required bytes starting from the first unread position is sent on the serial port. This works so far for all my cases.
Thanks,
Akbar.
was:
The serial transport sends more then required data when IoSession.write() is called with the IoBuffer. 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());
}
-----------------------------------------------------------------------
The message <code>this is a test message</code> should have been sent on the serial port COM1. But the actual output received is (output captured through HDD Free Serial Port Monitor) :
-----------------------------------------------------------------------
74 68 69 73 20 69 73 20 61 20 74 65 73 74 20 6D this is a test m
65 73 73 61 67 65 00 00 00 00 00 00 00 00 00 00 essage..........
-----------------------------------------------------------------------
I have looked into the code, and the reason appears to be the following statement on line # 18 in the file SerialSessionImpl.java.
-----------------------------------------------------------------------
outputStream.write(buf.array());
-----------------------------------------------------------------------
Since buf.array() returns the complete array in the IoBuffer, regardless of the actual count of valid data, so all bytes are sent. I changed this statement to:
-----------------------------------------------------------------------
outputStream.write(buf.array(), buf.position(), writtenBytes);
-----------------------------------------------------------------------
to ensure that only the required bytes starting from the first unread position is sent on the serial port. This works so far for all my cases.
Thanks,
Akbar.
> More than required data sent on serial port through serial transport
> --------------------------------------------------------------------
>
> Key: DIRMINA-646
> URL: https://issues.apache.org/jira/browse/DIRMINA-646
> Project: MINA
> Issue Type: Bug
> Components: Transport
> Affects Versions: 2.0.0-M3
> Environment: 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)
> Reporter: Akbar Munir Chaudhary
>
> The serial transport sends more then required data when IoSession.write() is called with the IoBuffer. 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());
> }
> -----------------------------------------------------------------------
> The message <code>this is a test message</code> should have been sent on the serial port COM1. But the actual output received is (output captured through HDD Free Serial Port Monitor) :
> -----------------------------------------------------------------------
> 74 68 69 73 20 69 73 20 61 20 74 65 73 74 20 6D this is a test m
> 65 73 73 61 67 65 00 00 00 00 00 00 00 00 00 00 essage..........
> -----------------------------------------------------------------------
> I have looked into the code, and the reason appears to be the following statement on line # 184 in the file SerialSessionImpl.java.
> -----------------------------------------------------------------------
> outputStream.write(buf.array());
> -----------------------------------------------------------------------
> Since buf.array() returns the complete array in the IoBuffer, regardless of the actual count of valid data, so all bytes are sent. I changed this statement to:
> -----------------------------------------------------------------------
> outputStream.write(buf.array(), buf.position(), writtenBytes);
> -----------------------------------------------------------------------
> to ensure that only the required bytes starting from the first unread position is sent on the serial port. This works so far for all my cases.
> Thanks,
> Akbar.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (DIRMINA-646) More than required data sent on
serial port through serial transport
Posted by "Akbar Munir Chaudhary (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/DIRMINA-646?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Akbar Munir Chaudhary updated DIRMINA-646:
------------------------------------------
Description:
The serial transport sends more then required data when IoSession.write() is called with the IoBuffer. 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());
}
-----------------------------------------------------------------------
The message <code>this is a test message</code> should have been sent on the serial port COM1. But the actual output received is (output captured through HDD Free Serial Port Monitor) :
-----------------------------------------------------------------------
74 68 69 73 20 69 73 20 61 20 74 65 73 74 20 6D this is a test m
65 73 73 61 67 65 00 00 00 00 00 00 00 00 00 00 essage..........
-----------------------------------------------------------------------
I have looked into the code, and the reason appears to be the following statement on line # 18 in the file SerialSessionImpl.java.
-----------------------------------------------------------------------
outputStream.write(buf.array());
-----------------------------------------------------------------------
Since buf.array() returns the complete array in the IoBuffer, regardless of the actual count of valid data, so all bytes are sent. I changed this statement to:
-----------------------------------------------------------------------
outputStream.write(buf.array(), buf.position(), writtenBytes);
-----------------------------------------------------------------------
to ensure that only the required bytes starting from the first unread position is sent on the serial port. This works so far for all my cases.
Thanks,
Akbar.
was:
The serial transport sends more then required data when IoSession.write() is called with the IoBuffer. The following code is the basic usage of serial transport:
<hr>
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());
}
</TT>
The message <code>this is a test message</code> should have been sent on the serial port COM1. But the actual output received is (output captured through HDD Free Serial Port Monitor) :
<code>
74 68 69 73 20 69 73 20 61 20 74 65 73 74 20 6D this is a test m
65 73 73 61 67 65 00 00 00 00 00 00 00 00 00 00 essage..........
</code>
I have looked into the code, and the reason appears to be the following statement on line # 18 in the file SerialSessionImpl.java.
<code>
outputStream.write(buf.array());
</code>
Since buf.array() returns the complete array in the IoBuffer, regardless of the actual count of valid data, so all bytes are sent. I changed this statement to:
<code>
outputStream.write(buf.array(), buf.position(), writtenBytes);
</code>
to ensure that only the required bytes starting from the first unread position is sent on the serial port. This works so far for all my cases.
Thanks,
Akbar.
> More than required data sent on serial port through serial transport
> --------------------------------------------------------------------
>
> Key: DIRMINA-646
> URL: https://issues.apache.org/jira/browse/DIRMINA-646
> Project: MINA
> Issue Type: Bug
> Components: Transport
> Affects Versions: 2.0.0-M3
> Environment: 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)
> Reporter: Akbar Munir Chaudhary
>
> The serial transport sends more then required data when IoSession.write() is called with the IoBuffer. 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());
> }
> -----------------------------------------------------------------------
> The message <code>this is a test message</code> should have been sent on the serial port COM1. But the actual output received is (output captured through HDD Free Serial Port Monitor) :
> -----------------------------------------------------------------------
> 74 68 69 73 20 69 73 20 61 20 74 65 73 74 20 6D this is a test m
> 65 73 73 61 67 65 00 00 00 00 00 00 00 00 00 00 essage..........
> -----------------------------------------------------------------------
> I have looked into the code, and the reason appears to be the following statement on line # 18 in the file SerialSessionImpl.java.
> -----------------------------------------------------------------------
> outputStream.write(buf.array());
> -----------------------------------------------------------------------
> Since buf.array() returns the complete array in the IoBuffer, regardless of the actual count of valid data, so all bytes are sent. I changed this statement to:
> -----------------------------------------------------------------------
> outputStream.write(buf.array(), buf.position(), writtenBytes);
> -----------------------------------------------------------------------
> to ensure that only the required bytes starting from the first unread position is sent on the serial port. This works so far for all my cases.
> Thanks,
> Akbar.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.