You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by Konrad Bösche <bi...@web.de> on 2008/02/06 15:56:06 UTC

Mina serial communication - filter not used?


Hello,

I'm developing a connection tool that supports UDP and serial(RS232)
connections. 
There's an IConnector instance that can be either a NioDatagramConnector or
a SerialConnector. In both cases I'm adding a ProtocolCodecFilter. The
corresponding encoder/decoder instances are working fine (tested with
NioDatagramConnector), but when writing/receiving a message over a serial
session, it seems as the encoder/decoder is not used. The encode() or
doDecode() method is never called. Even the getEncoder() and getDecoder()
methods from ProtocolCodecFactory are not called. 
Is it possible that there’s a bug in SerialSessionImpl that prevents the
usage of my filter? Here’s the code for my SerialConnector initialization:

connector = new SerialConnector();            
address = new SerialAddress("COM1", 115200, DataBits.DATABITS_8,
StopBits.BITS_1, Parity.NONE, FlowControl.NONE);
connector.getSessionConfig().setReadBufferSize(120000);                        
connector.getFilterChain().addLast( "protocol-codec", new
ProtocolCodecFilter(new CommProtocolCodecFactory()) );
connector.setHandler(new InternalIoHandler());
ConnectFuture cf = connector.connect(address);
try {
cf.await();
session = cf.getSession();
} catch (Exception e) {
e.printStackTrace();
}   
WriteFuture wf = session.write(object);

I'm using Mina core and serial bundle from the ASF Maven 2 snapshot
repository (mina-core-2.0.0-M1-20080117.051022-115.jar and
mina-transport-serial-2.0.0-M1-20080124.103130-71.jar)

I would be grateful for any answers.

Kind regards from Berlin,
Konrad

-- 
View this message in context: http://www.nabble.com/Mina-serial-communication---filter-not-used--tp15306707s16868p15306707.html
Sent from the Apache MINA Support Forum mailing list archive at Nabble.com.


Re: Mina serial communication - filter not used?

Posted by Konrad Bösche <bi...@web.de>.
Hi Julien,

I just checked it out and now it works fine! Thank you very much! 




Julien Vermillard wrote:
> 
> On Wed, 6 Feb 2008 18:15:26 +0100
> Julien Vermillard <jv...@archean.fr> wrote:
> 
>> On Wed, 6 Feb 2008 17:36:57 +0100
>> Julien Vermillard <jv...@archean.fr> wrote:
>> 
>> > On Wed, 6 Feb 2008 06:56:06 -0800 (PST)
>> > Konrad Bösche <bi...@web.de> wrote:
>> > 
>> > > 
>> > > 
>> > > Hello,
>> > > 
>> > > I'm developing a connection tool that supports UDP and
>> > > serial(RS232) connections. 
>> > > There's an IConnector instance that can be either a
>> > > NioDatagramConnector or a SerialConnector. In both cases I'm
>> > > adding a ProtocolCodecFilter. The corresponding encoder/decoder
>> > > instances are working fine (tested with NioDatagramConnector),
>> > > but when writing/receiving a message over a serial session, it
>> > > seems as the encoder/decoder is not used. The encode() or
>> > > doDecode() method is never called. Even the getEncoder() and
>> > > getDecoder() methods from ProtocolCodecFactory are not called. Is
>> > > it possible that there’s a bug in SerialSessionImpl that prevents
>> > > the usage of my filter? Here’s the code for my SerialConnector
>> > > initialization:
>> > > 
>> > > connector = new SerialConnector();            
>> > > address = new SerialAddress("COM1", 115200, DataBits.DATABITS_8,
>> > > StopBits.BITS_1, Parity.NONE, FlowControl.NONE);
>> > > connector.getSessionConfig().setReadBufferSize(120000);                        
>> > > connector.getFilterChain().addLast( "protocol-codec", new
>> > > ProtocolCodecFilter(new CommProtocolCodecFactory()) );
>> > > connector.setHandler(new InternalIoHandler());
>> > > ConnectFuture cf = connector.connect(address);
>> > > try {
>> > > cf.await();
>> > > session = cf.getSession();
>> > > } catch (Exception e) {
>> > > e.printStackTrace();
>> > > }   
>> > > WriteFuture wf = session.write(object);
>> > > 
>> > > I'm using Mina core and serial bundle from the ASF Maven 2
>> > > snapshot repository (mina-core-2.0.0-M1-20080117.051022-115.jar
>> > > and mina-transport-serial-2.0.0-M1-20080124.103130-71.jar)
>> > > 
>> > > I would be grateful for any answers.
>> > > 
>> > > Kind regards from Berlin,
>> > > Konrad
>> > > 
>> > 
>> > Hi Konrad,
>> > 
>> > It's sounding pretty weird, I'm sure to have tested it against a
>> > codec filter. I'm going to check that.
>> > 
>> > Julien
>> 
>> Yes there is a bug,
>> The filterchain from the SerialConnector is not copied, you could use
>> the IoHandler.sessionCreated(..) for adding your codec filter in the
>> session filterchain. 
>> I'll try to fix that ASAP.
>> 
>> Julien
> 
> I found it, I commited a fix in the serial-transport in the
> sandbox :
> https://svn.apache.org/repos/asf/mina/sandbox/transport-serial/
> Checkout that and a "mvn install" will build it.
> 
> HTH
> 
> Julien
> 
> 

