gnu.io
Class RXTXPort

java.lang.Object
  extended by gnu.io.CommPort
      extended by gnu.io.SerialPort
          extended by gnu.io.RXTXPort
All Implemented Interfaces:
CommPortInterface, SerialPortInterface

public final class RXTXPort
extends SerialPort

An extension of gnu.io.SerialPort

See Also:
SerialPort

Field Summary
 
Fields inherited from interface gnu.io.SerialPortInterface
DATABITS_5, DATABITS_6, DATABITS_7, DATABITS_8, FLOWCONTROL_NONE, FLOWCONTROL_RTSCTS_IN, FLOWCONTROL_RTSCTS_OUT, FLOWCONTROL_XONXOFF_IN, FLOWCONTROL_XONXOFF_OUT, PARITY_EVEN, PARITY_MARK, PARITY_NONE, PARITY_ODD, PARITY_SPACE, STOPBITS_1, STOPBITS_1_5, STOPBITS_2
 
Constructor Summary
RXTXPort(java.lang.String name)
          Open the named port
 
Method Summary
 void addEventListener(SerialPortEventListener lsnr)
           
 boolean checkMonitorThread()
           
 void close()
          Closes this communications port.
 void disableReceiveFraming()
          Disables receive framing.
 void disableReceiveThreshold()
          Disables receive threshold.
 void disableReceiveTimeout()
          Disables receive timeout.
 void enableReceiveFraming(int f)
          Receive framing control
 void enableReceiveThreshold(int thresh)
          Enables receive threshold.
 void enableReceiveTimeout(int time)
          Enables receive timeout.
 int getBaudBase()
          Extension to CommAPI
 int getBaudRate()
           
 boolean getCallOutHangup()
          Extension to CommAPI returns boolean true on success
 int getDataBits()
           
 int getDivisor()
          Extension to CommAPI
 byte getEndOfInputChar()
          Extension to CommAPI This is an extension to CommAPI.
 int getFlowControlMode()
           
 int getInputBufferSize()
           
 java.io.InputStream getInputStream()
          get the InputStream
 boolean getLowLatency()
          Extension to CommAPI returns boolean true on success
 int getOutputBufferSize()
           
 java.io.OutputStream getOutputStream()
          get the OutputStream
 int getParity()
           
 byte getParityErrorChar()
          Extension to CommAPI This is an extension to CommAPI.
 int getReceiveFramingByte()
           
 int getReceiveThreshold()
           
 int getReceiveTimeout()
           
 int getStopBits()
           
 java.lang.String getUARTType()
          Extension to CommAPI This is an extension to CommAPI.
 boolean isCD()
           
 boolean isCTS()
           
 boolean isDSR()
           
 boolean isDTR()
           
 boolean isReceiveFramingEnabled()
           
 boolean isReceiveThresholdEnabled()
           
 boolean isReceiveTimeoutEnabled()
           
 boolean isRI()
           
 boolean isRTS()
           
 int NativegetReceiveTimeout()
           
 void notifyOnBreakInterrupt(boolean enable)
           
 void notifyOnCarrierDetect(boolean enable)
           
 void notifyOnCTS(boolean enable)
           
 void notifyOnDataAvailable(boolean enable)
           
 void notifyOnDSR(boolean enable)
           
 void notifyOnFramingError(boolean enable)
           
 void notifyOnOutputEmpty(boolean enable)
           
 void notifyOnOverrunError(boolean enable)
           
 void notifyOnParityError(boolean enable)
           
 void notifyOnRingIndicator(boolean enable)
           
 void removeEventListener()
          Remove the serial port event listener
 void sendBreak(int duration)
          Write to the port
 boolean sendEvent(int event, boolean state)
           
 boolean setBaudBase(int BaudBase)
          Extension to CommAPI
 boolean setCallOutHangup(boolean NoHup)
          Extension to CommAPI returns boolean true on success
 boolean setDivisor(int Divisor)
          Extension to CommAPI
 void setDTR(boolean state)
          Sets or clears the DTR bit in the UART.
 boolean setEndOfInputChar(byte b)
          Extension to CommAPI This is an extension to CommAPI.
 void setFlowControlMode(int flowcontrol)
          Sets the flow control mode.
 void setInputBufferSize(int size)
          Sets the input buffer size.
 boolean setLowLatency()
          Extension to CommAPI returns boolean true on success
 void setOutputBufferSize(int size)
          Sets the output buffer size.
 boolean setParityErrorChar(byte b)
          Extension to CommAPI This is an extension to CommAPI.
 void setRcvFifoTrigger(int trigger)
          Deprecated. deprecated but used in Kaffe
 void setRTS(boolean state)
          Sets or clears the RTS bit in the UART.
 void setSerialPortParams(int b, int d, int s, int p)
          Sets the serial port parameters.
 boolean setUARTType(java.lang.String type, boolean test)
          Extension to CommAPI This is an extension to CommAPI.
