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.
Revision 2:c16325a7d225, committed 2019-07-04
- Comitter:
- epremeaux
- Date:
- Thu Jul 04 04:12:41 2019 +0000
- Parent:
- 1:acd907fbcbae
- Commit message:
- U-Blox-M8N GPS example for Nucleo-F401RE. Decodes additional NMEA sentences
Changed in this revision
diff -r acd907fbcbae -r c16325a7d225 MODSERIAL.lib --- a/MODSERIAL.lib Fri Aug 22 12:43:55 2014 +0000 +++ b/MODSERIAL.lib Thu Jul 04 04:12:41 2019 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/edodm85/code/MODSERIAL/#4213f9a7c3ad +https://os.mbed.com/users/Sissors/code/MODSERIAL/#d2a5e26fd658
diff -r acd907fbcbae -r c16325a7d225 main.cpp --- a/main.cpp Fri Aug 22 12:43:55 2014 +0000 +++ b/main.cpp Thu Jul 04 04:12:41 2019 +0000 @@ -2,16 +2,39 @@ * Author: Edoardo De Marchi * Date: 22-08-14 * Notes: Firmware for GPS U-Blox NEO-6M + * + * Modified: Emery Premeaux + * Date: July 2019 + * Written for: Nucleo F401RE & NEO-M8N + * + * Updated MODSERIAL library now compiles without errors but data seems corrupted. + * + * NMEA sentences: https://www.gpsinformation.org/dale/nmea.htm#nmea + * */ -#include "main.h" +#include "mbed.h" +//#include "MODSERIAL.h" + +//MODSERIAL pc(USBTX,USBRX); +//MODSERIAL gps(D8, D2); + +Serial pc(USBTX,USBRX); +Serial gps(D8, D2); + +char cDataBuffer[500]; +int i = 0; +int h_time,m_time,s_time; + +void Init(); +void parse(char *cmd, int n); +void parseTime (float timeval); void Init() { - gps.baud(9600); - pc.baud(115200); - + gps.baud(115200); + pc.baud(115200); pc.printf("Init OK\n"); } @@ -47,15 +70,16 @@ } } - +/* + * NMEA sentences: https://www.gpsinformation.org/dale/nmea.htm#nmea + * http://navspark.mybigcommerce.com/content/NMEA_Format_v0.1.pdf + */ void parse(char *cmd, int n) -{ - +{ char ns, ew, tf, status; int fq, nst, fix, date; // fix quality, Number of satellites being tracked, 3D fix float latitude, longitude, timefix, speed, altitude; - // Global Positioning System Fix Data if(strncmp(cmd,"$GPGGA", 6) == 0) { @@ -64,27 +88,71 @@ } // Satellite status - if(strncmp(cmd,"$GPGSA", 6) == 0) + else if(strncmp(cmd,"$GPGSA", 6) == 0) { sscanf(cmd, "$GPGSA,%c,%d,%d", &tf, &fix, &nst); pc.printf("GPGSA Type fix: %c, 3D fix: %d, number of sat: %d\r\n", tf, fix, nst); } // Geographic position, Latitude and Longitude - if(strncmp(cmd,"$GPGLL", 6) == 0) + else if(strncmp(cmd,"$GPGLL", 6) == 0) { sscanf(cmd, "$GPGLL,%f,%c,%f,%c,%f", &latitude, &ns, &longitude, &ew, &timefix); pc.printf("GPGLL Latitude: %f %c, Longitude: %f %c, Fix taken at: %f\n", latitude, ns, longitude, ew, timefix); } // Geographic position, Latitude and Longitude - if(strncmp(cmd,"$GPRMC", 6) == 0) + else if(strncmp(cmd,"$GPRMC", 6) == 0) { sscanf(cmd, "$GPRMC,%f,%c,%f,%c,%f,%c,%f,,%d", &timefix, &status, &latitude, &ns, &longitude, &ew, &speed, &date); pc.printf("GPRMC Fix taken at: %f, Status: %c, Latitude: %f %c, Longitude: %f %c, Speed: %f, Date: %d\n", timefix, status, latitude, ns, longitude, ew, speed, date); } + + // + else if(strncmp(cmd,"$GNVTG", 6) == 0) + { + // pc.printf("its a Vector Track message.\n"); + } + + else if(strncmp(cmd,"$GNGGA", 6) == 0) + { + sscanf(cmd, "$GNGGA,%f,%f,%c,%f,%c,%d,%d,%*f,%f", &timefix, &latitude, &ns, &longitude, &ew, &fq, &nst, &altitude); + pc.printf("GNGGA Fix taken at: %f, Latitude: %f %c, Longitude: %f %c, Fix quality: %d, Number of sat: %d, Altitude: %f M\n", timefix, latitude, ns, longitude, ew, fq, nst, altitude); + parseTime(timefix); + pc.printf("Time: %d:%d:%d\n", h_time, m_time, s_time); + } + + else if(strncmp(cmd,"$GNGSA", 6) == 0) + { + sscanf(cmd, "$GNGSA,%c,%d,%d", &tf, &fix, &nst); + pc.printf("GNGSA Type fix: %c, 3D fix: %d, number of sat: %d\r\n", tf, fix, nst); + } + + else if(strncmp(cmd,"$GPGSV", 6) == 0) + { + // pc.printf("its a Satellite details message.\n"); + } + + else if(strncmp(cmd,"$GNGLL", 6) == 0) + { + sscanf(cmd, "$GNGLL,%f,%c,%f,%c,%f", &latitude, &ns, &longitude, &ew, &timefix); + pc.printf("GNGLL Latitude: %f %c, Longitude: %f %c, Fix taken at: %f\n", latitude, ns, longitude, ew, timefix); + } + + else + { + // pc.printf("Unknown message type\n"); + } +} + +void parseTime (float timeval) +{ + //format utc time to beijing time,add 8 time zone + float time = timeval + 80000.00f; + h_time = int(time) / 10000; + m_time = (int(time) % 10000) / 100; + s_time = int(time) % 100; } -
diff -r acd907fbcbae -r c16325a7d225 main.h --- a/main.h Fri Aug 22 12:43:55 2014 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,19 +0,0 @@ -#pragma once -#include "mbed.h" -#include "MODSERIAL.h" - -MODSERIAL pc(USBTX,USBRX); - -#if defined(TARGET_LPC1768) -MODSERIAL gps(p13, p14); -#elif defined(TARGET_LPC4330_M4) -MODSERIAL gps(UART0_TX, UART0_RX); -#endif - - -char cDataBuffer[500]; -int i = 0; - - -void Init(); -void parse(char *cmd, int n);
diff -r acd907fbcbae -r c16325a7d225 mbed-src.lib --- a/mbed-src.lib Fri Aug 22 12:43:55 2014 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -http://mbed.org/users/mbed_official/code/mbed-src/#ec1b66a3d094
diff -r acd907fbcbae -r c16325a7d225 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Thu Jul 04 04:12:41 2019 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/9baf128c2fab \ No newline at end of file