org.mbari.siam.distributed.platform
Class PuckOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by org.mbari.siam.distributed.platform.PuckOutputStream
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable

public class PuckOutputStream
extends java.io.OutputStream

The PuckOutputStream is used to store binary data on the pucks non volatile memory. The PuckOutputStream can only write to a blank puck. If the the puck is not blank this implementation of the PuckOutputStream will throw an IOException if a puck write is attepmted. To erase the pucks non volatile memory the erasePuck method can be used from PuckUtils.

See Also:
PuckUtils

Constructor Summary
PuckOutputStream(java.io.InputStream in, java.io.OutputStream out)
          Creates a PuckOutputStream by using an intput and output stream to a to device that implements the pucks serial protocol.
PuckOutputStream(gnu.io.SerialPort serial_port)
          Creates a PuckOutputStream by using a SerialPort Object to a to device that implements the pucks serial protocol.
 
Method Summary
 void close()
          Closes the PuckOutputStream.
 boolean initPuckStream()
          This method is used to synchronize communications with the puck.
 void write(int b)
          Writes a byte to the pucks non volatile memory.
 
Methods inherited from class java.io.OutputStream
flush, write, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PuckOutputStream

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


PuckOutputStream

public PuckOutputStream(gnu.io.SerialPort serial_port)
Creates a PuckOutputStream by using a SerialPort Object to a to device that implements the pucks serial protocol.

Method Detail

close

public void close()
           throws java.io.IOException
Closes the PuckOutputStream. The close method must always be called after all the binary data has been written to the puck. Failure to call the close method could result in a portion of the binary data not being stored to the pucks non volatile memory.

Specified by:
close in interface java.io.Closeable
Overrides:
close in class java.io.OutputStream
Throws:
java.io.IOException

write

public void write(int b)
           throws java.io.IOException
Writes a byte to the pucks non volatile memory. The write method stores a byte of data in an internal packet buffer. When an entire packet is formed it is sent to the puck to be stored on the pucks non volatile memory. If the close method is not called after the last byte is written then a portion of the data sent to the puck may be lost.

Specified by:
write in class java.io.OutputStream
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.



Copyright © 2003 MBARI.

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.