Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
- Committer:
- charlie316
- Date:
- 2017-05-04
- Revision:
- 1:694c547e2961
- Parent:
- 0:0da308226fbd
File content as of revision 1:694c547e2961:
#include "mbed.h"
Serial pc(USBTX, USBRX);
Serial gps(PTB11, PTB10);
int main()
{
pc.baud(9600);
gps.baud(9600);
char buffer[128]; // NMEA data, Example: $GPGGA,123519,4807.038,N,01131.000,E,1,08,0.9,545.4,M,46.9,M,,*47
char * split;
char part1[12] = ""; // GGA Global Positioning System Fix Data
char part2[12] = ""; // 123519 Fix taken at 12:35:19 UTC
char part3[12] = ""; // 4807.038 Latitude 48 deg 07.038'
char part4[12] = ""; // N Direction - North
char part5[12] = ""; // 01131.000 Longitude 11 deg 31.000'
char part6[12] = ""; // E Direction - East
char part7[12] = ""; // 1 Fix quality: 0 = invalid
// 1 = GPS fix (SPS)
// 2 = DGPS fix
// 3 = PPS fix
// 4 = Real Time Kinematic
// 5 = Float RTK
// 6 = estimated (dead reckoning) (2.3 feature)
// 7 = Manual input mode
// 8 = Simulation mode
char part8[12] = ""; // 08 Number of satellites being tracked
char part9[12] = ""; // 0.9 Horizontal dilution of position
char part10[12] = ""; // 545.4 Altitude, Meters
char part11[12] = ""; // M above mean sea level
char part12[12] = ""; // 46.9 Height of geoid (mean sea level) above WGS84 ellipsoid
char part13[12] = ""; // M above mean sea level
char part14[12] = ""; // (empty field) time in seconds since last DGPS update
char part15[12] = ""; // *47 the checksum data, always begins with *
//int count=0;
pc.printf(" Hello World!\r\n");
while(true) {
// if(pc.readable()) {
// gps.putc(pc.getc());
// }
if(gps.readable()) {
gps.gets(buffer, 70);
if(buffer[0] == '$' && buffer[5] == 'A') //&& buffer[2] == '' && buffer[1] == 'G' && buffer[1] == 'G')
{
pc.printf("NMEA data = '%s'\r\n", buffer); // NMEA data, Example: $GPGGA,123519,4807.038,N,01131.000,E,1,08,0.9,545.4,M,46.9,M,,*47
pc.printf("Length = %d \r\n",strlen(buffer)); // Length of the NMEA data sentence
split = strtok(buffer, ",");
while(split != NULL) {
strcpy(part1,split);
pc.printf(" Global Positioning System Fix Data: '%s'\r\n",part1);
split = strtok(NULL,",");
strcpy(part2,split);
pc.printf(" Fix taken at: '%s'\r\n",part2);
split = strtok(NULL,",");
strcpy(part3,split);
pc.printf(" Latitude: '%s'\r\n",part3);
split = strtok(NULL,",");
strcpy(part4,split);
pc.printf(" Direction: '%s'\r\n",part4);
split = strtok(NULL,",");
strcpy(part5,split);
pc.printf(" Longitude: '%s'\r\n",part5);
split = strtok(NULL,",");
strcpy(part6,split);
pc.printf(" Direction: '%s'\r\n",part6);
split = strtok(NULL,",");
strcpy(part7,split);
pc.printf(" Fix quality: '%s'\r\n",part7);
split = strtok(NULL,",");
strcpy(part8,split);
pc.printf(" Number of satellites being tracked: '%s'\r\n",part8);
split = strtok(NULL,",");
strcpy(part9,split);
pc.printf(" Horizontal dilution of position: '%s'\r\n",part9);
split = strtok(NULL,",");
strcpy(part10,split);
pc.printf(" Altitude, Meters: '%s'\r\n",part10);
split = strtok(NULL,",");
strcpy(part11,split);
pc.printf(" '%s'\r\n",part11);
split = strtok(NULL,",");
strcpy(part12,split);
pc.printf(" Height of geoid (mean sea level) above WGS84 ellipsoid: '%s'\r\n",part12);
split = strtok(NULL,",");
strcpy(part13,split);
pc.printf(" '%s'\r\n",part13);
split = strtok(NULL,",");
strcpy(part14,split);
pc.printf(" (empty fields): '%s'\r\n",part14);
split = strtok(NULL,",");
strcpy(part15,split);
pc.printf(" The checksum data: '%s'\r\n",part15);
split = strtok(NULL,",");
}
//return 0;
}
}
}
}