jwo.landserf.process.gps.garmin
Class GarminSerialInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by java.io.FilterInputStream
          extended by jwo.landserf.process.gps.garmin.GarminSerialInputStream
All Implemented Interfaces:
Closeable

public class GarminSerialInputStream
extends FilterInputStream

Handles low level input from GPS connected via serial port. Automatically removes the DLEs from the GPS input stream. The double-DLEs can be found in the size, data, and checksum fields. The only method providing the filtering functionality is read().

Version:
2.3, 24th August, 2006.
Author:
Jo Wood, based on the design by Henrik Sorensen (haas@itu.dk).

Field Summary
 
Fields inherited from class java.io.FilterInputStream
in
 
Constructor Summary
GarminSerialInputStream(InputStream i)
          Passes the stream to the GPS unit.
 
Method Summary
 int read()
          Reads the next byte from the stream.
 GarminPacket 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

GarminSerialInputStream

public GarminSerialInputStream(InputStream i)
Passes the stream to the GPS unit.

Parameters:
i - Input stream to channel GPS input.
Method Detail

readPacket

public GarminPacket readPacket()
                        throws InvalidPacketException,
                               IOException
Reads a packet from the stream. This assumes that this method is called between packets. i.e. 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:
Packet including metadata and data.
Throws:
InvalidPacketException - if packet does not contain expected header or footer bytes.
IOException - if problem reading from input stream.

read

public int read()
         throws IOException
Reads the next byte from the stream. Removes DLE stuffing where necessary.

Overrides:
read in class FilterInputStream
Returns:
Next item in input stream.
Throws:
IOException - if problem reading from input stream.


Copyright Jo Wood, 1996-2009, last modified, 17th April, 2009