Serial Input Buffer Size

Written by Kevin Cloutier on Nov 7, 2017 10:14 am

Make sure that the Serial Input Buffer Size is adequate for your application. It is 128 bytes by default. If a greater number of bytes that the buffer size are sent and your application does not read them in time then the buffer can fill and data will be lost.

        // display the current buffer size
        System.out.println("auxSerialPort.getInputBufferSize(): " + auxSerialPort.getInputBufferSize());
 
        // set the new buffer size
        auxSerialPort.setInputBufferSize(256);
        // display the new buffer size
        System.out.println("auxSerialPort.getInputBufferSize(): " + auxSerialPort.getInputBufferSize());

The output should look as follows.

auxSerialPort.getInputBufferSize(): 128
auxSerialPort.getInputBufferSize(): 256
On this page