Link to home
Start Free TrialLog in
Avatar of ConsJMEA
ConsJMEA

asked on

Linux serial port or RXTX library not visible for Java software ADTPro

Hello. I'm trying to install ADTPro (http://adtpro.sourceforge.net/) in my Linux PC. I've installed the ADTPro server but when I try to use the serial port I receive the message that there are not serial ports, or that the RXTX library is not installed or is not visible. My data is:

uname -a
Linux Geminis002 3.2.0-4-686-pae #1 SMP Debian 3.2.60-1+deb7u1 i686 GNU/Linux

ls -l /home/jmea/ADTPro-2.0.0/lib/rxtx/
total 12
drwxr-xr-x 2 jmea jmea 4096 jul 25 13:21 ch-rxtx-2.2-20081207-win-x64
drwxr-xr-x 6 jmea jmea 4096 jul 25 13:21 rxtx-2.1-7-bins-r2
drwxr-xr-x 9 jmea jmea 4096 jul 25 13:21 rxtx-2.2pre2-local

If I start minicom -s for testing serial port:

| A - Dispositivo Serial            : /dev/ttyUSB0                      |
| B - Localización del Archivo de Bloqueo : /var/lock                   |
| C - Programa de Acceso           :                                    |
| D - Programa de Salida             :                                  |
| E - Bps/Paridad/Bits             : 115200 8N1                         |
| F - Control de Flujo por Hardware: Sí                                 |
| G - Control de Flujo por Software: No

I don't know what means that RXTX library must be "visible". I suppose that is something related with Java but I'm not sure. I am newbie with Linux.

I'm using a Plugable USB to RS-232 DB9 Serial Adapter (Prolific PL2303HX Chipset). It looks like this adapter is recognized by Linux:

dmesg | grep tty
[    0.000000] console [tty0] enabled
[   10.667195] usb 2-2: pl2303 converter now attached to ttyUSB0

I would appreciate some help.
Avatar of gheist
gheist
Flag of Belgium image

rxtx library is native linux library, so it ends with .so and is somewhere in path seen by ldconfig.
Avatar of ConsJMEA
ConsJMEA

ASKER

I've done this command:

sudo ldconfig -p | grep -i rxtx

without any result. Does this means that I need to add the library?

I've seen several ways to add a library but I'm not sure which one is right for this case.
Indeed you must add the library.

Download:
http://mfizz.com/oss/rxtx-for-java

Place so files under say /opt/rxtx/lib and make a file in /etc/ld.so.conf.d/ , then run ldconfig

Now check again with java

Maybe you need to replace jar inside your application etc
I've followed the instructions but the result is the same:

ls -l /opt/rxtx/lib
total 264
-rw-r--r-- 1 root root    256 jul 30 17:44 BuildInfo.txt
-rw-r--r-- 1 root root   1057 jul 30 17:44 Install.txt
-rwxr-xr-x 1 root root  43955 jul 30 17:44 librxtxParallel.so
-rwxr-xr-x 1 root root 143268 jul 30 17:44 librxtxSerial.so
-rw-r--r-- 1 root root   2098 jul 30 17:44 Readme.txt
-rw-r--r-- 1 root root    833 jul 30 17:44 ReleaseNotes.txt
-rwxr-xr-x 1 root root    819 jul 30 17:44 run-install.sh
-rw-r--r-- 1 root root  60898 jul 30 17:44 RXTXcomm.jar

I've created a file in /etc/ld.so.conf.d called myconf.opt

jmea@Geminis002:/etc/ld.so.conf.d$ cat myconf.opt
/opt/rxtx/lib/
[blank line]

jmea@Geminis002:~$ sudo ldconfig
jmea@Geminis002:~$ sudo ldconfig -p | grep -i rxtx
jmea@Geminis002:~$ [no results]
it takes just *.conf files from .d directory?
Thank you. I've renamed myconf.opt to myconf.conf and:

jmea@Geminis002:~$ sudo ldconfig -p | grep -i rxtx
      librxtxSerial-2.2-20081207.so (libc6) => /opt/rxtx/lib/librxtxSerial-2.2-20081207.so
      librxtxParallel-2.2-20081207.so (libc6) => /opt/rxtx/lib/librxtxParallel-2.2-20081207.so