-- 
View this message in context: http://www.nabble.com/Mina-serial-communication---filter-not-used--tp15306707s16868p15333834.html
Sent from the Apache MINA Support Forum mailing list archive at Nabble.com.


Re: Mina serial communication - filter not used?

Posted by Julien Vermillard <jv...@archean.fr>.
On Wed, 6 Feb 2008 18:15:26 +0100
Julien Vermillard <jv...@archean.fr> wrote:

> On Wed, 6 Feb 2008 17:36:57 +0100
> Julien Vermillard <jv...@archean.fr> wrote:
> 
> > On Wed, 6 Feb 2008 06:56:06 -0800 (PST)
> > Konrad Bösche <bi...@web.de> wrote:
> > 
> > > 
> > > 
> > > Hello,
> > > 
> > > I'm developing a connection tool that supports UDP and
> > > serial(RS232) connections. 
> > > There's an IConnector instance that can be either a
> > > NioDatagramConnector or a SerialConnector. In both cases I'm
> > > adding a ProtocolCodecFilter. The corresponding encoder/decoder
> > > instances are working fine (tested with NioDatagramConnector),
> > > but when writing/receiving a message over a serial session, it
> > > seems as the encoder/decoder is not used. The encode() or
> > > doDecode() method is never called. Even the getEncoder() and
> > > getDecoder() methods from ProtocolCodecFactory are not called. Is
> > > it possible that there’s a bug in SerialSessionImpl that prevents
> > > the usage of my filter? Here’s the code for my SerialConnector
> > > initialization:
> > > 
> > > connector = new SerialConnector();            
> > > address = new SerialAddress("COM1", 115200, DataBits.DATABITS_8,
> > > StopBits.BITS_1, Parity.NONE, FlowControl.NONE);
> > > connector.getSessionConfig().setReadBufferSize(120000);                        
> > > connector.getFilterChain().addLast( "protocol-codec", new
> > > ProtocolCodecFilter(new CommProtocolCodecFactory()) );
> > > connector.setHandler(new InternalIoHandler());
> > > ConnectFuture cf = connector.connect(address);
> > > try {
> > > cf.await();
> > > session = cf.getSession();
> > > } catch (Exception e) {
> > > e.printStackTrace();
> > > }   
> > > WriteFuture wf = session.write(object);
> > > 
> > > I'm using Mina core and serial bundle from the ASF Maven 2
> > > snapshot repository (mina-core-2.0.0-M1-20080117.051022-115.jar
> > > and mina-transport-serial-2.0.0-M1-20080124.103130-71.jar)
> > > 
> > > I would be grateful for any answers.
> > > 
> > > Kind regards from Berlin,
> > > Konrad
> > > 
> > 
> > Hi Konrad,
> > 
> > It's sounding pretty weird, I'm sure to have tested it against a
> > codec filter. I'm going to check that.
> > 
> > Julien
> 
> Yes there is a bug,
> The filterchain from the SerialConnector is not copied, you could use
> the IoHandler.sessionCreated(..) for adding your codec filter in the
> session filterchain. 
> I'll try to fix that ASAP.
> 
> Julien

I found it, I commited a fix in the serial-transport in the
sandbox :
https://svn.apache.org/repos/asf/mina/sandbox/transport-serial/
Checkout that and a "mvn install" will build it.

HTH

Julien

Re: Mina serial communication - filter not used?

Posted by Julien Vermillard <jv...@archean.fr>.
On Wed, 6 Feb 2008 17:36:57 +0100
Julien Vermillard <jv...@archean.fr> wrote:

