jcontrol.io
Interface BasicInputStream

All Known Subinterfaces:
ComplexInputStream, ConsoleInputStream
All Known Implementing Classes:
FlashStream, FT1_2, I2C, Resource, RS232

public interface BasicInputStream

Provides a set of low-level communication methods for reading.

Author:
boehme
Available on JControl Devices:
all

Method Summary
 void close()
          Closes the stream, further reads are not possible, attached hardware will be turned off.
 char read()
          Reads a single byte from the stream.
 int read(byte[] buffer, int startindex, int length)
          Reads a byte array from the stream.
 

Method Detail

close

void close()
Closes the stream, further reads are not possible, attached hardware will be turned off. Its save to call this method multiple times. Should be called by finalize of implementing classes.


read

char read()
          throws IOException
Reads a single byte from the stream. This is a blocking operation, if there is no data available the current Thread is yielded and should be woken up if data arrives. Implementing classes may throw an IOException if a timeout is reached.

Returns:
the byte read, converted to a char (range 0 .. 255)
Throws:
IOException - if an error occurs

read

int read(byte[] buffer,
         int startindex,
         int length)
         throws IOException
Reads a byte array from the stream. This is a blocking operation, if there is no data available the current Thread is yielded and should be woken up if data arrives. Implementing classes may throw an IOException if a timeout is reached. The byte array may be partially filled.

Parameters:
buffer - the buffer to fill
startindex - the index to start filling the array
length - number of byte to read; the array is filled from startindex to startindex+length-1
Returns:
the number of received bytes
Throws:
IOException - if an error occurs