org.mbari.siam.distributed.platform
Class PuckInputStream

The PuckInputStream constructor needs an input and output stream
to a device that supports the puck serial protocol. The
PuckInputStream provides a basic InputStream by using the pucks
serial protocol to query the device for data.

Constructor Summary

PuckInputStream(java.io.InputStream in,
java.io.OutputStream out)
Creates a PuckInputStream by using an intput and output stream to device
that implements the pucks serial protocol.

PuckInputStream(gnu.io.SerialPort serial_port)
Creates a PuckInputStream by using a SerialPort object to a device that
supports the pucks serial protocol.

Method Summary

int

available()
The available method returns the number of buffered puck bytes available
to be read.

PuckInputStream

Creates a PuckInputStream by using an intput and output stream to device
that implements the pucks serial protocol.

PuckInputStream

public PuckInputStream(gnu.io.SerialPort serial_port)

Creates a PuckInputStream by using a SerialPort object to a device that
supports the pucks serial protocol.

Method Detail

resetStream

public void resetStream()
throws java.io.IOException

Set the PuckInputStream to the begining. The puck stores binary data
that a host may use for various purposes. The resetStream method allows
the internal stream pointer to be set back to the begining of the data if
necessary.

Throws:

java.io.IOException

close

public void close()
throws java.io.IOException

Closes the PuckInputStream. Calling the close method releases the
control the PuckInputStream has over the puck. Any subsequent call
to a PuckInputStream method will cause an IOException to be thrown.

Specified by:

close in interface java.io.Closeable

Overrides:

close in class java.io.InputStream

Throws:

java.io.IOException

available

public int available()
throws java.io.IOException

The available method returns the number of buffered puck bytes available
to be read. The PuckInputStream extracts bytes from the puck in packets.
Calling the PuckInputStream available method will return the number of
bytes left in the last packet received from the puck.

Overrides:

available in class java.io.InputStream

Throws:

java.io.IOException

read

public int read()
throws java.io.IOException

The read method returns the next available byte from the puck.
If the number of bytes read from the PuckInputStream exceeds the
number of bytes of binary data stored on the puck zeroes will
be returned.

Specified by:

read in class java.io.InputStream

Throws:

java.io.IOException

skip

public long skip(long n)
throws java.io.IOException

Skips over and discards n bytes of data from the input stream. The skip
method repositions the internal stream pointer to the position indicated
by n. The skip method will return the number of bytes actually skipped.

Overrides:

skip in class java.io.InputStream

Throws:

java.io.IOException

initPuckStream

public boolean initPuckStream()

This method is used to synchronize communications with the puck. Though
called by the constructor when the stream is created it may be necessary
to call this method if a puck was not attached when the stream object
was created. When this method is called after the stream has been created
it will try to synchronize communications with the puck.

The Monterey Bay Aquarium Research Institute (MBARI) provides this documentation and code "as is", with no warranty, express or implied, of its quality or consistency. It is provided without support and without obligation on the part of MBARI to assist in its use, correction, modification, or enhancement.