Skip to main content

RXTX or what about the serial interfaces

1 reply [Last post]
captainjamescook
Offline
Joined: 2013-01-24
Points: 0

Hi,

thank you for the hard float version for the raspbian on raspberry pi. (eJRE SE 8)
Everything is running fine except the serial interfaces. The librxtx-java in the debian repository is not working. For me that is crucial for the RPi because I need to be able to for example plug in a wifi/zigbee/etc usb dongle and work with that.

Can I expect this to be fixed soon or will I have to wait till Debian updates their packages?

If both optionas are not going to be possible .... how simmilar are the header files of ejre se 8 to ejre 7? With ejre 7 I was able to use the librxtx bundle.

Thanks

James

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
jlaughter
Offline
Joined: 2013-02-05
Points: 0

Hey James,

Actually librxtx-java works fine with 1.8.0. Here's details of what it took to get it working:

- Started with December 2012 hard float Raspbian image
- Installed jdk1.8.0 per https://blogs.oracle.com/hinkmond/entry/quickie_guide_getting_hard_float
- Installed librxtx-java from the repository
- disabled console use of the port http://cae2100.wordpress.com/2012/12/23/raspberry-pi-and-the-serial-port/

All that was the easy part. I was trying to run an example that simply opened the port and copied data to/from the console for a quick test, found here: http://eclipsesource.com/blogs/2012/10/17/serial-communication-in-java-w...

Couple problems with the TwoWaySerialComm code above. One, they didn't import the serial classes, so add this to the top:

import gnu.io.CommPort;
import gnu.io.CommPortIdentifier;
import gnu.io.SerialPort;

Next, the port they're using in the code is 'ttyUSB0', a USB port. If you want to use the UART on the Pi you'll need to change that to 'ttyAMA0'

Next, it never defines the port for rxtx so attempting to use ttyAMA0, ttyUSB0, etc. results in a 'gnu.io.NoSuchPortException'. Add this somewhere ahead of where it opens the port... I started the main method with it:

String SerialPortID = "/dev/ttyAMA0";
System.setProperty("gnu.io.rxtx.SerialPorts", SerialPortID);

Last, compiling requires that you specify specific classpath and library paths for RXTX. Use these commands to compile and run the example after the default installs above:

$ javac -cp /usr/share/java/RXTXcomm.jar:. TwoWaySerialComm.java

$ java -Djava.library.path=/usr/lib/jni -cp /usr/share/java/RXTXcomm.jar:. TwoWaySerialComm

Hope this helps - this'll get the basic example running.

-Jeff