> On Wed, 6 Feb 2008 06:56:06 -0800 (PST)
> Konrad Bösche <bi...@web.de> wrote:
> 
> > 
> > 
> > Hello,
> > 
> > I'm developing a connection tool that supports UDP and serial(RS232)
> > connections. 
> > There's an IConnector instance that can be either a
> > NioDatagramConnector or a SerialConnector. In both cases I'm adding
> > a ProtocolCodecFilter. The corresponding encoder/decoder instances
> > are working fine (tested with NioDatagramConnector), but when
> > writing/receiving a message over a serial session, it seems as the
> > encoder/decoder is not used. The encode() or doDecode() method is
> > never called. Even the getEncoder() and getDecoder() methods from
> > ProtocolCodecFactory are not called. Is it possible that there’s a
> > bug in SerialSessionImpl that prevents the usage of my filter?
> > Here’s the code for my SerialConnector initialization:
> > 
> > connector = new SerialConnector();            
> > address = new SerialAddress("COM1", 115200, DataBits.DATABITS_8,
> > StopBits.BITS_1, Parity.NONE, FlowControl.NONE);
> > connector.getSessionConfig().setReadBufferSize(120000);                        
> > connector.getFilterChain().addLast( "protocol-codec", new
> > ProtocolCodecFilter(new CommProtocolCodecFactory()) );
> > connector.setHandler(new InternalIoHandler());
> > ConnectFuture cf = connector.connect(address);
> > try {
> > cf.await();
> > session = cf.getSession();
> > } catch (Exception e) {
> > e.printStackTrace();
> > }   
> > WriteFuture wf = session.write(object);
> > 
> > I'm using Mina core and serial bundle from the ASF Maven 2 snapshot
> > repository (mina-core-2.0.0-M1-20080117.051022-115.jar and
> > mina-transport-serial-2.0.0-M1-20080124.103130-71.jar)
> > 
> > I would be grateful for any answers.
> > 
> > Kind regards from Berlin,
> > Konrad
> > 
> 
> Hi Konrad,
> 
> It's sounding pretty weird, I'm sure to have tested it against a codec
> filter. I'm going to check that.
> 
> Julien

Yes there is a bug,
The filterchain from the SerialConnector is not copied, you could use
the IoHandler.sessionCreated(..) for adding your codec filter in the
session filterchain. 
I'll try to fix that ASAP.

Julien

Re: Mina serial communication - filter not used?

Posted by Julien Vermillard <jv...@archean.fr>.
On Wed, 6 Feb 2008 06:56:06 -0800 (PST)
Konrad Bösche <bi...@web.de> wrote:

> 
> 
> Hello,
> 
> I'm developing a connection tool that supports UDP and serial(RS232)
> connections. 
> There's an IConnector instance that can be either a
> NioDatagramConnector or a SerialConnector. In both cases I'm adding a
> ProtocolCodecFilter. The corresponding encoder/decoder instances are
> working fine (tested with NioDatagramConnector), but when
> writing/receiving a message over a serial session, it seems as the
> encoder/decoder is not used. The encode() or doDecode() method is
> never called. Even the getEncoder() and getDecoder() methods from
> ProtocolCodecFactory are not called. Is it possible that there’s a
> bug in SerialSessionImpl that prevents the usage of my filter? Here’s
> the code for my SerialConnector initialization:
> 
> connector = new SerialConnector();            
> address = new SerialAddress("COM1", 115200, DataBits.DATABITS_8,
> StopBits.BITS_1, Parity.NONE, FlowControl.NONE);
> connector.getSessionConfig().setReadBufferSize(120000);                        
> connector.getFilterChain().addLast( "protocol-codec", new
> ProtocolCodecFilter(new CommProtocolCodecFactory()) );
> connector.setHandler(new InternalIoHandler());
> ConnectFuture cf = connector.connect(address);
> try {
> cf.await();
> session = cf.getSession();
> } catch (Exception e) {
> e.printStackTrace();
> }   
> WriteFuture wf = session.write(object);
> 
> I'm using Mina core and serial bundle from the ASF Maven 2 snapshot
> repository (mina-core-2.0.0-M1-20080117.051022-115.jar and
> mina-transport-serial-2.0.0-M1-20080124.103130-71.jar)
> 
> I would be grateful for any answers.
> 
> Kind regards from Berlin,
> Konrad
> 

Hi Konrad,

It's sounding pretty weird, I'm sure to have tested it against a codec
filter. I'm going to check that.

Julien