static int staticGetBaudRate(java.lang.String port)
          Extension to CommAPI This is an extension to CommAPI.
static int staticGetDataBits(java.lang.String port)
          Extension to CommAPI This is an extension to CommAPI.
static int staticGetParity(java.lang.String port)
          Extension to CommAPI This is an extension to CommAPI.
static int staticGetStopBits(java.lang.String port)
          Extension to CommAPI This is an extension to CommAPI.
static boolean staticIsCD(java.lang.String port)
          Extension to CommAPI This is an extension to CommAPI.
static boolean staticIsCTS(java.lang.String port)
          Extension to CommAPI This is an extension to CommAPI.
static boolean staticIsDSR(java.lang.String port)
          Extension to CommAPI This is an extension to CommAPI.
static boolean staticIsDTR(java.lang.String port)
          Extension to CommAPI This is an extension to CommAPI.
static boolean staticIsRI(java.lang.String port)
          Extension to CommAPI This is an extension to CommAPI.
static boolean staticIsRTS(java.lang.String port)
          Extension to CommAPI This is an extension to CommAPI.
static boolean staticSetDSR(java.lang.String port, boolean flag)
          Extension to CommAPI This is an extension to CommAPI.
static boolean staticSetDTR(java.lang.String port, boolean flag)
          Extension to CommAPI This is an extension to CommAPI.
static boolean staticSetRTS(java.lang.String port, boolean flag)
          Extension to CommAPI This is an extension to CommAPI.
static void staticSetSerialPortParams(java.lang.String f, int b, int d, int s, int p)
          Extension to CommAPI This is an extension to CommAPI.
 
Methods inherited from class gnu.io.CommPort
getName, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface comm.CommPortInterface
getName, toString
 

Constructor Detail

RXTXPort

public RXTXPort(java.lang.String name)
         throws PortInUseException
Open the named port

Parameters:
name - the name of the device to open
Throws:
PortInUseException
See Also:
SerialPort
Method Detail

getOutputStream

public java.io.OutputStream getOutputStream()
get the OutputStream

Returns:
OutputStream

getInputStream

public java.io.InputStream getInputStream()
get the InputStream

Returns:
InputStream
See Also:
InputStream

setSerialPortParams

public void setSerialPortParams(int b,
                                int d,
                                int s,
                                int p)
                         throws UnsupportedCommOperationException
Description copied from interface: SerialPortInterface
Sets the serial port parameters.

Parameters:
b - the baud rate
d - the number of data bits: DATABITS_5, DATABITS_6, DATABITS_7, or DATABITS_8
s - the number of stop bits: STOPBITS_1, STOPBITS_2, or STOPBITS_1_5
p - the parity schema: PARITY_NONE, PARITY_ODD, PARITY_EVEN, PARITY_MARK or PARITY_SPACE
Throws:
UnsupportedCommOperationException

getBaudRate

public int getBaudRate()
Returns:
int representing the baudrate This will not behave as expected with custom speeds

getDataBits

public int getDataBits()
Returns:
int representing the databits

getStopBits

public int getStopBits()
Returns:
int representing the stopbits

getParity

public int getParity()
Returns:
int representing the parity

setFlowControlMode

public void setFlowControlMode(int flowcontrol)
Description copied from interface: SerialPortInterface
Sets the flow control mode.