But when I start the sofware I see:

ADTPro Servidor versión 2.0.0

java.lang.UnsatisfiedLinkError: /home/jmea/ADTPro-2.0.0/lib/rxtx/rxtx-2.2pre2-local/x86_64-unknown-linux-gnu/librxtxSerial.so: /home/jmea/ADTPro-2.0.0/lib/rxtx/rxtx-2.2pre2-local/x86_64-unknown-linux-gnu/librxtxSerial.so: wrong ELF class: ELFCLASS64 (Possible cause: architecture word width mismatch) thrown while loading gnu.io.RXTXCommDriver

The program for start the software is

/home/jmea/ADTPro-2.0.0/adtpro.sh

and this file contains:

#!/bin/sh
#
# ADTPro - *nix startup shell script
#
# Note:
#   Invoke with the name of the communications button to push
#   in order to start with that mode active (i.e. './adtpro.sh ethernet')
#
# You can set two variables here:
#   1. $MY_JAVA_HOME - to pick a particular java to run under
#   2. $ADTPRO_HOME - to say where you installed ADTPro
#
# Set default ADTPRO_HOME to be the fully qualified
# current working directory.
export ADTPRO_HOME="`dirname \"$0\"`"
cd "$ADTPRO_HOME"
export ADTPRO_HOME=`pwd`

# Uncomment and modify one or both of the lines below if you
# want to specify a particular location for Java or ADTPro.
# NOTE: be sure to include a trailing slash on MY_JAVA_HOME,
# but not on ADTPRO_HOME.
#
# export MY_JAVA_HOME=/usr/local/java/bin/
# export ADTPRO_HOME=~/myuser/adtpro

OS=`uname`
OS_ARCH=`uname -p`

# For Linux, use this:
if [ "$OS" = "Linux" ]; then
  if [ -f /usr/bin/raspi-config ]; then
    export RXTXLIB=lib/rxtx/rxtx-2.2pre2-local/arm
    ADTPRO_EXTRA_JAVA_PARMS="-Dgnu.io.rxtx.SerialPorts=/dev/ttyUSB0:/dev/ttyAMA0"
  elif [ "$OS_ARCH" = "i686" ]; then
    export RXTXLIB=lib/rxtx/rxtx-2.2pre2-local/i686-pc-linux-gnu
  else
    if [ "$OS_ARCH" = "i386" ]; then
      export RXTXLIB=lib/rxtx/rxtx-2.2pre2-local/i686-pc-linux-gnu
    else  
      export RXTXLIB=lib/rxtx/rxtx-2.2pre2-local/x86_64-unknown-linux-gnu
    fi
  fi
fi

# For OSX, use this:
if [ "$OS" = "Darwin" ]; then
  if [ "$OS_ARCH" = "powerpc" ]; then
    export RXTXLIB=lib/rxtx/rxtx-2.1-7-bins-r2/Mac_OS_X
  else
    export RXTXLIB=lib/rxtx/rxtx-2.2pre2-local/mac-10.5
  fi
fi

# For Solaris, use this:
if [ "$OS" = "SunOS" ]; then
  export RXTXLIB=lib/rxtx/rxtx-2.2pre2-local/sparc-sun-solaris2.10-32
fi

# Set up the library location.
export TWEAK1="-Djava.library.path="
export TWEAK=$TWEAK1$ADTPRO_HOME/$RXTXLIB

if [ "$1x" = "headlessx" ]; then
  shift
  if [ "$1x" = "x" ] || [ ! -f /usr/bin/xvfb-run ]; then
    if [ ! -f /usr/bin/xvfb-run ]; then
      echo "Headless operation requires xvfb."
    else
      echo "usage: adtpro.sh [ headless ] [ serial | ethernet | audio | localhost ]"
    fi
    exit 1
  else
    HEADLESS="xvfb-run --auto-servernum "
  fi
fi

