SerialPort for Java

Introduction

There are a number of applications that support hand-held devices or computer-controlled equipment. Much of this equipment uses a serial connection for configuration, software upgrades and/or data transfer. Despite the best efforts of PC vendors these serial connections are not about to go away. There are good reasons for this. These range from concerns about privacy or RF pollution, which can restrict the use or Bluetooth and other wireless connections, to physical size, power consumption or unsuitablity for the application. An example of the latter would be attempting to use CAT-5 wiring to connect to a hand-held device or an instrument designed for use in a light aircraft.

Taking another angle, there are clear advantages to writing these applications in Java because a single version of each application can be run on anything from a large server to a PDA or other handheld device. However, as soon as we look closely at doing so we find that while Java is quite capable of handling the data processing aspects of the task, its I/O capabilities are essemtially limited to using TCP/IP connections, interacting with terminals and print spoolers or writing files onto storage media. It does not support access to serial devices, so it cannot use either serial ports or USB to communicate with the types of device described above.

Implementation

SerialPort for Java was developed to overcome at least some of these limitations. It is an Open Source package that provides Java applications with access to serial ports via a single, straight forward interface class. Using this, the application is capable of handling serial ports that are attached to the computer running the Java application or to a remote host. If the host operating system, like Linux, can make a USB connection appear to be a normal serial connection, then this can also be used by any application that uses SerialPort. Each instance of the SerialPort class provides a connection to a single serial port, so an application can control more than one port and conversely, each port on a host computer can be handled by a different application.

The package was developed to provide a simply installed and configured way for Java and C programs to transfer data to and from serial ports. The initial version is restricted to using RS-232 and has had its operation verified at up to 9600 baud. It consists of a number of parts:

The interfaces are implemented in ANSI standard C and Java 2 (J2EE).

The data transfer protocol allows programs using the interface routines to:

Downloads and external dependencies

You can get the source and JAR files from the SerialPort for Java project at SourceForge.net

SerialPort was developed using Sun's Java J2EE SDK 1.4 and should be forward compatible without restriction. Java components are documented by the javadoc tool, which is a standard part of the Sun J2EE SDK. C components are documented using the Cdoc tool. A copy of this documentation is referenced below.

Documentation

All documentation is referenced through the online documentation index.