package org.netevolved.marine; import jssc.SerialPort; import jssc.SerialPortException; import jssc.SerialPortList; public class SerialTest { public static void main(String[] args) { String[] portNames = SerialPortList.getPortNames(); for (int i = 0; i < portNames.length; i++) { System.out.println(portNames[i]); } SerialPort serialPort = new SerialPort("/dev/ttyACM0"); try { serialPort.openPort();// Open serial port serialPort.setParams(9600, 8, 1, 0);// Set params. while (true) { byte[] buffer = serialPort.readBytes(100);// Read 10 bytes from serial port String contents = new String(buffer); System.out.print(contents); } } catch (SerialPortException ex) { System.out.println(ex); } } }