Hello,
I am setting a connection to a serial port by calling
SerialConnector.connect(SerialAddress) method. This connection is
established successfully, but it takes around 20-30 seconds to obtain it.
I am using the next code to get the a IoSession:
IoConnector ioConnector = new SerialConnector();
ioConnector.setHandler(new EchoConnectorHandler()); //
EchoConnectorHandler
extends IoHandlerAdapter
SerialAddress serialAddress = new
SerialAddress(getConnectionData().getSerialPortName(),
getConnectionData().getBauds().getValue(),
getConnectionData().getDataBits().getValue(),
getConnectionData().getStopBits().getValue(),
getConnectionData().getParity().getValue(),
getConnectionData().getFlowControl().getValue());
/ConnectFuture connectFuture = ioConnector.connect(serialAddress);/
connectFuture.awaitUninterruptibly();
IoSession ioSession = connectFuture.getSession();
ioSession.getConfig().setUseReadOperation(true);
And I think that this establishment time is beacuse of the line in italics:
"ioConnector.connect(serialAddress)". It is calling the next method inside
SerialConnector (by Mina):
protected synchronized ConnectFuture connect0(SocketAddress
remoteAddress,
SocketAddress localAddress,
IoSessionInitializer<? extends ConnectFuture> sessionInitializer) {
...
/Enumeration<?> portList =
CommPortIdentifier.getPortIdentifiers();/
...
It can be seen that it calls to "CommPortIdentifier.getPortIdentifiers()",
from RXTX. When I watched it, I found the next code:
static public Enumeration getPortIdentifiers()
{
if(debug) System.out.println("static
CommPortIdentifier:getPortIdentifiers()");
CommPortIndex = null;
try
{
CommDriver RXTXDriver = (CommDriver)
Class.forName("gnu.io.RXTXCommDriver").newInstance();
RXTXDriver.initialize();
}
catch (Throwable e)
{
System.err.println(e + " thrown while loading "
+
"gnu.io.RXTXCommDriver");
}
return new CommPortEnumerator();
}
Well, I just would like to know if you know any alternative way to set this
connection, or maybe if some timeout could be set to decrease this
connection time.
Thanks in advance.
Kind regards,
Daniel.
--
View this message in context:
http://apache-mina.10907.n7.nabble.com/Slow-connection-through-SerialConnector-tp40831.html
Sent from the Apache MINA User Forum mailing list archive at Nabble.com.