jcontrol.io
Interface BasicOutputStream

All Known Subinterfaces:
ComplexOutputStream, ConsoleOutputStream
All Known Implementing Classes:
DisplayConsole, FlashStream, FT1_2, I2C, RS232

public interface BasicOutputStream

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

Author:
boehme
Available on JControl Devices:
all

Method Summary
 void close()
          Closes the stream, further writes are not possible, attached hardware will be turned off.
 int write(byte[] buffer, int startindex, int length)
          Writes a byte array to the stream.
 void write(char data)
          Writes a single byte to the stream.
 

Method Detail

close

void close()
Closes the stream, further writes 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.


write

int write(byte[] buffer,
          int startindex,
          int length)
          throws IOException
Writes a byte array to the stream. This is a blocking operation, if the transmit device is busy the current Thread is yielded and should be woken up if the device becomes ready. Implementing classes may throw an IOException if a timeout is reached. The byte array may be partially written.

Parameters:
buffer - the buffer that holds the data to write
startindex - the index to start reading the array
length - number of bytes to write; the array is read from startindex to startindex+length-1
Returns:
the number of sent bytes
Throws:
IOException - if an error occurs

write

void write(char data)
           throws IOException
Writes a single byte to the stream. This is a blocking operation, if the transmit device is busy the current Thread is yielded and should be woken up if the device becomes ready. Implementing classes may throw an IOException if a timeout is reached.

Parameters:
data - the byte to write (range of the char 0 .. 255, the highbyte is ignored)
Throws:
IOException - if an error occurs