comm
Class SerialPort

java.lang.Object
  extended by comm.CommPort
      extended by comm.SerialPort
All Implemented Interfaces:
CommPortInterface, SerialPortInterface

public abstract class SerialPort
extends CommPort
implements SerialPortInterface

This class models an RS-232 serial communications port.

Version:
2.0.3
Author:
Chris Burdess

Field Summary
static int DATABITS_5
          5 data bit format.
static int DATABITS_6
          6 data bit format.
static int DATABITS_7
          7 data bit format.
static int DATABITS_8
          8 data bit format.
static int FLOWCONTROL_NONE
          No flow control.
static int FLOWCONTROL_RTSCTS_IN
          RTS/CTS flow control on input.
static int FLOWCONTROL_RTSCTS_OUT
          RTS/CTS flow control on output.
static int FLOWCONTROL_XONXOFF_IN
          XON/XOFF flow control on input.
static int FLOWCONTROL_XONXOFF_OUT
          XON/XOFF flow control on output.
static int PARITY_EVEN
          Even parity.
static int PARITY_MARK
          MARK parity scheme.
static int PARITY_NONE
          No parity.
static int PARITY_ODD
          Odd parity.
static int PARITY_SPACE
          SPACE parity scheme.
static int STOPBITS_1
          1 stop bit.
static int STOPBITS_1_5
          1-1½ stop bits.
static int STOPBITS_2
          2 stop bits.
 
Constructor Summary
SerialPort()
          Constructor.
 
Method Summary
abstract  void addEventListener(SerialPortEventListener listener)
          Adds the specified serial port listener to receive serial events.
abstract  boolean isCD()
          Indicates if the CD bit is set.
abstract  boolean isCTS()
          Indicates if the CTS bit is set.
abstract  boolean isDSR()
          Indicates if the DSR bit is set.
abstract  boolean isRI()
          Indicates if the RI bit is set.
abstract  boolean isRTS()
          Indicates if the RTS bit is set.
abstract  void notifyOnBreakInterrupt(boolean enable)
          Instructs the port to notify its listener when there is a break interrupt on the line.
abstract  void notifyOnCarrierDetect(boolean enable)
          Instructs the port to notify its listener when the CD bit changes.
abstract  void notifyOnCTS(boolean enable)
          Instructs the port to notify its listener when the CTS bit changes.
abstract  void notifyOnDataAvailable(boolean enable)
          Instructs the port to notify its listener when input data is available.
abstract  void notifyOnDSR(boolean enable)
          Instructs the port to notify its listener when the DSR bit changes.
abstract  void notifyOnFramingError(boolean enable)
          Instructs the port to notify its listener when a framing error occurs.
abstract  void notifyOnOutputEmpty(boolean enable)
          Instructs the port to notify its listener when the output buffer is empty.
abstract  void notifyOnOverrunError(boolean enable)
          Instructs the port to notify its listener when an overrun error occurs.
abstract  void notifyOnParityError(boolean enable)
          Instructs the port to notify its listener when a parity error occurs.
abstract  void notifyOnRingIndicator(boolean enable)
          Instructs the port to notify its listener when the RI bit changes.
abstract  void removeEventListener()
          Removes the current serial port listener.
 void setRcvFifoTrigger(int trigger)
          Deprecated.  
 
Methods inherited from class comm.CommPort
close, getName, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface comm.SerialPortInterface
getBaudBase, getBaudRate, getCallOutHangup, getDataBits, getDivisor, getEndOfInputChar, getFlowControlMode, getLowLatency, getParity, getParityErrorChar, getStopBits, getUARTType, isDTR, sendBreak, setBaudBase, setCallOutHangup, setDivisor, setDTR, setEndOfInputChar, setFlowControlMode, setLowLatency, setParityErrorChar, setRTS, setSerialPortParams, setUARTType
 
Methods inherited from interface comm.CommPortInterface
close, disableReceiveFraming, disableReceiveThreshold, disableReceiveTimeout, enableReceiveFraming, enableReceiveThreshold, enableReceiveTimeout, getInputBufferSize, getInputStream, getName, getOutputBufferSize, getOutputStream, getReceiveFramingByte, getReceiveThreshold, getReceiveTimeout, isReceiveFramingEnabled, isReceiveThresholdEnabled, isReceiveTimeoutEnabled, setInputBufferSize, setOutputBufferSize, toString
 

Field Detail

DATABITS_5

public static final int DATABITS_5
5 data bit format.

See Also:
Constant Field Values

DATABITS_6

public static final int DATABITS_6
6 data bit format.

See Also:
Constant Field Values

DATABITS_7

public static final int DATABITS_7
7 data bit format.

See Also:
Constant Field Values

DATABITS_8

public static final int DATABITS_8
8 data bit format.

See Also:
Constant Field Values

STOPBITS_1

public static final int STOPBITS_1
1 stop bit.

See Also:
Constant Field Values

STOPBITS_2

public static final int STOPBITS_2
2 stop bits.

See Also:
Constant Field Values

STOPBITS_1_5

public static final int STOPBITS_1_5
1-1½ stop bits.

See Also:
Constant Field Values

PARITY_NONE

public static final int PARITY_NONE
No parity.

See Also:
Constant Field Values

PARITY_ODD

public static final int PARITY_ODD
Odd parity.

See Also:
Constant Field Values

PARITY_EVEN

public static final int PARITY_EVEN
Even parity.

See Also:
Constant Field Values

PARITY_MARK

public static final int PARITY_MARK
MARK parity scheme.

See Also:
Constant Field Values

PARITY_SPACE

