gnu.io
Class I2C

java.lang.Object
  extended bygnu.io.CommPort
      extended bygnu.io.I2CPort
          extended bygnu.io.I2C

final class I2C
extends I2CPort

I2C


Nested Class Summary
(package private)  class I2C.I2CInputStream
          Inner class for I2CInputStream
(package private)  class I2C.I2COutputStream
          Inner class for I2COutputStream
(package private)  class I2C.MonitorThread
           
 
Field Summary
private  int dataAvailable
           
private  int dataBits
          Data bits port parameter
static int DATABITS_5
           
static int DATABITS_6
           
static int DATABITS_7
           
static int DATABITS_8
           
(package private) static boolean dsrFlag
          DSR flag
private  int fd
          File descriptor
static int FLOWCONTROL_NONE
           
static int FLOWCONTROL_RTSCTS_IN
           
static int FLOWCONTROL_RTSCTS_OUT
           
static int FLOWCONTROL_XONXOFF_IN
           
static int FLOWCONTROL_XONXOFF_OUT
           
private  int flowmode
          Flow control
private  I2C.I2CInputStream in
          Input stream
private  int InputBuffer
          FIXME I think this refers to FOPEN(3)/SETBUF(3)/FREAD(3)/FCLOSE(3) taj@www.linux.org.uk These are native stubs...
private  I2C.MonitorThread monThread
          Thread to monitor data
private  I2C.I2COutputStream out
          Output stream
private  int OutputBuffer
           
private  int parity
          Parity port parameter
static int PARITY_EVEN
           
static int PARITY_MARK
           
static int PARITY_NONE
           
static int PARITY_ODD
           
static int PARITY_SPACE
           
private  int speed
          Line speed in bits-per-second
private  I2CPortEventListener SPEventListener
          I2C Port Event listener
private  int stopBits
          Stop bits port parameter
static int STOPBITS_1
           
static int STOPBITS_1_5
           
static int STOPBITS_2
           
private  int threshold
          Receive threshold control
private  int timeout
          Receive timeout control
 
Fields inherited from class gnu.io.CommPort
name
 
Constructor Summary
I2C(java.lang.String name)
          Open the named port
 
Method Summary
 void addEventListener(I2CPortEventListener lsnr)
          Add an event listener
 void close()
           
 void disableReceiveFraming()
           
 void disableReceiveThreshold()
           
 void disableReceiveTimeout()
           
private  void drain()
           
 void enableReceiveFraming(int f)
          Receive framing control
 void enableReceiveThreshold(int thresh)
           
 void enableReceiveTimeout(int time)
           
(package private)  void eventLoop()
          Process I2CPortEvents
protected  void finalize()
          Finalize the port
 int getBaudRate()
           
 int getDataBits()
           
 int getFlowControlMode()
           
 int getInputBufferSize()
           
 java.io.InputStream getInputStream()
           
 int getOutputBufferSize()
           
 java.io.OutputStream getOutputStream()
           
 int getParity()
           
 int getReceiveFramingByte()
           
 int getReceiveThreshold()
           
 int getReceiveTimeout()
           
 int getStopBits()
           
private static void Initialize()
          Initialize the native library
 boolean isCD()
           
 boolean isCTS()
           
 boolean isDSR()
           
 boolean isDTR()
          Line status methods
 boolean isReceiveFramingEnabled()
           
 boolean isReceiveThresholdEnabled()
           
 boolean isReceiveTimeoutEnabled()
           
 boolean isRI()
           
 boolean isRTS()
           
private  int nativeavailable()
          I2C read methods
private  void nativeClose()
          Close the port
 void NativeEnableReceiveTimeoutThreshold(int time, int threshold, int InputBuffer)
           
 int NativegetReceiveTimeout()
           
 boolean NativeisReceiveTimeoutEnabled()
           
private  void nativeSetI2CPortParams(int speed, int dataBits, int stopBits, int parity)
          Set the native I2C port parameters
 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)
           
private  int open(java.lang.String name)
           
private  int readArray(byte[] b, int off, int len)
           
private  int readByte()
           
 void removeEventListener()
          Remove the I2C port event listener
 void sendBreak(int duration)
          Write to the port
 void sendEvent(int event, boolean state)
           
private  void setDSR(boolean state)
           
 void setDTR(boolean state)
           
(package private)  void setflowcontrol(int flowcontrol)
           
 void setFlowControlMode(int flowcontrol)
           
 void setI2CPortParams(int b, int d, int s, int p)
          Set the I2CPort parameters
 void setInputBufferSize(int size)
           
 void setOutputBufferSize(int size)
           
 void setRTS(boolean state)
           
private  void writeArray(byte[] b, int off, int len)
           
private  void writeByte(int b)
           
 
Methods inherited from class gnu.io.CommPort
getName, toString
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

fd

private int fd
File descriptor


dsrFlag

static boolean dsrFlag
DSR flag


out

private final I2C.I2COutputStream out
Output stream


in

private final I2C.I2CInputStream in
Input stream


speed

