com.engidea.comm
Class CommPort

java.lang.Object
  extended by com.engidea.comm.CommPort
Direct Known Subclasses:
SerialPort

public abstract class CommPort
extends java.lang.Object

The main difference are the method read and write. They are needed since it may happen that a port returns less bytes than wanted or writes less bytes that you are expected to write. read and write tells you this. If you want the standard interface just use PortInputStream and PortOutputStream NOTE: Basically all methods return either IOexception or UnsupportedEsception, this is really by design since IO si a messy business and you MUST NOT assume things go smooth and nice. methods may fail for a multitude of reasons, loking, ownership, timeout, BUGS, you HAVE to take care of exception either in the form or reopen or in user notificatino.


Field Summary
protected  java.lang.String portName
           
 
Constructor Summary
CommPort(java.lang.String portName)
          Constructor, needed since portName is final.
 
Method Summary
abstract  int available()
          Return the number of bytes available on read.
abstract  void close()
           
abstract  void disableReceiveFraming()
           
abstract  void disableReceiveThreshold()
           
abstract  void disableReceiveTimeout()
           
abstract  void enableReceiveFraming(int f)
           
abstract  void enableReceiveThreshold(int thresh)
           
abstract  void enableReceiveTimeout(int timeoutMilli)
           
abstract  void flush()
          This THROWS AWAY any char that is in the input or output queue !!!!
abstract  int getInputBufferSize()
           
 java.lang.String getName()
          Accessor for portName
abstract  int getOutputBufferSize()
           
abstract  int getReceiveFramingByte()
           
abstract  int getReceiveThreshold()
           
abstract  int getReceiveTimeout()
           
abstract  boolean isReceiveFramingEnabled()
           
abstract  boolean isReceiveThresholdEnabled()
           
abstract  boolean isReceiveTimeoutEnabled()
           
abstract  void open()
           
abstract  int read(byte[] buff, int offset, int len)
          Port instances are allowed to read less chars than requested at their wish.
abstract  void setInputBufferSize(int size)
           
abstract  void setOutputBufferSize(int size)
           
 java.lang.String toString()
           
abstract  int write(byte[] buff, int offset, int len)
          Port instances are allowed to write less chars than requested.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

portName

protected final java.lang.String portName
Constructor Detail

CommPort

public CommPort(java.lang.String portName)
Constructor, needed since portName is final.

Parameters:
portName -
Method Detail

getName

public java.lang.String getName()
Accessor for portName

Returns:
the name of the port as set in costructor

open

public abstract void open()
                   throws java.io.IOException
Throws:
java.io.IOException

close

public abstract void close()

read

public abstract int read(byte[] buff,
                         int offset,
                         int len)
                  throws java.io.IOException
Port instances are allowed to read less chars than requested at their wish. Expect this to throw exception on timeout or alternatively to return zero bytes.

Parameters:
buff -
offset -
len -
Returns:
the number of bytes read, only -1 means EOF, zero is a valid return
Throws:
java.io.IOException

write

public abstract int write(byte[] buff,
                          int offset,
                          int len)
                   throws java.io.IOException
Port instances are allowed to write less chars than requested. Expect this to throw exception on timeout or alternatively to return zero bytes.

Parameters:
buff -
offset -
len -
Returns:
the number of bytes written, only -1 means EOF, Zero is a valid return
Throws:
java.io.IOException

available

public abstract int available()
                       throws java.io.IOException
Return the number of bytes available on read.

Returns:
the number of bytes available to read
Throws:
java.io.IOException

flush

public abstract void flush()
                    throws java.io.IOException
This THROWS AWAY any char that is in the input or output queue !!!!

Throws:
java.io.IOException

enableReceiveFraming

public abstract void enableReceiveFraming(int f)
                                   throws java.io.IOException
Throws:
java.io.IOException

disableReceiveFraming

public abstract void disableReceiveFraming()
                                    throws java.io.IOException
Throws:
java.io.IOException

isReceiveFramingEnabled

public abstract boolean isReceiveFramingEnabled()
                                         throws java.io.IOException
Throws:
java.io.IOException

getReceiveFramingByte

public abstract int getReceiveFramingByte()
                                   throws java.io.IOException
Throws:
java.io.IOException

disableReceiveTimeout

public abstract void disableReceiveTimeout()
                                    throws java.io.IOException
Throws:
java.io.IOException

enableReceiveTimeout

public abstract void enableReceiveTimeout(int timeoutMilli)
                                   throws java.io.IOException
Throws:
java.io.IOException

isReceiveTimeoutEnabled

public abstract boolean isReceiveTimeoutEnabled()
                                         throws java.io.IOException
Throws:
java.io.IOException

getReceiveTimeout

public abstract int getReceiveTimeout()
                               throws java.io.IOException
Throws:
java.io.IOException

enableReceiveThreshold

public abstract void enableReceiveThreshold(int thresh)
                                     throws java.io.IOException
Throws:
java.io.IOException

disableReceiveThreshold

public abstract void disableReceiveThreshold()
                                      throws java.io.IOException
Throws:
java.io.IOException

getReceiveThreshold

public abstract int getReceiveThreshold()
                                 throws java.io.IOException
Throws:
java.io.IOException

isReceiveThresholdEnabled

public abstract boolean isReceiveThresholdEnabled()
                                           throws java.io.IOException
Throws:
java.io.IOException

setInputBufferSize

public abstract void setInputBufferSize(int size)
                                 throws java.io.IOException
Throws:
java.io.IOException

getInputBufferSize

public abstract int getInputBufferSize()
                                throws java.io.IOException
Throws:
java.io.IOException

setOutputBufferSize

public abstract void setOutputBufferSize(int size)
                                  throws java.io.IOException
Throws:
java.io.IOException

getOutputBufferSize

public abstract int getOutputBufferSize()
                                 throws java.io.IOException
Throws:
java.io.IOException

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object