Java NMEA 0183 Parser: Documentation

Programming API

There is some javadoc documentation for this parser.

Installation

These instructions assume you are using the Java VM which understands the The Java Extension Mechanism. Other VMs may require a slightly different procedure.

  1. Download the package for your computer type.
  2. Unzip the file.
  3. Copy the NMEA0183.jar to the <java-home>/lib/ext directory.

Quick Getting started guide

public class myclass implements ParserListener{
  
  public myclass() {
    Parser parser = new Parser(port.getInputStream(), this);
  }

  /** Handle notification of an event from the parser. */
  public void parserOutput(ParsedSentence parsedSentence) {
    // coordinate to fire if we ever get one...
    NMEA0183Coordinate pos = null;
	switch (parsedSentence.getSentenceID()) {
    case Mappings.GLL:
      GLL sentenceGLL = (GLL)parsedSentence;
      if (sentenceGLL.isDataValid()) {
        coord = sentenceGLL.getLocationOfFix();
      }
      break;
    case Mappings.GGA:
      GGA sentenceGGA = (GGA)parsedSentence;
      if (sentenceGGA.getQualityOfFix() != GGA.NO_FIX) {
        coord = sentenceGGA.getLocationOfFix();
      }
      break;
    default:
      System.err.println("GPSDevice, not handling ParsedSentence: " 
                         + parsedSentence.getSentenceType() + " "
                         + parsedSentence.getSentenceID());
      break;
    }
    if (coord != null) {
      dispatchPosition(coord);
    }
  }
  
  private void dispatchPosition(NMEA0183Coordinate c) {
  	// Handle position
  }
}