Embedded Freaks..

August 28, 2008

RXTX Loopback Test Program(1)

Filed under: java — Tags: , — kunilkuda @ 11:36 am

One comment that I had in this site said that the RXTX library is not very reliable in the receiving part (using data available event).

I’m unsure whether it happens because of the RXTX implementation (in the application side) or RXTX library has internal bug. So, here’s some simple loopback test program to test the RXTX.


August 13, 2008

Reading from serial port (using rxtx)

Filed under: java — Tags: , , — kunilkuda @ 9:29 am

Once you’ve got the serial InputStream, reading would be easy. Here’s an example of code to read the serial port using InputStream:

 * Buffer to hold the reading
private byte[] readBuffer = new byte[400];

private void readSerial() {
    try {
        int availableBytes = inStream.available();
        if (availableBytes > 0) {
            // Read the serial port
            inStream.read(readBuffer, 0, availableBytes);

            // Print it out
                    new String(readBuffer, 0, availableBytes));
    } catch (IOException e) {

But the real problem comes from the place where you should place the code.

August 12, 2008

Serial port event in rxtx

Filed under: java — Tags: , , — kunilkuda @ 6:26 am

So, what do you expect from serial port event ? Most probably is the notification whether you’ve got new data in the buffer or not. But for some people (like me) who deals with real modem (I use GSM modem for server communication), we need RTS/CTS notification as well. Otherwise, we will flood the modem with data, since most PCs are faster than modem.

I’ve tested some of rxtx serial port events in Linux, and here’s some report that you might be interested.

« Newer PostsOlder Posts »