Parameters:
flowcontrol - FLOWCONTROL_NONE is default
See Also:
SerialPortInterface.FLOWCONTROL_NONE

getFlowControlMode

public int getFlowControlMode()
Returns:
int representing the flowmode

enableReceiveFraming

public void enableReceiveFraming(int f)
                          throws UnsupportedCommOperationException
Receive framing control

Parameters:
f - framming
Throws:
UnsupportedCommOperationException
See Also:
CommPortInterface.disableReceiveFraming()

disableReceiveFraming

public void disableReceiveFraming()
Description copied from interface: CommPortInterface
Disables receive framing.

See Also:
CommPortInterface.enableReceiveFraming(int)

isReceiveFramingEnabled

public boolean isReceiveFramingEnabled()
Returns:
true if receive framing is enabled.
See Also:
CommPortInterface.enableReceiveFraming(int)

getReceiveFramingByte

public int getReceiveFramingByte()
Returns:
int representing the framing byte
See Also:
CommPortInterface.enableReceiveFraming(int)

NativegetReceiveTimeout

public int NativegetReceiveTimeout()
Returns:
int the timeout

disableReceiveTimeout

public void disableReceiveTimeout()
Description copied from interface: CommPortInterface
Disables receive timeout.

See Also:
CommPortInterface.enableReceiveTimeout(int)

enableReceiveTimeout

public void enableReceiveTimeout(int time)
Description copied from interface: CommPortInterface
Enables receive timeout. When the specified number of milliseconds have elapsed, read will return immediately.

Parameters:
time -
See Also:
CommPortInterface.disableReceiveTimeout()

isReceiveTimeoutEnabled

public boolean isReceiveTimeoutEnabled()
Returns:
boolean true if recieve timeout is enabled
See Also:
CommPortInterface.enableReceiveTimeout(int)

getReceiveTimeout

public int getReceiveTimeout()
Returns:
int the timeout
See Also:
CommPortInterface.enableReceiveTimeout(int)

enableReceiveThreshold

public void enableReceiveThreshold(int thresh)
Description copied from interface: CommPortInterface
Enables receive threshold. When the specified threshold number of bytes are retrieved, read will return immediately.

Parameters:
thresh - threshold
See Also:
CommPortInterface.disableReceiveThreshold()

disableReceiveThreshold

public void disableReceiveThreshold()
Description copied from interface: CommPortInterface
Disables receive threshold.

See Also:
CommPortInterface.enableReceiveThreshold(int)

getReceiveThreshold

public int getReceiveThreshold()
Returns:
int the recieve threshold
See Also:
CommPortInterface.enableReceiveThreshold(int)

isReceiveThresholdEnabled

public boolean isReceiveThresholdEnabled()
Returns:
boolean true if receive threshold is enabled
See Also:
CommPortInterface.enableReceiveThreshold(int)

setInputBufferSize

public void setInputBufferSize(int size)
Description copied from interface: CommPortInterface
Sets the input buffer size. The driver may choose to ignore this method.

Parameters:
size -

getInputBufferSize

public int getInputBufferSize()
Returns:
the input buffer size. The driver may choose not to report correct values.

setOutputBufferSize

public void setOutputBufferSize(int size)
Description copied from interface: CommPortInterface
Sets the output buffer size. The driver may choose to ignore this method.

Parameters:
size -

getOutputBufferSize

public int getOutputBufferSize()
Returns:
in the output buffer size

isDTR

public boolean isDTR()
Returns:
true if the DTR bit is set.
See Also:
SerialPortInterface.setDTR(boolean)

setDTR

public void setDTR(boolean state)
Description copied from interface: SerialPortInterface
Sets or clears the DTR bit in the UART.

Parameters:
state -
See Also:
SerialPortInterface.isDTR()

setRTS

public void setRTS(boolean state)
Description copied from interface: SerialPortInterface
Sets or clears the RTS bit in the UART.

Parameters:
state -

isCTS

public boolean isCTS()
Returns:
boolean true if CTS is set
See Also:
SerialPortInterface.setDTR(boolean)

isDSR

public boolean isDSR()
Returns:
boolean true if DSR is set

