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
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.
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
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.
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.
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).
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.
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:
rebuild RXTX package with option --disable-lockfiles to avoid creating lock files
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.