public class SerialIO extends Object implements javax.comm.SerialPortEventListener, Runnable
| Constructor and Description | 
|---|
| SerialIO()Default Ctor
 Creates an instance with default read buffer size of 1MB | 
| SerialIO(int internalBufferSize)Ctor
 Creates an instance with read buffer size of internalBufferSize in bytes | 
| Modifier and Type | Method and Description | 
|---|---|
| void | close()close the serial connection | 
| void | connect(PipedInputStream pipedInputStream)Connect a PipedInputStream to the PipedOutputStream to receive incoming data from the serial port | 
| static String[] | getAvailableSerialPorts()Search for available commPorts on this machine e.g. | 
| Logger | getLogger()Get the logger currently used by this class | 
| void | ioctrl()IO control to comply with UNIX file IO. | 
| static void | loadCommDriver(String driverName)Loads the comm driver manually on windows (if javax.comm is not installed properly in the JRE)
 [needs reference mailing-liist url here]
 On Windows:
 1) win32com.dll to directory : YOUR_JDK/bin
 2) javax.comm.properties to directory : YOUR_JDK/jre/lib
 3) comm.jar to directory : YOUR_JDK/lib
 Other OS's: Load the OS specific shared library analog to the win32com.dll | 
| void | open(String portName,
    int baudrate,
    int dataBits,
    int stopBits,
    int parity,
    boolean handshake)Opens the serial port with the specified parameters
 Note: make sure you call close() before reopening so the
 resources will be freed | 
| int | read(byte[] readBuffer)Non-blocking read:
 Reads if data from the serial port is available. | 
| int | read(byte[] readBuffer,
    int length)Blocking read:
 Read length data from the serial port. | 
| void | run()Read Thread: wakes up every 20 seconds and will be interrupted by serialEvent (hopefully) | 
| void | serialEvent(javax.comm.SerialPortEvent event)Method will be called by the java runtime, when a serial event of this serial port occurs. | 
| void | write(byte[] writeBuffer)Non-blocking write | 
public SerialIO(int internalBufferSize)
internalBufferSize - public SerialIO()
public static void loadCommDriver(String driverName) throws Exception
driverName - on Windows this would be "com.sun.comm.Win32Driver"Exceptionpublic static String[] getAvailableSerialPorts()
public void open(String portName, int baudrate, int dataBits, int stopBits, int parity, boolean handshake) throws Exception
portName - portName of the SerialInterface e.g. COM1, COM2baudrate - default baudratedataBits - number of databits: 7 or 8stopBits - parity - when 7 data bits, the 8th can be used for parityhandshake - sets handshake when transmitting data     *Exceptionpublic void close()
public int read(byte[] readBuffer)
readBuffer - IOExceptionNullPointerExceptionpublic int read(byte[] readBuffer,
       int length)
readBuffer - length - IOExceptionNullPointerExceptionArrayIndexOutOfBoundsExceptionpublic void write(byte[] writeBuffer)
writeBuffer - public void ioctrl()
unix file IO public void connect(PipedInputStream pipedInputStream) throws IOException
pipedInputStream - IOExceptionpublic void run()
public void serialEvent(javax.comm.SerialPortEvent event)
serialEvent in interface javax.comm.SerialPortEventListenerevent -