uwcse.location.objects.nmea
Class NMEADriver

java.lang.Object
  |
  +--com.intel.research.rain.Service
        |
        +--uwcse.location.LocationService
              |
              +--uwcse.location.FusionClientService
                    |
                    +--uwcse.location.objects.SensorDriver
                          |
                          +--uwcse.location.objects.nmea.NMEADriver
All Implemented Interfaces:
EventListener, MessageHandler, javax.comm.SerialPortEventListener

public class NMEADriver
extends SensorDriver
implements javax.comm.SerialPortEventListener

Driver for a device speaking the National Marine Electronics Association (NMEA) protocol including most Global Positioning System devices. Note that this driver is currently just for testing purposes in that it decodes NMEA sentences but does not interact with the location stack infrastructure.

Version:
$Revision: 1.2 $
Author:
Jeffrey Hightower
See Also:
MapMeasurement

Nested Class Summary
 
Nested classes inherited from class uwcse.location.LocationService
LocationService.RediscoverServices
 
Field Summary
protected  javax.comm.SerialPort m_serialPort
           
protected  BufferedReader m_serialPortReader
           
protected  BufferedWriter m_serialPortWriter
           
 
Fields inherited from class uwcse.location.objects.SensorDriver
m_measurementSinkServiceIDSet, SINK_DISCOVERY_QUERY
 
Fields inherited from class uwcse.location.FusionClientService
FUSION_DISCOVERY_QUERY, m_fusionServiceIDSet
 
Fields inherited from class uwcse.location.LocationService
CONFIG_FILENAME, MESSAGE_ELEMENT, MESSAGE_EXTENSION, RPC_ELEMENT, RPC_EXCEPTION_ELEMENT, RPC_EXTENSION, RPC_RESULT_ELEMENT
 
Constructor Summary
NMEADriver()
          Create an NMEA device driver.
 
Method Summary
 void closeSerialPort()
          Close serial port and remove the event listener.
static byte computeChecksum(byte[] bytes)
          Comput an NMEA checksum for the given array of bytes.
 void finalize()
          Overridden to make sure the serial port is closed before the object is garbage collected.
protected  void handleInputLine(String sentence)
          Parse and dispatch NMEA sentences.
protected  void handleNMEASentence(String name, String[] args)
          Handle an NMEA sentence of the given name with the given arguments.
protected  void handleNMEASentence(String@@"GPGGA" name, String[] args)
          Handle an NMEA sentence describing position, latitude, longitude, and time.
protected  void handleNMEASentence(String@@"GPGLL" name, String[] args)
          Handle an NMEA sentence containing position, latitude, longitude, and time.
protected  void handleNMEASentence(String@@"GPGSA" name, String[] args)
          Handle an NMEA sentence describing the type of GPS fix.
protected  void handleNMEASentence(String@@"GPRMC" name, String[] args)
          Handle an NMEA sentence containing the recommended minimum specific GPS/transit data.
protected  void handleNMEASentence(String@@"GPVTG" name, String[] args)
          Handle an NMEA sentence describing velocity made good.
protected  void handleNMEASentence(String@@"HCHDG" name, String[] args)
          Handle an NMEA sentence containing a digital compass reading.
static void main(String[] argv)
           
 void openSerialPort(String portName, int baudRate)
          Open the specified serial port at the given baud rate.
protected static void printUsageAndExit()
          Show the program argument usage and then exit.
 void serialEvent(javax.comm.SerialPortEvent event)
          Handle a serial port events.
 
Methods inherited from class uwcse.location.objects.SensorDriver
sendMeasurement, withdraw
 
Methods inherited from class uwcse.location.FusionClientService
callFusionServiceRpc, getFusionServiceIDSet
 
Methods inherited from class uwcse.location.LocationService
addObject, callLocationRpc, correctedTimeMillis, getObject, getSysclockError, handleTerminalCommand, multicastLocationMsg, multicastLocationMsgs, processLocationMsg, processLocationRpc, runTerminalCommandLoop, sendLocationMsg, sendLocationMsgs, setDescription
 
Methods inherited from class com.intel.research.rain.Service
getDaemon, getDispatcher, getServiceID, process, receive, setDaemon
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_serialPort

protected javax.comm.SerialPort m_serialPort

m_serialPortReader

protected BufferedReader m_serialPortReader

m_serialPortWriter

protected BufferedWriter m_serialPortWriter
Constructor Detail

NMEADriver

public NMEADriver()
           throws RainException,
                  LocationException
Create an NMEA device driver.

Throws:
RainException
LocationException
Method Detail

openSerialPort

public void openSerialPort(String portName,
                           int baudRate)
                    throws javax.comm.NoSuchPortException,
                           javax.comm.PortInUseException,
                           IOException,
                           javax.comm.UnsupportedCommOperationException,
                           TooManyListenersException
Open the specified serial port at the given baud rate.

Throws:
javax.comm.NoSuchPortException
javax.comm.PortInUseException
IOException
javax.comm.UnsupportedCommOperationException
TooManyListenersException

closeSerialPort

public void closeSerialPort()
Close serial port and remove the event listener.


serialEvent

public void serialEvent(javax.comm.SerialPortEvent event)
Handle a serial port events.

Specified by:
serialEvent in interface javax.comm.SerialPortEventListener

finalize

public void finalize()
Overridden to make sure the serial port is closed before the object is garbage collected.

Overrides:
finalize in class Object

handleInputLine

protected void handleInputLine(String sentence)
Parse and dispatch NMEA sentences. Corrupt sentences are silently dropped.


handleNMEASentence

protected void handleNMEASentence(String name,
                                  String[] args)
Handle an NMEA sentence of the given name with the given arguments.


handleNMEASentence

protected void handleNMEASentence(String@@"GPRMC" name,
                                  String[] args)
Handle an NMEA sentence containing the recommended minimum specific GPS/transit data.


handleNMEASentence

protected void handleNMEASentence(String@@"GPGSA" name,
                                  String[] args)
Handle an NMEA sentence describing the type of GPS fix.


handleNMEASentence

protected void handleNMEASentence(String@@"GPGGA" name,
                                  String[] args)
Handle an NMEA sentence describing position, latitude, longitude, and time.


handleNMEASentence

protected void handleNMEASentence(String@@"GPVTG" name,
                                  String[] args)
Handle an NMEA sentence describing velocity made good.


handleNMEASentence

protected void handleNMEASentence(String@@"GPGLL" name,
                                  String[] args)
Handle an NMEA sentence containing position, latitude, longitude, and time.


handleNMEASentence

protected void handleNMEASentence(String@@"HCHDG" name,
                                  String[] args)
Handle an NMEA sentence containing a digital compass reading.


computeChecksum

public static byte computeChecksum(byte[] bytes)
Comput an NMEA checksum for the given array of bytes.


printUsageAndExit

protected static void printUsageAndExit()
Show the program argument usage and then exit.


main

public static void main(String[] argv)


This documentation is for the Location Stack v0.8. The latest distribution, the documentation, and the list of contributors to the Location Stack can always be found at http://portolano.cs.washington.edu/projects/location/

© Copyright 2004 University of Washington CSE