Chapter 5: Creating a Serial Communication Application


The Java Communication Application Programming Interface (JCA) supports the javax.comm package. This package enables you to use the CommPortIdentifier class to obtain a list of the COM or serial ports on a computer. The javax.comm package also provides the SerialPortEventListener and CommPortOwnershipListener interfaces, which include methods to handle and propagate events associated with serial or COM ports.

This chapter explains how to develop a Serial Communication application using the javax.comm package to send and receive data between the two COM or serial ports on two different computers that are attached using a null modem wire.

Architecture of the Serial Communication Application

The Serial Communication application enables two COM or serial ports to communicate with each other, which enables end users to communicate with each other. The ports of the two computers are connected through a null modem wire. The end user can use the Serial Communication application to specify the communication properties of the ports.

The Serial Communication application uses the following files:

  • PortCommunication.java: Creates a user interface that helps an end user open a COM or serial port for communication, and send and receive data from the COM or serial port. This file invokes the PortPropertyPage.java file to display and set the properties of the port used for communication.

  • PortPropertyPage.java: Enables the end user to specify the properties of a COM or serial port. The various properties of a COM or serial port that an end user can set are baud rate, stop bit, data bit, or parity bit.

Figure 5-1 shows the architecture of the Serial Communication application:

click to expand: this figure shows the sequence in which various files of the serial communication application are used.
Figure 5-1: Architecture of the Serial Communication Application




Developing Applications Using JCA
Developing Applications Using JCA
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 43

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net