codeskin.serial
Class SerialPortRxtx2_1

java.lang.Object
  extended by codeskin.serial.SerialPortRxtx2_1
All Implemented Interfaces:
ManagedSerialPort, gnu.io.SerialPortEventListener, java.util.EventListener

public class SerialPortRxtx2_1
extends java.lang.Object
implements ManagedSerialPort, gnu.io.SerialPortEventListener

This class implements a thread-safe way of using RXTX-2.1.


Constructor Summary
SerialPortRxtx2_1(java.lang.String name)
          Class constructor specifying the name of the port.
 
Method Summary
 void close()
          Closes port.
 boolean isOpen()
          Checks if port is open.
 void open(int b, int d, int s, int p, SerialPortClient client)
          Opens serial port (unless already open).
 boolean overflowOccured()
          Checks if buffer overflow occurred.
 void sendBreak(int duration)
          Sends break signal for certain duration.
 void serialEvent(gnu.io.SerialPortEvent event)
           
 void setDTR(boolean set)
          Sets DTR (data terminal ready) line.
 void setRTS(boolean set)
          Sets RTS (ready to send) line.
 void write(byte[] b)
          Writes (sends) array of bytes to port.
 void write(int b)
          Writes (sends) 8-bit integer to port.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SerialPortRxtx2_1

public SerialPortRxtx2_1(java.lang.String name)
Class constructor specifying the name of the port. Should not be used directly. Use static getPort() method instead.

Parameters:
name - the string name of the serial port
Method Detail

open

public void open(int b,
                 int d,
                 int s,
                 int p,
                 SerialPortClient client)
          throws java.io.IOException
Description copied from interface: ManagedSerialPort
Opens serial port (unless already open).

Specified by:
open in interface ManagedSerialPort
Parameters:
b - baudrate
d - number of data bits
s - number of stop bits
p - parity
Throws:
java.io.IOException - - if open fails

isOpen

public boolean isOpen()
Description copied from interface: ManagedSerialPort
Checks if port is open.

Specified by:
isOpen in interface ManagedSerialPort
Returns:
true if port is open

close

public void close()
           throws java.io.IOException
Description copied from interface: ManagedSerialPort
Closes port.

Specified by:
close in interface ManagedSerialPort
Throws:
java.io.IOException - if unable to perform close

write

public void write(int b)
           throws java.io.IOException
Description copied from interface: ManagedSerialPort
Writes (sends) 8-bit integer to port.

Specified by:
write in interface ManagedSerialPort
Parameters:
b - 8-bit integer
Throws:
java.io.IOException - if unable to write

write

public void write(byte[] b)
           throws java.io.IOException
Description copied from interface: ManagedSerialPort
Writes (sends) array of bytes to port.

Specified by:
write in interface ManagedSerialPort
Parameters:
b - array of bytes
Throws:
java.io.IOException - if unable to write

overflowOccured

public boolean overflowOccured()
Description copied from interface: ManagedSerialPort
Checks if buffer overflow occurred.

Specified by:
overflowOccured in interface ManagedSerialPort
Returns:
true if overflow occurred

setDTR

public void setDTR(boolean set)
            throws java.io.IOException
Description copied from interface: ManagedSerialPort
Sets DTR (data terminal ready) line.

Specified by:
setDTR in interface ManagedSerialPort
Parameters:
set - true for asserting line
Throws:
java.io.IOException - if unable to control line

setRTS

public void setRTS(boolean set)
            throws java.io.IOException
Description copied from interface: ManagedSerialPort
Sets RTS (ready to send) line.

Specified by:
setRTS in interface ManagedSerialPort
Parameters:
set - true for asserting line
Throws:
java.io.IOException - if unable to control line

sendBreak

public void sendBreak(int duration)
               throws java.io.IOException
Description copied from interface: ManagedSerialPort
Sends break signal for certain duration.

Specified by:
sendBreak in interface ManagedSerialPort
Parameters:
duration - time in ms
Throws:
java.io.IOException

serialEvent

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