You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@mina.apache.org by Daniel <dr...@tecsisa.com> on 2013/12/31 10:36:14 UTC

Slow connection through SerialConnector

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.

Re: Slow connection through SerialConnector

Posted by Daniel Redondo <dr...@tecsisa.com>.
Hello,

Finally the problem has been solved =)

After some days trying to get main cause for this issue, I have been
uninstalling some software programs related to serial port communications
and now the serial port connection can be established in around 0.3 seconds.

So problem was due to my own local environment and it is not related with
any mina or rxtx implementation.

Kind regards, Daniel.



--
View this message in context: http://apache-mina.10907.n7.nabble.com/Slow-connection-through-SerialConnector-tp40831p40886.html
Sent from the Apache MINA User Forum mailing list archive at Nabble.com.