rxtxSerial help needed

I’m trying to set rxtxSerial to work so a Java app has access to a serial port (via SiLabs CP210x driver, port /dev/ttyUSB0).

When I use update-alternatives --config java, there are 3 alternatives which provide `java’. I have tried openJDK and Sun. Both fail but with completely different messages.

Any help is appreciated.

/usr/lib64/jvm/jre-1.6.0-openjdk/bin/java

check_group_uucp(): error testing lock file creation Error details:Permission denied
check_lock_status: No permission to create lock file.
please see: How can I use Lock Files with rxtx? in INSTALL

There is no “INSTALL” file. However, I know the solution is supposed to be adding my user to group uucp. I have done that.

/usr/lib64/jvm/jre-1.6.0-sun/bin/java

ERROR: java.lang.UnsatisfiedLinkError: no rxtxSerial in java.library.path thrown while loading gnu.io.RXTXCommDriver

I have a link pointing to the gnu.io.RXTXCommDriver. It looks correct to me:
ls -la /usr/lib64/jvm/jre/lib/ext/
total 1244
drwxr-xr-x 2 root root 4096 2010-05-10 12:02 .
drwxr-xr-x 19 root root 4096 2009-12-06 11:49 …
-rw-r–r-- 1 root root 8239 2009-10-11 04:37 dnsns.jar
-rw-r–r-- 1 root root 841667 2009-11-13 04:42 localedata.jar
-rw-r–r-- 1 root root 429 2009-10-11 05:09 meta-index
lrwxrwxrwx 1 root root 12 2010-05-10 12:02 RXTXcomm.jar → RXTXcomm.jar
-rw-r–r-- 1 root root 170239 2009-10-11 04:12 sunjce_provider.jar
-rw-r–r-- 1 root root 231542 2009-10-11 04:36 sunpkcs11.jar

3 lines from the bottom is a circular symbolic link. You must have the real RXTXcomm.jar somewhere.

According to the rxtx mailing list, “There is a problem with openSUSE 11.2 that causes rxtx to fail.”

I worked around that by allowing var/lock to be world read/writable (just for now, at least).

I guess I also screwed up the ln -s command, as you pointed out. To be sure it’s right this time I copied the real file and the result is shown below.

/usr/lib64/jvm/jre/lib/ext # ls -la
total 3068
drwxr-xr-x  2 root root    4096 2010-05-10 14:05 .
drwxr-xr-x 11 root root    4096 2009-12-06 11:49 ..
-rw-r--r--  1 root root    9230 2009-11-26 19:02 dnsns.jar
-rw-r--r--  1 root root  448948 2009-11-26 19:19 gnome-java-bridge.jar
-rw-r--r--  1 root root  496631 2009-11-26 19:05 localedata.jar
-rw-r--r--  1 root root     347 2009-11-26 19:13 meta-index
-rw-r--r--  1 root root 1648612 2009-11-26 18:46 pulse-java.jar
-rw-r--r--  1 root root   59464 2010-05-10 14:05 RXTXcomm.jar
-rw-r--r--  1 root root  211402 2009-11-26 19:06 sunjce_provider.jar
-rw-r--r--  1 root root  239876 2009-11-26 19:01 sunpkcs11.jar

Now I have fixed the permission issue and I have the real RXTXcomm.jar in /usr/lib64/jvm/jre/lib/ext. However, I still cannot get my java app to find any serial ports on openSUSE. The app works on Ubuntu and Windows.

Any more suggestions?

Look in the kernel messages at boot to see if the serial ports were detected. You may have to load the driver since it’s a USB serial port. If needed add the module name to /etc/sysconfig/kernel, variable MODULES_LOADED_ON_BOOT.

Thanks again. I got one step further. As a temporary step, I did this:
chmod 666 /dev/ttyUSB0

That allowed the serial port to be visible to my java app and my app now starts, run, and lists the serial ports. All this is with /usr/lib64/jvm/jre-1.6.0-openjdk/bin/java.

However, as soon as serial data comes in, the app crashes. Here’s the message.

Experimental: JNI_OnLoad called.
Stable Library

Native lib Version = RXTX-2.1-7
Java lib Version = RXTX-2.1-7

A fatal error has been detected by the Java Runtime Environment:

SIGSEGV (0xb) at pc=0x00007f3a01a96462, pid=6434, tid=139887112681744

JRE version: 6.0-b16

Java VM: OpenJDK 64-Bit Server VM (14.0-b16 mixed mode linux-amd64 )

Distribution: Custom build (Thu Nov 26 23:44:19 UTC 2009)

Problematic frame:

C [librxtxSerial.so+0x6462] read_byte_array+0x52

An error report file with more information is saved as:

hs_err_pid6434.log

If you would like to submit a bug report, please include

instructions how to reproduce the bug and visit:

Bugzilla Main Page

The crash happened outside the Java Virtual Machine in native code.

See problematic frame for where to report the bug.

Aborted

That makes me want to try the Sun JRE, but when I try it I am back to square one and I cannot even get the rxtxSerial modules/jars on the java path. The error is the same as in my original post. The only progress I was able to make was with OpenJDK.

Persevere with Sun Java, this looks like an OpenJDK bug.

I tested on another computer. The error is identical with the Sun java.

JRE version: 6.0_16-b01

Java VM: Java HotSpot™ 64-Bit Server VM (14.2-b01 mixed mode linux-amd64 )

Problematic frame:

C [librxtxSerial.so+0x6462] read_byte_array+0x52

Compare that to the OpenJDK error. Same message.

JRE version: 6.0-b16

Java VM: OpenJDK 64-Bit Server VM (14.0-b16 mixed mode linux-amd64 )

Distribution: Custom build (Thu Nov 26 23:44:19 UTC 2009)

Problematic frame:

C [librxtxSerial.so+0x6462] read_byte_array+0x52

Ah, looks like a known bug:

status. No success. Everything works on Windows but not on Ubuntu or openSUSE. Giving up for the moment…

Did you try the patched rxtx package mentioned in that thread?

Yes, I tried rxtx-2.2pre2-bins. It solved the crash, but it didn’t work. No crash, but no communication either. No serial data was received. (The data does come if I connect to the serial port with minicom.)

I’m wondering if that updated rxtxSerial will work without updating the Java app? I don’t have the java source code and the java app was built with the prior version of rxtxSerial.

Shouldn’t have to since class libraries are linked at runtime. Unless the RXTX API has changed.

I don’t think the API has changed. I am baffled that it works on Windows but not on Linux after I have solved all the errors on Linux.

The lock file problems are solved,
the USB serial driver is loaded,
cp210x converter is attached to ttyUSB0,
ttyUSB0 has the right permissions,
ttyUSB0 works with minicom,
I have the right RXTXcomm.jar,
I have the right librxtxSerial.so,
they are in the path
and I’m not getting any errors…
It seems I have done everything, but it doesn’t work in either Ubuntu or openSUSE (and it does work in Windoze).

Have you tried asking the developer of rxtx?

I’ve been on the mailing list, yes.

Are there any simple test programs that come with rxtx to check its operation? A terminal program perhaps?

That is a great idea. If there isn’t one, there should be.

Update. I got rxtx serial working on Ubuntu. Not yet on openSUSE, but I’m going to give it another try with a fresh install as soon as my new drive arrives.

Hi,

I had similar problems with RXTX in pair with BT747 installed from Application:Geo repository on my OpenSUSE 11.3 installation.

The RXTX backend worked fine under root user but it didn’t under regular user. There are was several problems with access rights to the serial port (user must have access to the USB Serial port, that mean must be included to “dialout”, “tty” and “uucp” groups). But after the applying all necessary groups to the user RXTX still didn’t work.

After the googling the problem I found that RXTX trying to lock the serial port to prevent simultaneous access from another applications. It use a lock file in /var/lock dir.

There are two ways to solve it:

  1. rebuild RXTX package with option --disable-lockfiles to avoid creating lock files
  2. give access to create locks

As far as nolocking option not recommended by RXTX team I choose the second way, change the group owner for the /var/lock dir from root to lock group and assign user to lock group.

Now RXTX itself and BT747 works fine.

Olexa,

The 2nd way you instructed worked fine with my opensuse 11.4 86_64
To fulfil your 2nd tip:


useradd -G lock --system -c "Lock system user" lock
chown -R lock:lock /var/lock

There’s a 3rd way to work around this situation:

Update the rxtxserial library:
You can replace the with librxtxSerial.so file with the one inside the rxtx-2.2pre2-bins.zip file:

Download - Rxtx

Hope this helps