I have to continue the development of a specific java embedded project which talks to some serial external devices.
Previous development was done using Windows and now I try to run it using Ubuntu. I have some port issue when using this code:
String comport = Gateway.config.getHardwareRevision() <= 1 ? "com0" : "com1";
String ports = System.getProperty("microedition.commports");
log.log("---available PORTS: " + ports);
serial = (CommConnection) Connector .open("comm:" + comport + ";blocking=on;baudrate=" + BAUD_RATES[baudrate]
+ ";autocts=off;autorts=off");
inStream = serial.openInputStream();
outStream = serial.openOutputStream();
Basically I connect my usb to serial cable, noticed that Ubuntu is assigning to it port /dev/ttyUSB0
so I change code to:
`String comport = Gateway.config.getHardwareRevision() <= 1 ? "/dev/ttyUSB0" : "com1";`
because hw revision is <=1 so it should load this port. Unfortunately after many tries I still receive:
Could not find serial port /dev/ttyUSB0
java.io.IOException: gnu.io.NoSuchPortException
at javax.microedition.io.SerialConnection.open(SerialConnection.java:57)
at javax.microedition.io.SerialConnection.<init>(SerialConnection.java:19)
at javax.microedition.io.Connector.open(Connector.java:43)
at javax.microedition.io.Connector.open(Connector.java:13)
I read something that I have to use RXTX if developing with Linux but I can't believe that I should rewrite java code just because I change my dev environment.
Do you have any ideas to make this work without refactoring?