The Architecture of the Java Communications API
Because the Java Communications API is a standard extension, it is not installed by default with the JDK. You have to download it from http://java.sun.com/products/javacomm/ and install it separately. The current version is 3.0. However. this is only available for Linux and Solaris. Version 2.0 was also available on Windows. However, Sun recently retired that version. At the time of this writing you can find it at http://javashoplm.sun.com/ECom/docs/Welcome.jsp?StoreId=22&PartDetailId=7235-javacomm-2.0-spec-oth-JSpec&SiteId=JSC&TransactionId=noreg but I wouldn count on that URL lasting forever. If you can find a copy, the difference between 2.0 and 3.0 is not huge (with the exception of Windows support), just a couple of extra methods here and there.
|
The Java Communications API contains a single package, javax.comm, which holds a bakers dozen of classes, exceptions, and interfaces. Because the Comm API is a standard extension, the javax prefix is used instead of the java prefix. The Comm API also includes a DLL or shared library containing the native code to communicate with the ports, and a few driver classes in the com.sun.comm package that mostly handle the vagaries of Unix or Wintel ports. Other vendors may need to muck around with these if they e porting the Comm API to another platform (e.g., the Mac or Pocket PC), but as a user of the API, youll only concern yourself with the documented classes in javax.comm.
javax.comm is divided into high-level and low-level classes. High-level classes are responsible for controlling access to and ownership of the communication ports and performing basic I/O. The CommPortIdentifier class lets you find and open the ports available on a system. The CommPort class provides input and output streams connected to the ports. Low-level classesSerialPort and ParallelPort, for examplemanage interaction with particular kinds of ports and help you read and write the control wires on the ports. They also provide event-based notification of changes to the state of the port.
Категории |