

In part I, we will show how to send and receive data over serial ports using the Boost C++ libraries in order to obtain sensor data. In this two-part article series, we will use a GPS receiver that supports the NMEA 0183 data specification as an example of a serial device with which to communicate. Communicating with these devices is a necessity, and, as the machines that they connect to range in architecture, it is important to write code that is portable and can be used in different environments.

While physical serial ports may not be as commonplace on new hardware as they once were, many devices still provide serial connectivity by creating virtual serial ports in the operating system that are associated with USB interfaces.Įxternal modems may be the most familiar serial device, but many devices communicate serially, such as bar code scanners, printers, LCD panels and the like that are commonly used in the commercial world. Since the early days of the IBM PC, serial ports supporting the RS-232 standard have been used to connect external devices to computers. I also use it to interface the Factor programming language with the same XBee module.MaBy Charles Calkins, OCI Senior Software Engineer INTRODUCTION This is what I chose to interface a Scala program with a XBee Pro module through a serial interface to interact with my students devices.

However, there exist at least one other solution which does not require the use of any external library. It is simpler to setup than RXTX, is hosted on GitHub and is actively maintained. PureJavaComm is a drop-in replacement for those two libraries, written in Java and using JNA to interface with the system. The last stable version is 2.1.7 from 2006. It is hosted on a CVS server and it looks like the 2.2 release will never go out since it got stuck on version 2.2pre2 released in 2009. RXTX is a mix between Java code and C code accessed through the Java native interface.

It is available for Solaris SPARC, Solaris x86, and Linux x86. The Java Communications 3.0 API looks awfully old and unmaintained. There exist several solutions to do this in Java: Every once in a while, I see people having a hard time accessing a RS232 or USB serial port from Java.
