gnu.io
Class RS485

java.lang.Object
  extended bygnu.io.CommPort
      extended bygnu.io.RS485Port
          extended bygnu.io.RS485

final class RS485
extends RS485Port

Since:
JDK1.0

Nested Class Summary
(package private)  class RS485.MonitorThread
           
(package private)  class RS485.RS485InputStream
          Inner class for RS485InputStream
(package private)  class RS485.RS485OutputStream
          Inner class for RS485OutputStream
 
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  RS485.RS485InputStream 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  RS485.MonitorThread monThread
          Thread to monitor data
private  RS485.RS485OutputStream 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  RS485PortEventListener SPEventListener
          RS485 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
RS485(java.lang.String name)
          Open the named port
 
Method Summary
 void addEventListener(RS485PortEventListener 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 RS485PortEvents
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()
          RS485 read methods
private  void nativeClose()
          Close the port
 void NativeEnableReceiveTimeoutThreshold(int time, int threshold, int InputBuffer)
           
 int NativegetReceiveTimeout()
           
 boolean NativeisReceiveTimeoutEnabled()
           
private  void nativeSetRS485PortParams(int speed, int dataBits, int stopBits, int parity)
          Set the native RS485 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 RS485 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 setInputBufferSize(int size)
           
 void setOutputBufferSize(int size)
           
 void setRS485PortParams(int b, int d, int s, int p)
          Set the RS485Port parameters
 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 RS485.RS485OutputStream out
Output stream


in

private final RS485.RS485InputStream 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 RS485PortEventListener SPEventListener
RS485 Port Event listener


monThread

private RS485.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

RS485

public RS485(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

setRS485PortParams

public void setRS485PortParams(int b,
                               int d,
                               int s,
                               int p)
                        throws UnsupportedCommOperationException
Set the RS485Port parameters

Specified by:
setRS485PortParams in class RS485Port
Throws:
UnsupportedCommOperationException

nativeSetRS485PortParams

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

Throws:
UnsupportedCommOperationException

getBaudRate

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

getDataBits

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

getStopBits

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

getParity

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

setFlowControlMode

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

getFlowControlMode

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

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 RS485Port

setDTR

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

setRTS

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

setDSR

private void setDSR(boolean state)

isCTS

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

isDSR

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

isCD

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

isRI

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

isRTS

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

sendBreak

public void sendBreak(int duration)
Write to the port

Specified by:
sendBreak in class RS485Port

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
RS485 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 RS485PortEvents


sendEvent

public void sendEvent(int event,
                      boolean state)

addEventListener

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

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

removeEventListener

public void removeEventListener()
Remove the RS485 port event listener

Specified by:
removeEventListener in class RS485Port

notifyOnDataAvailable

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

notifyOnOutputEmpty

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

notifyOnCTS

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

notifyOnDSR

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

notifyOnRingIndicator

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

notifyOnCarrierDetect

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

notifyOnOverrunError

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

notifyOnParityError

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

notifyOnFramingError

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

notifyOnBreakInterrupt

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

nativeClose

private void nativeClose()
Close the port


close

public void close()
Overrides:
close in class CommPort

finalize

protected void finalize()
Finalize the port