private int speed
Line speed in bits-per-second


dataBits

private int dataBits
Data bits port parameter


stopBits

private int stopBits
Stop bits port parameter


parity

private int parity
Parity port parameter


flowmode

private int flowmode
Flow control


timeout

private int timeout
Receive timeout control


threshold

private int threshold
Receive threshold control


InputBuffer

private int InputBuffer
FIXME I think this refers to FOPEN(3)/SETBUF(3)/FREAD(3)/FCLOSE(3) taj@www.linux.org.uk These are native stubs...


OutputBuffer

private int OutputBuffer

SPEventListener

private I2CPortEventListener SPEventListener
I2C Port Event listener


monThread

private I2C.MonitorThread monThread
Thread to monitor data


dataAvailable

private int dataAvailable

DATABITS_5

public static final int DATABITS_5
See Also:
Constant Field Values

DATABITS_6

public static final int DATABITS_6
See Also:
Constant Field Values

DATABITS_7

public static final int DATABITS_7
See Also:
Constant Field Values

DATABITS_8

public static final int DATABITS_8
See Also:
Constant Field Values

PARITY_NONE

public static final int PARITY_NONE
See Also:
Constant Field Values

PARITY_ODD

public static final int PARITY_ODD
See Also:
Constant Field Values

PARITY_EVEN

public static final int PARITY_EVEN
See Also:
Constant Field Values

PARITY_MARK

public static final int PARITY_MARK
See Also:
Constant Field Values

PARITY_SPACE

public static final int PARITY_SPACE
See Also:
Constant Field Values

STOPBITS_1

public static final int STOPBITS_1
See Also:
Constant Field Values

STOPBITS_1_5

public static final int STOPBITS_1_5
See Also:
Constant Field Values

STOPBITS_2

public static final int STOPBITS_2
See Also:
Constant Field Values

FLOWCONTROL_NONE

public static final int FLOWCONTROL_NONE
See Also:
Constant Field Values

FLOWCONTROL_RTSCTS_IN

public static final int FLOWCONTROL_RTSCTS_IN
See Also:
Constant Field Values

FLOWCONTROL_RTSCTS_OUT

public static final int FLOWCONTROL_RTSCTS_OUT
See Also:
Constant Field Values

FLOWCONTROL_XONXOFF_IN

public static final int FLOWCONTROL_XONXOFF_IN
See Also:
Constant Field Values

FLOWCONTROL_XONXOFF_OUT

public static final int FLOWCONTROL_XONXOFF_OUT
See Also:
Constant Field Values
Constructor Detail

I2C

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

Method Detail

Initialize

private static void Initialize()
Initialize the native library


open

private int open(java.lang.String name)
          throws PortInUseException
Throws:
PortInUseException

getOutputStream

public java.io.OutputStream getOutputStream()
Specified by:
getOutputStream in class CommPort

getInputStream

public java.io.InputStream getInputStream()
Specified by:
getInputStream in class CommPort

setI2CPortParams

public void setI2CPortParams(int b,
                             int d,
                             int s,
                             int p)
                      throws UnsupportedCommOperationException
Set the I2CPort parameters

Specified by:
setI2CPortParams in class I2CPort
Throws:
UnsupportedCommOperationException

nativeSetI2CPortParams

private void nativeSetI2CPortParams(int speed,
                                    int dataBits,
                                    int stopBits,
                                    int parity)
                             throws UnsupportedCommOperationException
Set the native I2C port parameters

Throws:
UnsupportedCommOperationException

getBaudRate

public int getBaudRate()
Specified by:
getBaudRate in class I2CPort

getDataBits

public int getDataBits()
Specified by:
getDataBits in class I2CPort

getStopBits

public int getStopBits()
Specified by:
getStopBits in class I2CPort

getParity

public int getParity()
Specified by:
getParity in class I2CPort

setFlowControlMode

public void setFlowControlMode(int flowcontrol)
Specified by:
setFlowControlMode in class I2CPort

getFlowControlMode

public int getFlowControlMode()
Specified by:
getFlowControlMode in class I2CPort

setflowcontrol

void setflowcontrol(int flowcontrol)
              throws java.io.IOException
Throws:
java.io.IOException

enableReceiveFraming

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

Specified by:
enableReceiveFraming in class CommPort
Throws:
UnsupportedCommOperationException

disableReceiveFraming

public void disableReceiveFraming()
Specified by:
disableReceiveFraming in class CommPort

isReceiveFramingEnabled

public boolean isReceiveFramingEnabled()
Specified by:
isReceiveFramingEnabled in class CommPort

getReceiveFramingByte

public int getReceiveFramingByte()
Specified by:
getReceiveFramingByte in class CommPort

NativegetReceiveTimeout

public int NativegetReceiveTimeout()

NativeisReceiveTimeoutEnabled

public boolean NativeisReceiveTimeoutEnabled()

NativeEnableReceiveTimeoutThreshold

public void NativeEnableReceiveTimeoutThreshold(int time,
                                                int threshold,
                                                int InputBuffer)

