| 
 | comm API Version 2.0 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjavax.comm.CommPort
A communications port. CommPort is an abstract class that
 describes a communications port made available by the underlying system.
 It includes high-level methods for controlling I/O that are common to
 different kinds of communications ports. SerialPort and
 ParallelPort are subclasses of CommPort that
 include additional methods for low-level control of physical communications
 ports.
 
 There are no public constructors for
 CommPort. Instead an application should use the static method
 CommPortIdentifier.getPortIdentifiers to generate a list of
 available ports. It then chooses a port from this list and calls
 CommPortIdentifier.open to create a CommPort object.
 Finally, it casts the CommPort object to a physical
 communications device class like SerialPort or
 ParallelPort.
 
 After a communications port has been identified and opened it can be
 configured with the methods in the low-level classes like
 SerialPort and ParallelPort. Then an IO stream can
 be opend for reading and writing data. Once the application is done with
 the port, it must call the close method. Thereafter the application must
 not call any methods in the port object. Doing so will cause a
 IllegalStateException to be thrown.
CommPortIdentifier, 
ParallelPort, 
SerialPort| Field Summary | |
| protected  String | namename of the port | 
| Constructor Summary | |
| CommPort() | |
| Method Summary | |
|  void | close()Closes the communications port. | 
| abstract  void | disableReceiveFraming()Disables receive framing. | 
| abstract  void | disableReceiveThreshold()Disables receive threshold. | 
| abstract  void | disableReceiveTimeout()Disables receive timeout. | 
| abstract  void | enableReceiveFraming(int framingByte)Enables receive framing, if this feature is supported by the driver. | 
| abstract  void | enableReceiveThreshold(int thresh)Enables receive threshold, if this feature is supported by the driver. | 
| abstract  void | enableReceiveTimeout(int rcvTimeout)Enables receive timeout, if this feature is supported by the driver. | 
| abstract  int | getInputBufferSize()Gets the input buffer size. | 
| abstract  InputStream | getInputStream()Returns an input stream. | 
|  String | getName()Gets the name of the communications port. | 
| abstract  int | getOutputBufferSize()Gets the output buffer size. | 
| abstract  OutputStream | getOutputStream()Returns an output stream. | 
| abstract  int | getReceiveFramingByte()Gets the current byte used for receive framing. | 
| abstract  int | getReceiveThreshold()Gets the integer value of the receive threshold. | 
| abstract  int | getReceiveTimeout()Gets the integer value of the receive timeout. | 
| abstract  boolean | isReceiveFramingEnabled()Checks if receive framing is enabled. | 
| abstract  boolean | isReceiveThresholdEnabled()Checks if receive threshold is enabled. | 
| abstract  boolean | isReceiveTimeoutEnabled()Checks if receive timeout is enabled. | 
| abstract  void | setInputBufferSize(int size)Sets the input buffer size. | 
| abstract  void | setOutputBufferSize(int size)Sets the output buffer size. | 
|  String | toString()Returns a String representation of this communications port. | 
| Methods inherited from class java.lang.Object | 
| clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait | 
| Field Detail | 
protected String name
| Constructor Detail | 
public CommPort()
| Method Detail | 
public String getName()
public String toString()
public abstract InputStream getInputStream()
                                    throws IOException
getInputStream returns
 null.
 
 The read behaviour of the input stream returned by
 getInputStream depends on combination of the threshold and
 timeout values. The possible behaviours are described in the table below:
 
| Threshold | Timeout | Read Buffer Size | Read Behaviour | ||
|---|---|---|---|---|---|
| State | Value | State | Value | ||
| disabled | - | disabled | - | n bytes | block until any data is available | 
| enabled | m bytes | disabled | - | n bytes | block until min(m,n) bytes are available | 
| disabled | - | enabled | x ms | n bytes | block for x ms or until any data is available | 
| enabled | m bytes | enabled | x ms | n bytes | block for x ms or until min(m,n) bytes are available | 
Note, however, that framing errors may cause the Timeout and Threshold values to complete prematurely without raising an exception.
Enabling the Timeout OR Threshold with a value a zero is a special case. This causes the underlying driver to poll for incoming data instead being event driven. Otherwise, the behaviour is identical to having both the Timeout and Threshold disabled.
IOException - if an I/O error occurred
public abstract OutputStream getOutputStream()
                                      throws IOException
