org.jscience.devices.gps.garmin
Class GarminInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by java.io.FilterInputStream
          extended by org.jscience.devices.gps.garmin.GarminInputStream
All Implemented Interfaces:
java.io.Closeable

public class GarminInputStream
extends java.io.FilterInputStream

This class provides the functionality of automatically removing the double DLEs from the GPS-inputstream. The double-DLEs can be found in the size-,data-, and checksum-fields. The only method providing the filtering-functionality is read().


Field Summary
 
Fields inherited from class java.io.FilterInputStream
in
 
Constructor Summary
GarminInputStream(java.io.InputStream i)
          Takes the stream to the GPS-unit as an argument.
 
Method Summary
 int read()
          Returns the next byte from the stream.
 int[] readPacket()
          Reads a packet from the stream.
 
Methods inherited from class java.io.FilterInputStream
available, close, mark, markSupported, read, read, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GarminInputStream

public GarminInputStream(java.io.InputStream i)
Takes the stream to the GPS-unit as an argument.

Parameters:
i - DOCUMENT ME!
Method Detail

readPacket

public int[] readPacket()
                 throws InvalidPacketException,
                        java.io.IOException
Reads a packet from the stream.
Note: Method assumes that it's called between packets, ie. when the first byte of a packet is the next in the stream. If this condition is met, the method will leave the stream in the same state.

Returns:
DOCUMENT ME!
Throws:
InvalidPacketException - DOCUMENT ME!
java.io.IOException - DOCUMENT ME!

read

public int read()
         throws java.io.IOException
Returns the next byte from the stream. Makes sure to remove DLE stuffing.

Overrides:
read in class java.io.FilterInputStream
Returns:
DOCUMENT ME!
Throws:
java.io.IOException - DOCUMENT ME!