On Tue, 4 Sep 2007 18:03:27 +0200
Julien Vermillard <[EMAIL PROTECTED]> wrote:
> On Tue, 4 Sep 2007 11:49:20 -0300
> "Fernando C. de Castro" <[EMAIL PROTECTED]> wrote:
>
> > Hi people,
> >
> > Sorry if this was addressed before. This is my first take on the
> > new Serial Transport, and I decided to adapt the good old NetCat
> > Example as a first attempt. These were my steps:
> >
> > 1) downloaded mina-core-2.0.0-M1-20070822.130904-57.jar from the
> > trunk;
> >
> > 2) started a new project using that Mina 2.0 snapshot with the
> > NetCat Example files taken from the website;
> >
> > 3) Made the necessary adjustments on the code (as the API changed a
> > bit from 1.x) and put the example to work. Worked fine as expected;
> >
> > 4) Downloaded the rxtx pack and installed the DLL (I'm coding on
> > WindowsXP).
> >
> > 5) Changed Main.java to use a SerialConnector instead of a
> > SocketConnector, following instructions on the Serial Tutorial.
> >
> > 6) Run the program.
> >
> > And this is what I get:
> >
> >
> >
> > Native lib Version = RXTX-2.1-7pre20
> > Java lib Version = RXTX-2.1-7
> > WARNING: RXTX Version mismatch
> > Jar version = RXTX-2.1-7
> > native lib Version = RXTX-2.1-7pre20
> > Experimental: JNI_OnLoad called.
> >
> > Exception in thread "VmPipeIdleStatusChecker"
> > java.lang.NullPointerException at
> > org.apache.mina.common.IdleStatusChecker.notifyIdleSession(IdleStatusChecker.java:86)
> > at
> > org.apache.mina.common.IdleStatusChecker.access$200(IdleStatusChecker.java:33)
> > at
> > org.apache.mina.common.IdleStatusChecker$Worker.run(IdleStatusChecker.java:77)
> >
> >
> > Apparently there is a version mismatch with RXTX, but I haven't
> > been able to identify why. Any hints on how to sort that out will
> > surely help. Plus, there is the Exception above. I ignored it at
> > first because the program was "cat'ing" whatever text was sent to
> > the serial port, as expected, with either Socket or Serial.
> >
> > But then I noticed: sessionIdle() was never called when I used a
> > SerialConnector (and the exception is thrown). When I use the
> > SocketConnector, no Exception is thrown and sessionIdle() is called
> > appropriately.
> >
> > My Main.java is as follows:
> >
> >
> > public class Main {
> > public static void main(String[] args) throws Exception {
> >
> >
> > System.out.println(RXTXVersion.getVersion());
> >
> > IoConnector connector = new SerialConnector();
> > connector.setHandler( new NetCatProtocolHandler() );
> > connector.setConnectTimeout(10);
> >
> > SerialAddress portAddress=new SerialAddress( "COM3", 9600,
> > 8, SerialAddress.StopBits.BITS_1, SerialAddress.Parity.NONE,
> > SerialAddress.FlowControl.NONE );
> >
> >
> > ConnectFuture future = connector.connect( portAddress );
> > future.await();
> > IoSession session = future.getSession();
> >
> >
> > }
> > }
> >
> > The NetCatProtocolHandler() used is as follows:
> >
> >
> >
> > public class NetCatProtocolHandler extends IoHandlerAdapter {
> > public void sessionOpened(IoSession session) {
> > // Set reader idle time to 10 seconds.
> > // sessionIdle(...) method will be invoked when no data is
> > read // for 10 seconds.
> > session.getConfig().setIdleTime(IdleStatus.READER_IDLE, 10);
> > }
> >
> > public void sessionClosed(IoSession session) {
> > // Print out total number of bytes read from the remote
> > peer. System.err.println("Total " + session.getReadBytes() + "
> > byte(s)"); }
> >
> > public void sessionIdle(IoSession session, IdleStatus status) {
> > // Close the connection if reader is idle.
> > if (status == IdleStatus.READER_IDLE)
> > session.close();
> > }
> >
> > public void messageReceived(IoSession session, Object message) {
> > ByteBuffer buf = (ByteBuffer) message;
> > // Print out read buffer content.
> > while (buf.hasRemaining()) {
> > System.out.print((char) buf.get());
> > }
> > System.out.flush();
> > }
> >
> >
> > }
> >
> >
> > Any ideas on what could be throwing the exception and probably
> > hindering sessionIdle() from being called when using the
> > SerialConnector?
> >
> >
> > Thanks in advance.
> >
> >
> > Fernando
> >
>
> Ok it's fixed in SVN, apparently the SerialSession config wasn't
> correctly initialized.
>
> Sorry if you lost some time around this issue.
>
> Julien
>
> PS : it's me or the mailling list is lagging ?
I uploaded a new 2.0M1 snapshot for fixing the problem.
You can get it here :
http://tinyurl.com/2qjmnz
Julien