GPS精度実験

Dependents:   GPSLOG_program

Fork of MBed_Adafruit-GPS-Library by aigamozu

Committer:
s1200058
Date:
Fri Oct 14 07:58:49 2016 +0000
Revision:
8:f1c5757af8dd
Parent:
7:3f389529228e
test;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mlee350 0:a23e3099bb0a 1 /***********************************
mlee350 0:a23e3099bb0a 2 This is the Adafruit GPS library - the ultimate GPS library
mlee350 0:a23e3099bb0a 3 for the ultimate GPS module!
mlee350 0:a23e3099bb0a 4
mlee350 0:a23e3099bb0a 5 Tested and works great with the Adafruit Ultimate GPS module
mlee350 0:a23e3099bb0a 6 using MTK33x9 chipset
mlee350 0:a23e3099bb0a 7 ------> http://www.adafruit.com/products/746
mlee350 0:a23e3099bb0a 8 Pick one up today at the Adafruit electronics shop
mlee350 0:a23e3099bb0a 9 and help support open source hardware & software! -ada
mlee350 0:a23e3099bb0a 10
mlee350 0:a23e3099bb0a 11 Adafruit invests time and resources providing this open source code,
mlee350 0:a23e3099bb0a 12 please support Adafruit and open-source hardware by purchasing
mlee350 0:a23e3099bb0a 13 products from Adafruit!
mlee350 0:a23e3099bb0a 14
mlee350 0:a23e3099bb0a 15 Written by Limor Fried/Ladyada for Adafruit Industries.
mlee350 0:a23e3099bb0a 16 BSD license, check license.txt for more information
mlee350 0:a23e3099bb0a 17 All text above must be included in any redistribution
mlee350 0:a23e3099bb0a 18 ****************************************/
mlee350 0:a23e3099bb0a 19 #include "mbed.h"
mlee350 0:a23e3099bb0a 20 #include <stdint.h>
mlee350 0:a23e3099bb0a 21 #include <math.h>
mlee350 0:a23e3099bb0a 22 #include <ctype.h>
s1200058 7:3f389529228e 23 #include <string>
mlee350 0:a23e3099bb0a 24
kityann 5:ce26d53dc358 25
mlee350 0:a23e3099bb0a 26 #ifndef _MBED_ADAFRUIT_GPS_H
mlee350 0:a23e3099bb0a 27 #define _MBED_ADAFRUIT_GPS_H
mlee350 0:a23e3099bb0a 28
mlee350 0:a23e3099bb0a 29
mlee350 0:a23e3099bb0a 30 // different commands to set the update rate from once a second (1 Hz) to 10 times a second (10Hz)
mlee350 0:a23e3099bb0a 31 #define PMTK_SET_NMEA_UPDATE_1HZ "$PMTK220,1000*1F"
mlee350 0:a23e3099bb0a 32 #define PMTK_SET_NMEA_UPDATE_5HZ "$PMTK220,200*2C"
mlee350 0:a23e3099bb0a 33 #define PMTK_SET_NMEA_UPDATE_10HZ "$PMTK220,100*2F"
s1200058 7:3f389529228e 34 #define PMTK_SET_NMEA_UPDATE_3SEC "$PMTK220,3000*1D"
mlee350 0:a23e3099bb0a 35
mlee350 0:a23e3099bb0a 36 #define PMTK_SET_BAUD_57600 "$PMTK251,57600*2C"
mlee350 0:a23e3099bb0a 37 #define PMTK_SET_BAUD_9600 "$PMTK251,9600*17"
mlee350 0:a23e3099bb0a 38
mlee350 0:a23e3099bb0a 39 // turn on only the second sentence (GPRMC)
mlee350 0:a23e3099bb0a 40 #define PMTK_SET_NMEA_OUTPUT_RMCONLY "$PMTK314,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*29"
mlee350 0:a23e3099bb0a 41 // turn on GPRMC and GGA
mlee350 0:a23e3099bb0a 42 #define PMTK_SET_NMEA_OUTPUT_RMCGGA "$PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*28"
mlee350 0:a23e3099bb0a 43 // turn on ALL THE DATA
mlee350 0:a23e3099bb0a 44 #define PMTK_SET_NMEA_OUTPUT_ALLDATA "$PMTK314,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0*28"
mlee350 0:a23e3099bb0a 45 // turn off output
mlee350 0:a23e3099bb0a 46 #define PMTK_SET_NMEA_OUTPUT_OFF "$PMTK314,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*28"
mlee350 0:a23e3099bb0a 47
mlee350 0:a23e3099bb0a 48 // to generate your own sentences, check out the MTK command datasheet and use a checksum calculator
mlee350 0:a23e3099bb0a 49 // such as the awesome http://www.hhhh.org/wiml/proj/nmeaxor.html
mlee350 0:a23e3099bb0a 50
mlee350 0:a23e3099bb0a 51 #define PMTK_LOCUS_STARTLOG "$PMTK185,0*22"
mlee350 0:a23e3099bb0a 52 #define PMTK_LOCUS_LOGSTARTED "$PMTK001,185,3*3C"
mlee350 0:a23e3099bb0a 53 #define PMTK_LOCUS_QUERY_STATUS "$PMTK183*38"
mlee350 0:a23e3099bb0a 54 #define PMTK_LOCUS_ERASE_FLASH "$PMTK184,1*22"
mlee350 0:a23e3099bb0a 55 #define LOCUS_OVERLAP 0
mlee350 0:a23e3099bb0a 56 #define LOCUS_FULLSTOP 1
mlee350 0:a23e3099bb0a 57
mlee350 0:a23e3099bb0a 58 // standby command & boot successful message
mlee350 0:a23e3099bb0a 59 #define PMTK_STANDBY "$PMTK161,0*28"
mlee350 0:a23e3099bb0a 60 #define PMTK_STANDBY_SUCCESS "$PMTK001,161,3*36" // Not needed currently
mlee350 0:a23e3099bb0a 61 #define PMTK_AWAKE "$PMTK010,002*2D"
mlee350 0:a23e3099bb0a 62
mlee350 0:a23e3099bb0a 63 // ask for the release and version
mlee350 0:a23e3099bb0a 64 #define PMTK_Q_RELEASE "$PMTK605*31"
mlee350 0:a23e3099bb0a 65
mlee350 0:a23e3099bb0a 66 // request for updates on antenna status
mlee350 0:a23e3099bb0a 67 #define PGCMD_ANTENNA "$PGCMD,33,1*6C"
mlee350 0:a23e3099bb0a 68 #define PGCMD_NOANTENNA "$PGCMD,33,0*6D"
mlee350 0:a23e3099bb0a 69
mlee350 0:a23e3099bb0a 70 // how long to wait when we're looking for a response
mlee350 0:a23e3099bb0a 71 #define MAXWAITSENTENCE 5
mlee350 0:a23e3099bb0a 72
mlee350 0:a23e3099bb0a 73
mlee350 0:a23e3099bb0a 74
mlee350 0:a23e3099bb0a 75 class Adafruit_GPS {
mlee350 0:a23e3099bb0a 76 public:
mlee350 0:a23e3099bb0a 77 void begin(int baud);
mlee350 0:a23e3099bb0a 78
mlee350 0:a23e3099bb0a 79 Adafruit_GPS(Serial * ser);
mlee350 0:a23e3099bb0a 80
mlee350 0:a23e3099bb0a 81 char *lastNMEA(void);
mlee350 0:a23e3099bb0a 82 bool newNMEAreceived();
mlee350 0:a23e3099bb0a 83 void common_init(void);
mlee350 0:a23e3099bb0a 84 void sendCommand(char *);
mlee350 0:a23e3099bb0a 85 void pause(bool b);
mlee350 0:a23e3099bb0a 86
mlee350 0:a23e3099bb0a 87 bool parseNMEA(char *response);
mlee350 0:a23e3099bb0a 88 uint8_t parseHex(char c);
kityann 5:ce26d53dc358 89
s1200058 7:3f389529228e 90 string GPGGAdata;
s1200058 7:3f389529228e 91 string GPRMCdata;
s1200058 7:3f389529228e 92 string GPGSAdata;
s1200058 7:3f389529228e 93 string GPGSVdata;
s1200058 7:3f389529228e 94 string GPGSVdataA, GPGSVdataB, GPGSVdataC, GPGSVdataD;
s1200058 7:3f389529228e 95 int print_ok;
s1200058 7:3f389529228e 96 int count_[3];
mlee350 0:a23e3099bb0a 97
mlee350 0:a23e3099bb0a 98 char read(void);
mlee350 0:a23e3099bb0a 99 bool parse(char * nmea);
mlee350 0:a23e3099bb0a 100 void interruptReads(bool r);
mlee350 0:a23e3099bb0a 101
mlee350 0:a23e3099bb0a 102 bool wakeup(void);
mlee350 0:a23e3099bb0a 103 bool standby(void);
mlee350 0:a23e3099bb0a 104
mlee350 0:a23e3099bb0a 105 uint8_t hour, minute, seconds, year, month, day;
mlee350 0:a23e3099bb0a 106 uint16_t milliseconds;
m5171135 1:ff72e93bcb0e 107 float geoidheight, altitude;
m5171135 1:ff72e93bcb0e 108 long latitudeH,latitudeL,longitudeH,longitudeL;
kityann 3:cc9ab73d0624 109 long latitudeKH,latitudeKL,longitudeKH,longitudeKL;
mlee350 0:a23e3099bb0a 110 float speed, angle, magvariation, HDOP;
mlee350 0:a23e3099bb0a 111 char lat, lon, mag;
mlee350 0:a23e3099bb0a 112 bool fix;
mlee350 0:a23e3099bb0a 113 uint8_t fixquality, satellites;
mlee350 0:a23e3099bb0a 114
mlee350 0:a23e3099bb0a 115 bool waitForSentence(char *wait, uint8_t max = MAXWAITSENTENCE);
mlee350 0:a23e3099bb0a 116 bool LOCUS_StartLogger(void);
mlee350 0:a23e3099bb0a 117 bool LOCUS_ReadStatus(void);
mlee350 0:a23e3099bb0a 118
mlee350 0:a23e3099bb0a 119 uint16_t LOCUS_serial, LOCUS_records;
mlee350 0:a23e3099bb0a 120 uint8_t LOCUS_type, LOCUS_mode, LOCUS_config, LOCUS_interval, LOCUS_distance, LOCUS_speed, LOCUS_status, LOCUS_percent;
mlee350 0:a23e3099bb0a 121 private:
mlee350 0:a23e3099bb0a 122 bool paused;
mlee350 0:a23e3099bb0a 123
mlee350 0:a23e3099bb0a 124 Serial * gpsSerial;
mlee350 0:a23e3099bb0a 125 };
mlee350 0:a23e3099bb0a 126
mlee350 0:a23e3099bb0a 127 #endif