I'm trying to run simple code:
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStream;
import gnu.io.CommPortIdentifier;
import gnu.io.SerialPort;
import gnu.io.SerialPortEvent;
import gnu.io.SerialPortEventListener;
import java.util.Enumeration;
public class SerialTest implements SerialPortEventListener {
SerialPort serialPort;
private BufferedReader input;
private OutputStream output;
private static final int TIME_OUT = 2000;
private static final int DATA_RATE = 9600;
public void initialize() {
CommPortIdentifier portId = null;
Enumeration portEnum = CommPortIdentifier.getPortIdentifiers();
while (portEnum.hasMoreElements()) {
CommPortIdentifier currPortId = (CommPortIdentifier) portEnum.nextElement();
System.out.println( "a " + currPortId.getName());
}
}
public synchronized void close() {
//...
}
public synchronized void serialEvent(SerialPortEvent oEvent) {
// ...
}
public static void main(String[] args) throws Exception {
SerialTest main = new SerialTest();
main.initialize();
}
}
and it should list available COM port in my system. I'm working on 3.2.0-39-generic #62-Ubuntu x86_64 x86_64 x86_64 GNU/Linux and Java 1.6
First I have RXTX install from apt-get repository but after some trouble I install it from source and it still don't work. I make chmod 777 on all ttyS* to be sure that this in not problem with permissions.
I try this and wouldn't help.