sophware.home.io
Class RXTXSerialAccess

java.lang.Object
  extended by sophware.home.io.RXTXSerialAccess
All Implemented Interfaces:
gnu.io.SerialPortEventListener, java.util.EventListener, HomeAccess

public class RXTXSerialAccess
extends java.lang.Object
implements HomeAccess, gnu.io.SerialPortEventListener

RXTXSerialAccess provides communications access to serial ports using RXTX specification.

Requires RXTX release 2.1 package from RXTX

Version:
1.0, 02/17/06
Author:
Russell Soph

Constructor Summary
RXTXSerialAccess(java.lang.String port)
          Creates an instance of the SerialAccess
RXTXSerialAccess(java.lang.String port, int baudrate, int databits, int stopbits, int parity)
          Creates an instance of the SerialAccess
 
Method Summary
 void close()
          Closes the Serial Port
 java.io.InputStream getInputStream()
          Gets the input stream associate with the Serial Port
 java.io.OutputStream getOutputStream()
          Gets the output stream associate with the Serial Port
 boolean isOpen()
          returns status of access
 void open()
          Opens and initializes the Serial Port
 void serialEvent(gnu.io.SerialPortEvent event)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RXTXSerialAccess

public RXTXSerialAccess(java.lang.String port)
Creates an instance of the SerialAccess

DEFAULT: 4800 baud, 8 data bits, 1 stop bit, no parity

Parameters:
port - the COM port connected to the device

RXTXSerialAccess

public RXTXSerialAccess(java.lang.String port,
                        int baudrate,
                        int databits,
                        int stopbits,
                        int parity)
Creates an instance of the SerialAccess

The databits, stopbits and parity should use the static fields provided by javax.comm.SerialPort

Parameters:
port - the COM port connected to the device (e.g. COM1, COM2, ...)
baudrate - the baud rate of the port
databits -
  • SerialPort.DATABITS_5: 5 data bits
  • SerialPort.DATABITS_6: 6 data bits
  • SerialPort.DATABITS_7: 7 data bits
  • SerialPort.DATABITS_8: 8 data bits
stopbits -
  • SerialPort.STOPBITS_1: 1 stop bit
  • SerialPort.STOPBITS_2: 2 stop bits
  • SerialPort.STOPBITS_1_5: 1.5 stop bits
parity -
  • SerialPort.PARITY_NONE: no parity
  • SerialPort.PARITY_ODD: odd parity
  • SerialPort.PARITY_EVEN: even parity
  • SerialPort.PARITY_MARK: mark parity
  • SerialPort.PARITY_SPACE: space parity
Method Detail

open

public void open()
          throws java.io.IOException
Opens and initializes the Serial Port

Specified by:
open in interface HomeAccess
Throws:
java.io.IOException

getInputStream

public java.io.InputStream getInputStream()
Gets the input stream associate with the Serial Port

Specified by:
getInputStream in interface HomeAccess
Returns:
the input stream

getOutputStream

public java.io.OutputStream getOutputStream()
Gets the output stream associate with the Serial Port

Specified by:
getOutputStream in interface HomeAccess
Returns:
the output stream

serialEvent

public void serialEvent(gnu.io.SerialPortEvent event)
Specified by:
serialEvent in interface gnu.io.SerialPortEventListener
See Also:
SerialPortEventListener

isOpen

public boolean isOpen()
returns status of access

Specified by:
isOpen in interface HomeAccess

close

public void close()
           throws java.io.IOException
Closes the Serial Port

Specified by:
close in interface HomeAccess
Throws:
java.io.IOException