Rxtx devagar

Estou tentando pegar dados da porta serial, os dados sao mandados de um microcontrlador, porém estes dados são atualizador muito rápidos milhares de vezes por segundo e quando o RXTX vai pegar o dado ele retorna como NULL, como posso fazer pra pegar estes dados?

[code] /**

public static class SerialReader implements SerialPortEventListener 
{
    private InputStream in;
    private byte[] buffer = new byte[1024];
    
    public SerialReader ( InputStream in )
    {
        this.in = in;
    }
    
    public void serialEvent(SerialPortEvent arg0) {
        int data;
      
        try
        {
            int len = 0;
            while ( ( data = in.read()) > -1 )
            {
                if ( data == '\n' ) {
                    break;
                }
                buffer[len++] = (byte) data;
            }
            System.out.print(new String(buffer,0,len));
        }
        catch ( IOException e )
        {
            e.printStackTrace();
            System.exit(-1);
        }             
    }

}

[/code]

com esse metodo vc consegue ler o que vem da porta serial… ai com as informações vindas vc tem que manipular por regex… ele ate print no console o que se passa e etc… lembrando que vc tem que saber em que porta comm o aparelho ou sei la o que ta conectado ao pc… para isso usa esse metodo…

[code]import gnu.io.*;
static void listPorts()
{
java.util.Enumeration portEnum = CommPortIdentifier.getPortIdentifiers();
while ( portEnum.hasMoreElements() )
{
CommPortIdentifier portIdentifier = portEnum.nextElement();
System.out.println(portIdentifier.getName() + " - " + getPortTypeName(portIdentifier.getPortType()) );
}
}

static String getPortTypeName ( int portType )
{
    switch ( portType )
    {
        case CommPortIdentifier.PORT_I2C:
            return "I2C";
        case CommPortIdentifier.PORT_PARALLEL:
            return "Parallel";
        case CommPortIdentifier.PORT_RAW:
            return "Raw";
        case CommPortIdentifier.PORT_RS485:
            return "RS485";
        case CommPortIdentifier.PORT_SERIAL:
            return "Serial";
        default:
            return "unknown type";
    }
}

[/code]

bom espero ter ajudado, pois mexer com rxtx não é algo muito simples no começo