disableReceiveTimeout

public void disableReceiveTimeout()
Specified by:
disableReceiveTimeout in class CommPort

enableReceiveTimeout

public void enableReceiveTimeout(int time)
Specified by:
enableReceiveTimeout in class CommPort

isReceiveTimeoutEnabled

public boolean isReceiveTimeoutEnabled()
Specified by:
isReceiveTimeoutEnabled in class CommPort

getReceiveTimeout

public int getReceiveTimeout()
Specified by:
getReceiveTimeout in class CommPort

enableReceiveThreshold

public void enableReceiveThreshold(int thresh)
Specified by:
enableReceiveThreshold in class CommPort

disableReceiveThreshold

public void disableReceiveThreshold()
Specified by:
disableReceiveThreshold in class CommPort

getReceiveThreshold

public int getReceiveThreshold()
Specified by:
getReceiveThreshold in class CommPort

isReceiveThresholdEnabled

public boolean isReceiveThresholdEnabled()
Specified by:
isReceiveThresholdEnabled in class CommPort

setInputBufferSize

public void setInputBufferSize(int size)
Specified by:
setInputBufferSize in class CommPort

getInputBufferSize

public int getInputBufferSize()
Specified by:
getInputBufferSize in class CommPort

setOutputBufferSize

public void setOutputBufferSize(int size)
Specified by:
setOutputBufferSize in class CommPort

getOutputBufferSize

public int getOutputBufferSize()
Specified by:
getOutputBufferSize in class CommPort

isDTR

public boolean isDTR()
Line status methods

Specified by:
isDTR in class I2CPort

setDTR

public void setDTR(boolean state)
Specified by:
setDTR in class I2CPort

setRTS

public void setRTS(boolean state)
Specified by:
setRTS in class I2CPort

setDSR

private void setDSR(boolean state)

isCTS

public boolean isCTS()
Specified by:
isCTS in class I2CPort

isDSR

public boolean isDSR()
Specified by:
isDSR in class I2CPort

isCD

public boolean isCD()
Specified by:
isCD in class I2CPort

isRI

public boolean isRI()
Specified by:
isRI in class I2CPort

isRTS

public boolean isRTS()
Specified by:
isRTS in class I2CPort

sendBreak

public void sendBreak(int duration)
Write to the port

Specified by:
sendBreak in class I2CPort

writeByte

private void writeByte(int b)
                throws java.io.IOException
Throws:
java.io.IOException

writeArray

private void writeArray(byte[] b,
                        int off,
                        int len)
                 throws java.io.IOException
Throws:
java.io.IOException

drain

private void drain()
            throws java.io.IOException
Throws:
java.io.IOException

nativeavailable

private int nativeavailable()
                     throws java.io.IOException
I2C read methods

Throws:
java.io.IOException

readByte

private int readByte()
              throws java.io.IOException
Throws:
java.io.IOException

readArray

private int readArray(byte[] b,
                      int off,
                      int len)
               throws java.io.IOException
Throws:
java.io.IOException

eventLoop

void eventLoop()
Process I2CPortEvents


sendEvent

public void sendEvent(int event,
                      boolean state)

addEventListener

public void addEventListener(I2CPortEventListener lsnr)
                      throws java.util.TooManyListenersException
Add an event listener

Specified by:
addEventListener in class I2CPort
Throws:
java.util.TooManyListenersException

removeEventListener

public void removeEventListener()
Remove the I2C port event listener

Specified by:
removeEventListener in class I2CPort

notifyOnDataAvailable

public void notifyOnDataAvailable(boolean enable)
Specified by:
notifyOnDataAvailable in class I2CPort

notifyOnOutputEmpty

public void notifyOnOutputEmpty(boolean enable)
Specified by:
notifyOnOutputEmpty in class I2CPort

notifyOnCTS

public void notifyOnCTS(boolean enable)
Specified by:
notifyOnCTS in class I2CPort

notifyOnDSR

public void notifyOnDSR(boolean enable)
Specified by:
notifyOnDSR in class I2CPort

notifyOnRingIndicator

public void notifyOnRingIndicator(boolean enable)
Specified by:
notifyOnRingIndicator in class I2CPort

notifyOnCarrierDetect

public void notifyOnCarrierDetect(boolean enable)
Specified by:
notifyOnCarrierDetect in class I2CPort

notifyOnOverrunError

public void notifyOnOverrunError(boolean enable)
Specified by:
notifyOnOverrunError in class I2CPort

notifyOnParityError

public void notifyOnParityError(boolean enable)
Specified by:
notifyOnParityError in class I2CPort

notifyOnFramingError

public void notifyOnFramingError(boolean enable)
Specified by:
notifyOnFramingError in class I2CPort

notifyOnBreakInterrupt

public void notifyOnBreakInterrupt(boolean enable)
Specified by:
notifyOnBreakInterrupt in class I2CPort

nativeClose

private void nativeClose()
Close the port


close

public void close()
Overrides:
close in class CommPort

finalize

protected void finalize()
Finalize the port