com.esf.device.serial.comm.service
Class SerialCommInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by com.esf.device.serial.comm.service.SerialCommInputStream
All Implemented Interfaces:
java.io.Closeable

public abstract class SerialCommInputStream
extends java.io.InputStream

This is an extension of the standard InputStream, providing additional functionality to be able to wait for incoming data. This avoids the need to have an event driven mechanism for data input.

Author:
matt.demaree

Constructor Summary
SerialCommInputStream()
           
 
Method Summary
abstract  int waitDataAvailable()
          Wait indefinitely for data to become available.
abstract  int waitDataAvailable(int timeout)
          Wait up to the specified timeout milliseconds for data to become available.
 
Methods inherited from class java.io.InputStream
available, close, mark, markSupported, read, read, read, reset, skip
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SerialCommInputStream

public SerialCommInputStream()
Method Detail

waitDataAvailable

public abstract int waitDataAvailable()
                               throws java.io.IOException
Wait indefinitely for data to become available. Once data becomes available, the amount of data immediately available will be returned.

Returns:
number of bytes that can be read immediately from the port
Throws:
java.io.IOException - failure in attempting to wait for data

waitDataAvailable

public abstract int waitDataAvailable(int timeout)
                               throws java.io.IOException
Wait up to the specified timeout milliseconds for data to become available. Once data becomes available, the amount of data immediately available will be returned.

Parameters:
timeout - in milliseconds
Returns:
number of bytes that can be read immediately from the port or 0 if timeout occurred.
Throws:
java.io.IOException - failure in attempting to wait for data