Menu

AsyncSerialSample

Stephen Davies

Asynchronous Serial Port

To use your FTDI device as an asynchronous serial port perform the following actions. A complete serial port sample program can be found in the samples. Its name is Simple.

Device[] devices = FTDIInterface.getDevices();

if (devices.length == 0) {
    // Error handling
}

Device dev = devices[0];

dev.open();
dev.setDataCharacteristics(FTDIConstants.FT_BITS_8,
                    FTDIConstants.FT_STOP_BITS_2,
                    FTDIConstants.FT_PARITY_NONE);
dev.setBaudRate(FTDIConstants.FT_BAUD_9600);
dev.setTimeouts(2000, 2000);

// use the device
dev.write((byte) 0x41); // 'A'
dev.write((byte) 0x42); // 'B'
dev.write((byte) 0x43); // 'C'

dev.close();