isCD

public boolean isCD()
Returns:
boolean true if CD is set

isRI

public boolean isRI()
Returns:
boolean true if RI is set

isRTS

public boolean isRTS()
Returns:
boolean true if RTS is set
See Also:
SerialPortInterface.setRTS(boolean)

sendBreak

public void sendBreak(int duration)
Write to the port

Parameters:
duration -

checkMonitorThread

public boolean checkMonitorThread()

sendEvent

public boolean sendEvent(int event,
                         boolean state)
Parameters:
event -
state -
Returns:
boolean true if the port is closing

addEventListener

public void addEventListener(SerialPortEventListener lsnr)
                      throws java.util.TooManyListenersException
Throws:
java.util.TooManyListenersException

removeEventListener

public void removeEventListener()
Remove the serial port event listener


notifyOnDataAvailable

public void notifyOnDataAvailable(boolean enable)

notifyOnOutputEmpty

public void notifyOnOutputEmpty(boolean enable)
Parameters:
enable -

notifyOnCTS

public void notifyOnCTS(boolean enable)
Parameters:
enable -

notifyOnDSR

public void notifyOnDSR(boolean enable)
Parameters:
enable -

notifyOnRingIndicator

public void notifyOnRingIndicator(boolean enable)
Parameters:
enable -

notifyOnCarrierDetect

public void notifyOnCarrierDetect(boolean enable)
Parameters:
enable -

notifyOnOverrunError

public void notifyOnOverrunError(boolean enable)
Parameters:
enable -

notifyOnParityError

public void notifyOnParityError(boolean enable)
Parameters:
enable -

notifyOnFramingError

public void notifyOnFramingError(boolean enable)
Parameters:
enable -

notifyOnBreakInterrupt

public void notifyOnBreakInterrupt(boolean enable)
Parameters:
enable -

close

public void close()
Description copied from interface: CommPortInterface
Closes this communications port. All PortOwnershipListeners will be  notified of this change of ownership. Further method calls on this  object will throw IllegalStateException. Further calls on the  associated InputStream or OutputStream will throw IOException.

Close does not block. Undelivered data is discarded. Blocked read and  write operations are aborted if the underlying operating systems  supports an IO abort mechanism. To await the delivery of undelivered  data call OutputStream.flush() or OutputStream.close() before calling  Port.close().

Specified by:
close in interface CommPortInterface
Overrides:
close in class CommPort

setRcvFifoTrigger

public void setRcvFifoTrigger(int trigger)
Deprecated. deprecated but used in Kaffe

A dummy method added so RXTX compiles on Kaffee

Parameters:
trigger - the trigger level

staticGetBaudRate

public static int staticGetBaudRate(java.lang.String port)
                             throws UnsupportedCommOperationException
Extension to CommAPI This is an extension to CommAPI. It may not be supported on all operating systems.

This is only accurate up to 38600 baud currently.

Parameters:
port - the name of the port thats been preopened
Returns:
BaudRate on success
Throws:
UnsupportedCommOperationException; - This will not behave as expected with custom speeds
UnsupportedCommOperationException

staticGetDataBits

public static int staticGetDataBits(java.lang.String port)
                             throws UnsupportedCommOperationException
Extension to CommAPI This is an extension to CommAPI. It may not be supported on all operating systems.

Parameters:
port - the name of the port thats been preopened
Returns:
DataBits on success
Throws:
UnsupportedCommOperationException;
UnsupportedCommOperationException

staticGetParity

public static int staticGetParity(java.lang.String port)
                           throws UnsupportedCommOperationException
Extension to CommAPI This is an extension to CommAPI. It may not be supported on all operating systems.

Parameters:
port - the name of the port thats been preopened
Returns:
Parity on success
Throws:
UnsupportedCommOperationException;
UnsupportedCommOperationException

staticGetStopBits

public static int staticGetStopBits(java.lang.String port)
                             throws UnsupportedCommOperationException
Extension to CommAPI This is an extension to CommAPI. It may not be supported on all operating systems.

Parameters:
port - the name of the port thats been preopened
Returns:
StopBits on success
Throws:
UnsupportedCommOperationException;
UnsupportedCommOperationException

