SerialPort for Java

Package components

spd

spd is written in ANSI standard C and initially runs under Linux. It is a non-threaded server which handles all events on TCP connections and serial ports asynchronously. It's sole configuration requirements are to set the port it listens on and to define the serial ports it is allowed to provide access to. The port defaults to 16001.

spc

This is a simple command line utility that can display spd's current status and can be used to shut it down.

SerialPort applications interfaces

Two SerialPort interfaces have been implemented, one for ANSI C and one for Java:

The interfaces are functionally equivalent though, because of language differences, there is not an exact 1:1 correspondence between C function calls and Java methods. However, it is always possible to combine Java methods to get the exact equivalent of the corresponding C function. Comparing TestSPD.java and testspd.c sources shows exactly how to achieve this. Both test harnesses run the same set of test scripts.

Test harnesses and debugging aids

testspd and TestSPD

These are script driven test harnesses for the C and Java interfaces respectively. They can exercise all interface functions and corresponding server capabilities. A set of test scripts are provided that can be run by either test harness. All operate with the example spd.conf file and cause the server to send data to and from disk files and a single serial line, which should have sptarget attached to the remote end.

Both implement the login command. It is built on top of the SerialPort interface and designed to login to a host running OS-9. If you need to run it against another system you'll need to change the prompts that it recognises. It was written this way because an OS-9 system was the only available target machine.

spd_regress and Java_regress

The C regression tests are run by the spd_regress script and the Java regression tests are run by the Java_regress script. They start a copy of spd, run the tests and then use spc to stop the server. As each test is run the test harness output is compared with a set of expected results by using diff and the differences are displayed. The expected results are kept in the result*.txt files.

All scripts and results files and in the data subdirectory.

Test scripts that do not require a serial connection (they use files instead) are in the test[0-9].txt files. These are run by default if spd_regress and Java_regress have no parameters supplied other than options.

Scripts that exercise a real serial connection are in the stest[0-9].txt files. These are run if spd_regress and Java_regress have stest supplied as the only non-option parameter. These scripts are designed to be run with the sptarget utility running at the remote end of the line. The stest0.txt script is written on the assumption that the following logins exist on the machine at the far end of the line:

Login name Password Description
spt blank starts sptarget instead of a shell. It logs out when sptarget receives Q.
sptarget A nonexistent login name.
cc kiwi A login to a shell that understands dir as the command to list a directory and x as a logout alias.

These scripts use the builtin login command in testspd and TestSPD to log on to the users. See the description of these programs for details.

sptarget

This is a test utility that provides known a remote application to allow the SerialPort functions and server to be exercised over an RS-232 line. It was initially developed to run under the Microware OS/9 operating system, but can be compiled and run within a Linux environment.

The stest*.txt files are scripts that are designed to be run against this program using a serial connection. sptarget may be run on a separate host or on the same host via a loopback cable. The spttest*.txt scripts are intended solely to test sptarget. They are designed to be input directly to sptarget's standard input. file1.txt is referenced by them. It contains data to be returned by sptarget.

Buffer overflow testing

The btest1.txt script is designed allow the test harnesses to check buffer overflow conditions. It will only work correctly if the circular buffers are set to 64 bytes capacity by setting maxmessage to 32 in spd.conf.

quicktest

This is a simple shell script to quickly run a single script against spd via the testspd test harness. It starts a copy of spd, runs the test and then uses spc to stop the server.

multitest

This is a simple shell script to run multiple copies of testspd against spd. One copy of testspd is started for each command line argument and the results for each copy of testspd are written to separate files named multi_BASE where BASE is the basename of the input script file. Under Kernel 2.4 it failed entirely to track the test progress or stop the server after the last client had stopped. If you have this problem stop the script with ^C, monitor progress by issuing ps; spc status commands until only the server is running and then stop it with an spc stop command.

JTerm

This is a pure Java terminal emulator using SerialPort Java extensions to access remote systems via a serial connection. Its components are supplied in the jterm subdirectory as part of the source archive. It is built with the rest of the package. It is run with the command java JTerm. All other information is available through its GUI and the automatically generated documentation provided by make docs.

It is currently limited to "glass teletype" operation: it does not currently understand escape sequences, but it should log in to most shells and communicate with the sptarget utility.

Documentation

Manpages for spd, spc and sptarget are installed when the programs and libraries are installed.

Web-based documentation is generated into the docs subdirectory by running

make docs

You can permanently install the document set by copying everything in the docs directory and its subdirectories to any location that's convenient for access by your web browsers or servers. Access this document set via the index.html page in the docs subdirectory.