cd "$ADTPRO_HOME"/disks
$HEADLESS"$MY_JAVA_HOME"java -Xms256m -Xmx512m "$TWEAK" $ADTPRO_EXTRA_JAVA_PARMS -cp ../lib/ADTPro-2.0.0.jar:../"$RXTXLIB"/../RXTXcomm.jar:../lib/AppleCommander/AppleCommander-1.3.5.13-ac.jar org.adtpro.ADTPro $*

*** End of file ***
Run ldd against 32bit .so library under your java application. It will not load any system library, just that included. (you can delete .conf and both .so files, and rerun ldconfig. They had no effect unless you greatly rewrite script.
Thank you. I've tweaked the script and I can start the software without error messages. I'm now resolving some problems software-related because the drop-down list of serial ports is empty. I'll let you know the result.
I've created a log when ADTPro starts.  The application ask RXTX what ports it can see, and finds none. It looks like RXTX isn't able to see the serial port on the Linux side. There are some way I can test the serial port with RXTX?

I can see:

dmesg | grep -i tty
[    0.000000] console [tty0] enabled
[   10.105713] usb 2-2: pl2303 converter now attached to ttyUSB0
[   26.003798] Bluetooth: RFCOMM TTY layer initialized

but I don't know if this is enough.

Thanks
According to this:
java.lang.UnsatisfiedLinkError: /home/jmea/ADTPro-2.0.0/lib/rxtx/rxtx-2.2pre2-local/x86_64-unknown-linux-gnu/librxtxSerial.so: /home/jmea/ADTPro-2.0.0/lib/rxtx/rxtx-2.2pre2-local/x86_64-unknown-linux-gnu/librxtxSerial.so: wrong ELF class: ELFCLASS64 (Possible cause: architecture word width mismatch) thrown while loading gnu.io.RXTXCommDriver

You are loading 64bit library in 32bit system.
I've solved this problem. Now I can start without errors. The command uname returns:
uname -p
unknown

I don't know why. My computer is a ThinhPad G41 but the motherboard was changed by Lenovo support several years ago. This is why the script couldn't correctly identify my processor.

On adtpro.sh I've commented all lines for Linux IF statements but:

export RXTXLIB=lib/rxtx/rxtx-2.2pre2-local/i686-pc-linux-gnu

is not commented. This way I force the script to use the 32-bit library.

I've also deleted the /opt/rxtx folder and myconf.conf file on /etc/ld.so.conf.d (for going back to original state)

Now I can start ADTPro without any error message. But if I try to set the serial port there is no options in the drop-down list.

The ADTPro support team has instructed to me how I can log the start process. The contents of /disks/ADTProTrace.txt:

1/08/14 14:04:35 Gui Constructor entry.
1/08/14 14:04:35 Gui.getWorkingDirectory(): /home/jmea/ADTPro-2.0.0/disks/
1/08/14 14:04:35 Gui.actionPerformed() entry, responding to Desconectar; previous button is Desconectar
1/08/14 14:04:35 Gui.actionPerformed() exit.
1/08/14 14:04:35 Gui setting screen coordinates from properties file values.
1/08/14 14:04:36 SerialConfig.enumeratePorts() entry.
1/08/14 14:04:36 SerialConfig.enumeratePorts() about to attempt to instantiate rxtx library.
1/08/14 14:04:36 SerialConfig.enumeratePorts() completed instantiating rxtx library.
1/08/14 14:04:36 SerialConfig.enumeratePorts() exit.
1/08/14 14:04:36 SerialConfig Constructor exit.
1/08/14 14:04:36 AudioConfig().ctor Added device PulseAudio Mixer at index 0, mixer index 1.
1/08/14 14:04:36 AudioConfig().ctor Added device default [default] at index 1, mixer index 2.
1/08/14 14:04:36 AudioConfig().ctor Added device I82801DBICH4 [plughw:0,0] at index 2, mixer index 3.
1/08/14 14:04:36 AudioConfig().ctor Added device I82801DBICH4 [plughw:0,1] at index 3, mixer index 4.
1/08/14 14:04:36 AudioConfig().ctor Added device I82801DBICH4 [plughw:0,2] at index 4, mixer index 5.
1/08/14 14:04:36 AudioConfig().ctor Added device I82801DBICH4 [plughw:0,3] at index 5, mixer index 6.
1/08/14 14:04:36 AudioConfig().ctor Added device I82801DBICH4 [plughw:0,4] at index 6, mixer index 7.
1/08/14 14:04:36 AudioConfig().ctor Added device Modem [plughw:1,0] at index 7, mixer index 8.
1/08/14 14:04:36 AudioConfig().ctor Added device Port I82801DBICH4 [hw:0] at index 8, mixer index 9.
1/08/14 14:04:36 AudioConfig().ctor Added device Port Modem [hw:1] at index 9, mixer index 10.
1/08/14 14:04:36 AudioConfig().ctor Added device Port Unknown Name at index 10, mixer index 11.
1/08/14 14:04:36 AudioConfig.ctor() Found a GUI mixer index of: 0
1/08/14 14:04:36 which is a hardware index of: 0
1/08/14 14:04:36 AudioConfig Constructor exit.
1/08/14 14:04:36 args.length = 0
1/08/14 14:04:36 Gui Constructor exit.
1/08/14 14:04:43 Gui.actionPerformed() entry, responding to Serie; previous button is Desconectar
1/08/14 14:04:43 Gui.startComms() entry.
1/08/14 14:04:43 Gui.startComms() didn't have an old thread to stop.
1/08/14 14:04:43 Gui.startComms() exit; returning true.
1/08/14 14:04:43 SerialConfig.showSingleton() showing tab 0.
1/08/14 14:04:43 SerialConfig.enumeratePorts() entry.
1/08/14 14:04:43 SerialConfig.enumeratePorts() about to attempt to instantiate rxtx library.
1/08/14 14:04:43 SerialConfig.enumeratePorts() completed instantiating rxtx library.
1/08/14 14:04:43 SerialConfig.enumeratePorts() exit.
1/08/14 14:04:47 SerialConfig.actionPerformed() entry, responding to Ok
1/08/14 14:04:48 SerialConfig.actionPerformed() exit.
1/08/14 14:04:48 Gui.actionPerformed() entry, responding to Serie; previous button is Desconectar
1/08/14 14:04:49 Gui.actionPerformed() entry, responding to Desconectar; previous button is Desconectar
1/08/14 14:04:49 Gui.actionPerformed() exit.
1/08/14 14:04:49 Gui.actionPerformed() exit.
1/08/14 14:04:49 Gui.actionPerformed() exit.
1/08/14 14:04:56 Gui.getWorkingDirectory(): /home/jmea/ADTPro-2.0.0/disks/

End of file

The application ask RXTX what ports it can see, and finds none. It looks like RXTX isn't able to see the serial port on the Linux side.
Can you try newer RXTX library? i.e .jar and .so-s ?
I'm not sure if I've understood your question. I can use some file downloaded from http://mfizz.com/oss/rxtx-for-java and modify the script for use that file in place of the file provided by ADTPro. This is what you are asking for?
Yes, please try more recent version of serial library.
Maybe old version never heard of USB serial ports...
I've replaced the .so and .jar file but the problem remains.

I've tested the software in another computer ThinkPad T400 (32 bits) with dual boot:

jmea@Geminis004:~$ uname -a
Linux Geminis004 3.2.0-4-686-pae #1 SMP Debian 3.2.60-1+deb7u1 i686 GNU/Linux

uname -p
unknown

and the problem is the same.

Then I've placed the computer on a docking station with a physical serial port:

dmesg | grep -i tty
[ 0.000000] console [tty0] enabled
[ 1.044995] 00:0a: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A
[ 17.325194] Bluetooth: RFCOMM TTY layer initialized

But the problem remains. Also I've tested on Lenovo IdeaPad Y510p (64 bits) without succes.

There are some team in charge for RXTX library? I can contact them to explain the problem.
ASKER CERTIFIED SOLUTION
Avatar of gheist
gheist
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you. The problem need more time to be solved. You have provided to me valuable information for understand the causes and find a solution.