I'm connecting a device with librxtx-java to Ubuntu. The code previously worked in 10.04, but in 12.04 it can't discover the usb-serial connected to the computer.
java.util.Enumeration<CommPortIdentifier> portEnum = CommPortIdentifier.getPortIdentifiers();
while ( portEnum.hasMoreElements() )
{
CommPortIdentifier portIdentifier = portEnum.nextElement();
System.out.println( portIdentifier.getName() + " - " + getPortTypeName(portIdentifier.getPortType()) );
}
This section of the code never goes into the while loop, despite the appropriate librxtx-java libraries being installed, and device being recognized (dmesg | tail shows USB "Serial Device converter detected" on one line).
Update:
It appears Ubuntu 12.04 64-bit isn't working with any usb-serial devices (although they show up in dmesg and show up as a /dev/ttyUSB, it seems to be more than just a problem with Java.
Best Answer
I have
Ubuntu 11.10
kernel 3.0.0-12-generic-pae andlibrxtx-java version 2.2pre2-8
installed. With the code below, it list my serial ports correctly. Now you have usb to serial converter installed properly? you need to check that what port is the converter use. Using the sample app below, you can try something likejava -cp /usr/share/java/RXTXcomm.jar:. GetCommPorts 2
Please ensure that you have the correct permission in the ttySXX or ttyUSBXX file, in /dev/.
These serial ports are shown in my system and the user who want to run the application should be under group dialout. To add yourself, use:
You should now be in "dialout" group.
Output from this application: