[Rxtx] Block permanently when open serial port on Linux

Francois Hamard francois.hamard at intesens.com
Wed Apr 4 10:41:01 MDT 2012


Hello,

I'm a newbie using rxtx directly but I use it for 2 year now through the 
mina framework. Today, I try to open a serial port with RXTX and it 
blocks permanently on the open function. It seems works fine on windows 
but not on linux.
Do you have any clue of what can append?
Hereunder my environment, stacktraces, logs and my code as simple as I can.

Best regards,
Francois

OS:
$ uname -a
Linux francois-PC 2.6.38-13-generic #56-Ubuntu SMP Tue Feb 14 12:40:40 
UTC 2012 i686 i686 i386 GNU/Linux
JRE:
java-6-openjdk
Lib:
librxtxSerial.so
rxtxcomm-2.2pre2-sources.jar

Code:
     public static void main(String[] args) {
         System.out.println("Try to open serial port");
         String comPort = "/dev/ttyHS3";
         System.setProperty("gnu.io.rxtx.SerialPorts", comPort);
         SerialPort sp = null;
         try {
             CommPortIdentifier id = 
CommPortIdentifier.getPortIdentifier(comPort);
             if (id.getPortType() == CommPortIdentifier.PORT_SERIAL) {

                 sp = (SerialPort) id.open("LinuxOpenTester", 1000);

                 sp.setSerialPortParams(4800, SerialPort.DATABITS_8, 
SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);

             }
             System.out.println("NMEA data was not found..");

         } catch (Exception e) {
             System.out.println("Error opening GPS com port");
             e.printStackTrace();
         }
         System.out.println("Open is finished.");
         System.out.println("sp = " + sp);

     }
Log:
Try to open serial port
WARNING:  RXTX Version mismatch
     Jar version = RXTX-2.2pre1
     native lib Version = RXTX-2.2pre2
RXTX Warning:  Removing stale lock file. /var/lock/LCK..ttyHS3

StackTrace:
TestOpenSerial at localhost:60821
     Thread [main] (Suspended)
         Thread.sleep(long) line: not available [native method]
         RXTXPort.waitForTheNativeCodeSilly() line: 892
         RXTXPort.<init>(String) line: 129
         RXTXCommDriver.getCommPort(String, int) line: 861
         CommPortIdentifier.open(String, int) line: 458
         TestOpenSerial.main(String[]) line: 16
     Thread [Thread-0] (Suspended)
         RXTXPort.eventLoop() line: not available [native method]
         RXTXPort$MonitorThread.run() line: 1641





More information about the Rxtx mailing list