staticSetSerialPortParams

public static void staticSetSerialPortParams(java.lang.String f,
                                             int b,
                                             int d,
                                             int s,
                                             int p)
                                      throws UnsupportedCommOperationException
Extension to CommAPI This is an extension to CommAPI. It may not be supported on all operating systems.

Set the SerialPort parameters 1.5 stop bits requires 5 databits

Parameters:
f - filename
b - baudrate
d - databits
s - stopbits
p - parity
Throws:
UnsupportedCommOperationException
See Also:
UnsupportedCommOperationException

staticSetDSR

public static boolean staticSetDSR(java.lang.String port,
                                   boolean flag)
                            throws UnsupportedCommOperationException
Extension to CommAPI This is an extension to CommAPI. It may not be supported on all operating systems.

Open the port and set DSR. remove lockfile and do not close This is so some software can appear to set the DSR before 'opening' the port a second time later on.

Returns:
true on success
Throws:
UnsupportedCommOperationException;
UnsupportedCommOperationException

staticSetDTR

public static boolean staticSetDTR(java.lang.String port,
                                   boolean flag)
                            throws UnsupportedCommOperationException
Extension to CommAPI This is an extension to CommAPI. It may not be supported on all operating systems.

Open the port and set DTR. remove lockfile and do not close This is so some software can appear to set the DTR before 'opening' the port a second time later on.

Returns:
true on success
Throws:
UnsupportedCommOperationException;
UnsupportedCommOperationException

staticSetRTS

public static boolean staticSetRTS(java.lang.String port,
                                   boolean flag)
                            throws UnsupportedCommOperationException
Extension to CommAPI This is an extension to CommAPI. It may not be supported on all operating systems.

Open the port and set RTS. remove lockfile and do not close This is so some software can appear to set the RTS before 'opening' the port a second time later on.

Returns:
none
Throws:
UnsupportedCommOperationException;
UnsupportedCommOperationException

staticIsRTS

public static boolean staticIsRTS(java.lang.String port)
                           throws UnsupportedCommOperationException
Extension to CommAPI This is an extension to CommAPI. It may not be supported on all operating systems.

find the fd and return RTS without using a Java open() call

Parameters:
port -
Returns:
boolean true if asserted
Throws:
UnsupportedCommOperationException;
UnsupportedCommOperationException

staticIsCD

public static boolean staticIsCD(java.lang.String port)
                          throws UnsupportedCommOperationException
Extension to CommAPI This is an extension to CommAPI. It may not be supported on all operating systems.

find the fd and return CD without using a Java open() call

Parameters:
port -
Returns:
boolean true if asserted
Throws:
UnsupportedCommOperationException;
UnsupportedCommOperationException

staticIsCTS

public static boolean staticIsCTS(java.lang.String port)
                           throws UnsupportedCommOperationException
Extension to CommAPI This is an extension to CommAPI. It may not be supported on all operating systems.

find the fd and return CTS without using a Java open() call

Parameters:
port -
Returns:
boolean true if asserted
Throws:
UnsupportedCommOperationException;
UnsupportedCommOperationException

staticIsDSR

public static boolean staticIsDSR(java.lang.String port)
                           throws UnsupportedCommOperationException
Extension to CommAPI This is an extension to CommAPI. It may not be supported on all operating systems.

find the fd and return DSR without using a Java open() call

Parameters:
port -
Returns:
boolean true if asserted
Throws:
UnsupportedCommOperationException;
UnsupportedCommOperationException

staticIsDTR

public static boolean staticIsDTR(java.lang.String port)
                           throws UnsupportedCommOperationException
Extension to CommAPI This is an extension to CommAPI. It may not be supported on all operating systems.

find the fd and return DTR without using a Java open() call

Parameters:
port -
Returns:
boolean true if asserted
Throws:
UnsupportedCommOperationException;
UnsupportedCommOperationException

staticIsRI

public static boolean staticIsRI(java.lang.String port)
                          throws UnsupportedCommOperationException
Extension to CommAPI This is an extension to CommAPI. It may not be supported on all operating systems.