public static final int PARITY_SPACE
SPACE parity scheme.

See Also:
Constant Field Values

FLOWCONTROL_NONE

public static final int FLOWCONTROL_NONE
No flow control.

See Also:
Constant Field Values

FLOWCONTROL_RTSCTS_IN

public static final int FLOWCONTROL_RTSCTS_IN
RTS/CTS flow control on input.

See Also:
Constant Field Values

FLOWCONTROL_RTSCTS_OUT

public static final int FLOWCONTROL_RTSCTS_OUT
RTS/CTS flow control on output.

See Also:
Constant Field Values

FLOWCONTROL_XONXOFF_IN

public static final int FLOWCONTROL_XONXOFF_IN
XON/XOFF flow control on input.

See Also:
Constant Field Values

FLOWCONTROL_XONXOFF_OUT

public static final int FLOWCONTROL_XONXOFF_OUT
XON/XOFF flow control on output.

See Also:
Constant Field Values
Constructor Detail

SerialPort

public SerialPort()
Constructor.

Method Detail

setRcvFifoTrigger

public void setRcvFifoTrigger(int trigger)
Deprecated. 

Set the Receive Fifo trigger level. If the UART has a FIFO and if it can have programmable trigger levels, then this method will cause the UART to raise an interrupt after trigger bytes have been received.

Specified by:
setRcvFifoTrigger in interface SerialPortInterface
Parameters:
trigger - the trigger level

isRTS

public abstract boolean isRTS()
Indicates if the RTS bit is set.

Specified by:
isRTS in interface SerialPortInterface
Returns:
true if the RTS bit is set.
See Also:
SerialPortInterface.setRTS(boolean)

isCTS

public abstract boolean isCTS()
Indicates if the CTS bit is set.

Specified by:
isCTS in interface SerialPortInterface
Returns:
true if the DTR bit is set.
See Also:
SerialPortInterface.setDTR(boolean)

isDSR

public abstract boolean isDSR()
Indicates if the DSR bit is set.

Specified by:
isDSR in interface SerialPortInterface
Returns:
true if the DTR bit is set.

isRI

public abstract boolean isRI()
Indicates if the RI bit is set.

Specified by:
isRI in interface SerialPortInterface
Returns:
true if the RI bit is set.

isCD

public abstract boolean isCD()
Indicates if the CD bit is set.

Specified by:
isCD in interface SerialPortInterface
Returns:
true if the CD bit is set.

addEventListener

public abstract void addEventListener(SerialPortEventListener listener)
                               throws java.util.TooManyListenersException
Adds the specified serial port listener to receive serial events. Only one listener is allowed per serial port.

Specified by:
addEventListener in interface SerialPortInterface
Parameters:
listener - the listener to add
Throws:
java.util.TooManyListenersException

removeEventListener

public abstract void removeEventListener()
Removes the current serial port listener. This is performed automatically when the port is closed.

Specified by:
removeEventListener in interface SerialPortInterface

notifyOnDataAvailable

public abstract void notifyOnDataAvailable(boolean enable)
Instructs the port to notify its listener when input data is available.

Specified by:
notifyOnDataAvailable in interface SerialPortInterface
Parameters:
enable - true if asynchronous events are desired, false otherwise

notifyOnOutputEmpty

public abstract void notifyOnOutputEmpty(boolean enable)
Instructs the port to notify its listener when the output buffer is empty.

Specified by:
notifyOnOutputEmpty in interface SerialPortInterface
Parameters:
enable - true to enable notification, false otherwise

notifyOnCTS

public abstract void notifyOnCTS(boolean enable)
Instructs the port to notify its listener when the CTS bit changes.

Specified by:
notifyOnCTS in interface SerialPortInterface
Parameters:
enable - true to enable notification, false otherwise

notifyOnDSR

public abstract void notifyOnDSR(boolean enable)
Instructs the port to notify its listener when the DSR bit changes.

Specified by:
notifyOnDSR in interface SerialPortInterface
Parameters:
enable - true to enable notification, false otherwise

notifyOnRingIndicator

public abstract void notifyOnRingIndicator(boolean enable)
Instructs the port to notify its listener when the RI bit changes.

Specified by:
notifyOnRingIndicator in interface SerialPortInterface
Parameters:
enable - true to enable notification, false otherwise

notifyOnCarrierDetect

public abstract void notifyOnCarrierDetect(boolean enable)
Instructs the port to notify its listener when the CD bit changes.

Specified by:
notifyOnCarrierDetect in interface SerialPortInterface
Parameters:
enable - true to enable notification, false otherwise

notifyOnOverrunError

public abstract void notifyOnOverrunError(boolean enable)
Instructs the port to notify its listener when an overrun error occurs.

Specified by:
notifyOnOverrunError in interface SerialPortInterface
Parameters:
enable - true to enable notification, false otherwise

notifyOnParityError

public abstract void notifyOnParityError(boolean enable)
Instructs the port to notify its listener when a parity error occurs.

Specified by:
notifyOnParityError in interface SerialPortInterface
Parameters:
enable - true to enable notification, false otherwise

notifyOnFramingError

public abstract void notifyOnFramingError(boolean enable)
Instructs the port to notify its listener when a framing error occurs.

Specified by:
notifyOnFramingError in interface SerialPortInterface
Parameters:
enable - true to enable notification, false otherwise

notifyOnBreakInterrupt

public abstract void notifyOnBreakInterrupt(boolean enable)
Instructs the port to notify its listener when there is a break interrupt on the line.

Specified by:
notifyOnBreakInterrupt in interface SerialPortInterface
Parameters:
enable - true to enable notification, false otherwise