Serial port data acquisition in Java

Paul Gettings
Department of Geology & Geophysics
University of Utah

SerialDAS is a set of Java classes that allow for real-time data acquisition from serial ports. The classes use Sun's CommAPI (javax.comm) package and can use RXTX to provide the native methods under Linux. The classes spawn a separate thread to read the serial ports and buffer records of data, which are then read by the controlling thread.

The code has been tested on Win32 with Sun's JDK 1.3, Linux with Sun's JDK 1.2.2 and JDK 1.3 (with RXTX on kernels 2.2 and 2.4.0test6), and IBM's JDK 1.3 on Linux. It should work anywhere CommAPI works.

The package is designed to be record oriented, such as from NMEA-compliant devices. This works for the vast majority of scientific instruments, but is less desireable for a truly interactive application. The classes can handle full interactive communications - set no end of record character and a record length of 1.

The package was originally developed to gather data from a system with a Geometrics magnetometer and a NMEA-output GPS. The magnetometer produces data at 10Hz, and the package (with a Swing GUI under X) is able to read and process the data for plotting in real-time, using <30% of a PPro 200. By multi-threading the data acquisition, data is not lost in the event of slow screen updates, etc.

The most current version is thought to be quite stable; a test run with the LogTD program (see below) ran for over 171,000 points at a 1Hz sampling rate without fault.

The documentation of the code (as produced by javadoc) is available here. You want to start with the SerialDAS class, and leave the PortParams and SerialIO classes for extensions, etc.

The most current release is a gzip'd tarball here. This version has been tested on linux, but should work anywhere javax.comm does. The tarball does not include javax.comm, but does include a jar file of the classes.

This code is released under the LGPL. Please submit improvements, bug reports, or feature requests; otherwise, this code will only be updated when I need it to do something more. :)


Example Programs using SerialDAS


gettings@mines.utah.edu