Latest downloadsProjectsDocumentationResources
CommunityUpcoming |
Serial TutorialWith the MINA 2.0 you are able to connect to serial port like you use to connect to a TCP/IP port with MINA. Getting MINA 2.0For now MINA 2.0 final isn't released, but you you can download the latest built version (2.0.0-M4). If you prefer to build the code from the trunk, and need assistance to do so, please consult the Developer Guide. Prerequisite
Connecting to a serial portSerial communication for MINA provide only an IoConnector, due to the point-to-point nature of the communication media. At this point you are supposed to have already read the MINA tutorial. Now for connecting to a serial port you need a SerialConnector : // create your connector IoConnector connector = new SerialConnector() connector.setHandler( ... here your buisness logic IoHandler ... ); Nothing very different of a SocketConnector. Let's create an address for connecting to our serial port. SerialAddress portAddress=new SerialAddress( "/dev/ttyS0", 38400, 8, StopBits.BITS_1, Parity.NONE, FlowControl.NONE ); The first parameter is your port identifier. For Windows computer, the serial ports are called "COM1", "COM2", etc... For Linux and some other Unix : "/dev/ttyS0", "/dev/ttyS1", "/dev/ttyUSB0". The remaining parameters are depending of the device you are driving and the supposed communications characteristics.
Once it's done, connect the connector to the address : ConnectFuture future = connector.connect( portAddress ); future.await(); IoSession sessin = future.getSession(); And voila ! Everything else is as usual, you can plug your filters and codecs. |