find the fd and return RI without using a Java open() call

Parameters:
port -
Returns:
boolean true if asserted
Throws:
UnsupportedCommOperationException;
UnsupportedCommOperationException

getParityErrorChar

public byte getParityErrorChar()
                        throws UnsupportedCommOperationException
Extension to CommAPI This is an extension to CommAPI. It may not be supported on all operating systems.

Returns:
int the Parity Error Character
Throws:
UnsupportedCommOperationException; - Anyone know how to do this in Unix?
UnsupportedCommOperationException

setParityErrorChar

public boolean setParityErrorChar(byte b)
                           throws UnsupportedCommOperationException
Extension to CommAPI This is an extension to CommAPI. It may not be supported on all operating systems.

Parameters:
b - Parity Error Character
Returns:
boolean true on success
Throws:
UnsupportedCommOperationException; - Anyone know how to do this in Unix?
UnsupportedCommOperationException

getEndOfInputChar

public byte getEndOfInputChar()
                       throws UnsupportedCommOperationException
Extension to CommAPI This is an extension to CommAPI. It may not be supported on all operating systems.

Returns:
int the End of Input Character
Throws:
UnsupportedCommOperationException; - Anyone know how to do this in Unix?
UnsupportedCommOperationException

setEndOfInputChar

public boolean setEndOfInputChar(byte b)
                          throws UnsupportedCommOperationException
Extension to CommAPI This is an extension to CommAPI. It may not be supported on all operating systems.

Parameters:
b - End Of Input Character
Returns:
boolean true on success
Throws:
UnsupportedCommOperationException;
UnsupportedCommOperationException

setUARTType

public boolean setUARTType(java.lang.String type,
                           boolean test)
                    throws UnsupportedCommOperationException
Extension to CommAPI This is an extension to CommAPI. It may not be supported on all operating systems.

Parameters:
type - String representation of the UART type which mayb be "none", "8250", "16450", "16550", "16550A", "16650", "16550V2" or "16750".
test - boolean flag to determin if the UART should be tested.
Returns:
boolean true on success
Throws:
UnsupportedCommOperationException;
UnsupportedCommOperationException

getUARTType

public java.lang.String getUARTType()
                             throws UnsupportedCommOperationException
Extension to CommAPI This is an extension to CommAPI. It may not be supported on all operating systems.

Returns:
type String representation of the UART type which mayb be "none", "8250", "16450", "16550", "16550A", "16650", "16550V2" or "16750".
Throws:
UnsupportedCommOperationException;
UnsupportedCommOperationException

setBaudBase

public boolean setBaudBase(int BaudBase)
                    throws UnsupportedCommOperationException
Extension to CommAPI

Parameters:
BaudBase - The clock frequency divided by 16. Default BaudBase is 115200.
Returns:
boolean true on success
Throws:
UnsupportedCommOperationException

getBaudBase

public int getBaudBase()
                throws UnsupportedCommOperationException
Extension to CommAPI

Returns:
int BaudBase
Throws:
UnsupportedCommOperationException

setDivisor

public boolean setDivisor(int Divisor)
                   throws UnsupportedCommOperationException
Extension to CommAPI

Parameters:
Divisor; -
Throws:
UnsupportedCommOperationException

getDivisor

public int getDivisor()
               throws UnsupportedCommOperationException
Extension to CommAPI

Throws:
UnsupportedCommOperationException

setLowLatency

public boolean setLowLatency()
                      throws UnsupportedCommOperationException
Extension to CommAPI returns boolean true on success

Throws:
UnsupportedCommOperationException

getLowLatency

public boolean getLowLatency()
                      throws UnsupportedCommOperationException
Extension to CommAPI returns boolean true on success

Throws:
UnsupportedCommOperationException

setCallOutHangup

public boolean setCallOutHangup(boolean NoHup)
                         throws UnsupportedCommOperationException
Extension to CommAPI returns boolean true on success

Throws:
UnsupportedCommOperationException

getCallOutHangup

public boolean getCallOutHangup()
                         throws UnsupportedCommOperationException
Extension to CommAPI returns boolean true on success

Throws:
UnsupportedCommOperationException