view main/packages/common/gps/nmea.h @ 252:1b764c120921 main

Correct the number of bytes of memory required.
author Bob Cook <bob@bobcookdev.com>
date Mon, 07 Sep 2015 20:21:11 -0700
parents 0faaa371df10
children
line wrap: on
line source

// ----------------------------------------------------------------------------------------
//
//  common/gps/nmea.h
//    
//  Bob Cook Development, Robotics Library
//  http://www.bobcookdev.com/rl/
//    
//  This file implements a state machine to parse selected NMEA sentences.
//
//  Copyright (c) 2010-2013 Bob Cook
//  
//  Permission is hereby granted, free of charge, to any person obtaining a copy
//  of this software and associated documentation files (the "Software"), to deal
//  in the Software without restriction, including without limitation the rights
//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
//  copies of the Software, and to permit persons to whom the Software is
//  furnished to do so, subject to the following conditions:
//  
//  The above copyright notice and this permission notice shall be included in
//  all copies or substantial portions of the Software.
//  
//  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
//  THE SOFTWARE.
//  
//  Note: this package requires 40 bytes of RAM for state information.
//
// ----------------------------------------------------------------------------------------

#if !defined( BCDRL_COMMON_GPS_NMEA_H )
#define BCDRL_COMMON_GPS_NMEA_H

#include <stdint.h>

// ----------------------------------------------------------------------------------------

const int32_t nmea_fractional_minutes_multiplier = 10000;

// ----------------------------------------------------------------------------------------
//  nmea_parse
//
//      Accept another byte for the NMEA parsing state machine.
//
//      Returns true when the sentence is correctly decoded.
//

bool nmea_parse( uint8_t byte );

// ----------------------------------------------------------------------------------------
//  nmea_error_count
//
//      Returns the accumulated parse error count.
//

uint8_t nmea_error_count();

// ----------------------------------------------------------------------------------------
//  nmea_timestamp
//
//      Return the packed version of the UTC timestamp field from a GPGGA sentence. The
//      caller must supply a ptr to a 6-byte buffer for the data.
//
//      This value will only be meaningful if nmea_parse() returns true.
//

void nmea_timestamp( uint8_t* timestamp );

// ----------------------------------------------------------------------------------------
//  nmea_latitude
//
//      Retrieve the degrees and minutes of the latitude field from a GPGGA sentence.
//      The degrees will be positive for northern locations, negative for southern. The
//      minutes are whole numbers, and the fractional portion of the minutes are scaled
//      by 10,000 e.g. 0.123 will be stored as 1,230. Only four significant digits are
//      returned e.g. 0.9999 is the maximum fractional value.
//
//      This value will only be meaningful if nmea_parse() returns true.
//

void nmea_latitude( int16_t* degrees, uint16_t* minutes, uint16_t* fractional_minutes );

// ----------------------------------------------------------------------------------------
//  nmea_longitude
//
//      Retrieve the degrees and minutes of the longitude field from a GPGGA sentence.
//      The degrees will be positive for eastern locations, negative for western. The
//      minutes and fractional minutes follow the same format as nmea_latitude().
//
//      This value will only be meaningful if nmea_parse() returns true.
//

void nmea_longitude( int16_t* degrees, uint16_t* minutes, uint16_t* fractional_minutes );

// ----------------------------------------------------------------------------------------
//  nmea_position_fix
//
//      Test whether the GPGGA sentence was derived from a valid position fix. If the
//      supplied ptr is not null the number of satellites used is provided.
//
//      This value will only be meaningful if nmea_parse() returns true.
//

bool nmea_position_fix( uint8_t* satellite_count = 0 );

#endif  // #if defined( BCDRL_COMMON_GPS_NMEA_H )
// ----------------------------------------------------------------------------------------