getOutputStream
 returns null.
IOException - if an I/O error occurredpublic void close()
close when it is done with the
 port. Notification of this ownership change will be propagated to all
 classes registered using addPortOwnershipListener.
public abstract void enableReceiveThreshold(int thresh)
                                     throws UnsupportedCommOperationException
read
 from the input stream for this port will return immediately.
 
 enableReceiveThreshold is an advisory method which the
 driver may not implement. By default, receive threshold is not enabled.
 
 An application can determine whether the driver supports this feature
 by first calling the enableReceiveThreshold method and then
 calling the isReceiveThresholdEnabled method. If
 isReceiveThresholdEnabled still returns false, then receive
 threshold is not supported by the driver. If the driver does not
 implement this feature, it will return from blocking reads at an
 appropriate time.
 
 See getInputStream for description of exact behaviour.
thresh - when this many bytes are in the input buffer, return
                  immediately from read.
UnsupportedCommOperationException - if receive threshold is not
              supported by the underlying driver.public abstract void disableReceiveThreshold()
public abstract boolean isReceiveThresholdEnabled()
true if the driver supports receive threshold.public abstract int getReceiveThreshold()
public abstract void enableReceiveTimeout(int rcvTimeout)
                                   throws UnsupportedCommOperationException
read
 from the input stream for this port will return immediately.
 
 enableReceiveTimeout is an advisory method which the driver
 may not implement. By default, receive timeout is not enabled.
 
 An application can determine whether the driver supports this feature
 by first calling the enableReceiveTimeout method and then
 calling the isReceiveTimeout method. If
 isReceiveTimeout still returns false, then receive timeout
 is not supported by the driver.
 
 See getInputStream for description of exact behaviour.
rcvTimeout - when this many milliseconds have elapsed, return
      immediately from read, regardless of bytes in
      input buffer.
UnsupportedCommOperationException - if receive
      timeout is not supported by the underlying driver.public abstract void disableReceiveTimeout()
public abstract boolean isReceiveTimeoutEnabled()
true if the driver supports receive timeout.public abstract int getReceiveTimeout()
public abstract void enableReceiveFraming(int framingByte)
                                   throws UnsupportedCommOperationException
read
 from the input stream for this port will return immediately.
 
 enableReceiveFraming is an advisory method which the driver
 may not implement. By default, receive framing is not enabled.
 
 An application can determine whether the driver supports this feature
 by first calling the enableReceiveFraming method and then
 calling the isReceiveFramingEnabled method. If
 isReceiveFramingEnabled still returns false, then receive
 framing is not supported by the driver.
 
Note: As implemented in this method, framing is not related to bit-level framing at the hardware level, and is not associated with data errors.
framingByte - this byte in the input stream suggests the end of
              the received frame. Blocked reads will return immediately.
              Only the low 8 bits of framingByte are used
              while the upper 24 bits are masked off. A value outside
              the range of 0-255 will be converted to the value of its
              lowest 8 bits.
UnsupportedCommOperationException - if receive
              timeout is not supported by the underlying driver.public abstract void disableReceiveFraming()
public abstract boolean isReceiveFramingEnabled()
true if the driver supports receive framing.public abstract int getReceiveFramingByte()
getReceiveFramingByte
 is an integer, the low 8 bits of which represent the current byte
 used for receive framing.
 Note: As implemented in this method, framing is not related to bit-level framing at the hardware level, and is not associated with data errors.
public abstract void setInputBufferSize(int size)
size - size of the input bufferpublic abstract int getInputBufferSize()
public abstract void setOutputBufferSize(int size)
size - size of the output bufferpublic abstract int getOutputBufferSize()
| 
 | comm API Version 2.0 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||