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
00001 #include "mbed.h" 00002 #define ACK 0x06 00003 #define LF 0x0A 00004 #define CR 0x0D 00005 #define NAK 0x15 00006 #define MESS_LEN 100 // maximum message length 00007 #define MAX_STR 20 00008 #define STR_LEN 40 00009 00010 //------------------------------------------------------------------- 00011 // Made by G.Pathuis (gpa@quicknet.nl) 00012 // Program reads the information coming from the GPS receiver 00013 // 65 channel SUP500F 10Hz GPS receiver with integrated Smart antenna 00014 // See www.sparkfun.com GPS-09758 for details and documentation 00015 // Hardware information 00016 // SUP500F pin1 -------------MBED p13 00017 // SUP500F pin2 -------------MBED p14 00018 // SUP500F pin3 -------------MBED GND 00019 // SUP500F pin4 -------------MBED Vout (3.3V @ 75mAmp) 00020 // SUP500F pin5 -------------MBED Vout 00021 // SUP500F pin6 -----LED-----MBED GND 00022 // SUP500F pin7 -------------MBED GND 00023 // 00024 // IMPORTANT REMARK------------------------------------------------- 00025 // This receiver has an integrated antenna and will not work when 00026 // situated near a laptop, PC or MBED 00027 // I used connecting (mbed-receiver) wires with a length of 1 meter 00028 //------------------------------------------------------------------ 00029 00030 Serial pc(USBTX, USBRX); // tx, rx 00031 Serial sup500(p13, p14); // tx, rx 00032 00033 char nmea[MESS_LEN] = {0x00}; // raw message from the GPS receiver 00034 char gp[MAX_STR][STR_LEN]; // 40 strings, length is 30 00035 00036 void read_nmea(void); // read nmea message from gps module 00037 int chop_message(void); // chop the nmea messeage 00038 void present_array(void); // send a part of the available info to the laptop 00039 00040 int main() { 00041 pc.baud(9600); 00042 pc.format(8,Serial::None,1); 00043 00044 sup500.baud(9600); 00045 sup500.format(8,Serial::None,1); 00046 00047 pc.printf("Start lurking...\n\r"); 00048 while (1) { 00049 read_nmea(); 00050 chop_message(); 00051 present_array(); 00052 } 00053 } 00054 00055 //--------------------read nmea from GPS unit-------------------- 00056 void read_nmea(void) { 00057 sup500.scanf("%s,",nmea); 00058 //pc.printf("Raw message %s \n\r",nmea); // just for testing 00059 } 00060 00061 //---------------- chop the nmea message separated by comma's----------- 00062 int chop_message(void) { 00063 for (int k=0; k<MAX_STR; k++) { // just to make sure thet the char array is set to 0x00 00064 for (int l=0; l<STR_LEN; l++) { 00065 gp[k][l]= 0x00; 00066 }; 00067 } 00068 int strcnt=0; // string counter 00069 int strpos=0; // position inside the string 00070 for (int k=0; k < MESS_LEN; k++) { 00071 if (nmea[k] == '*') { // detect end of message is found 00072 gp[strcnt][strpos]= 0x00; // close the string with 0x00 00073 return 0; // the work is done, end of this function 00074 } 00075 if (nmea[k] == 0x2c) { // detect the comma 00076 if (strpos == 0) { 00077 gp[strcnt][0]= 'E'; // comma at position zero, string must be empty 00078 gp[strcnt][1]= 'm'; // comma at position zero, string must be empty 00079 gp[strcnt][2]= 'p'; // comma at position zero, string must be empty 00080 gp[strcnt][3]= 't'; // comma at position zero, string must be empty 00081 gp[strcnt][4]= 'y'; // comma at position zero, string must be empty 00082 gp[strcnt][5]= 0x00; // comma at position zero, string must be empty 00083 } else { 00084 gp[strcnt][strpos]= 0x00; // end the previous string 00085 } 00086 strcnt += 1; // increment to the next string 00087 strpos =0; // start at position zero 00088 } else { 00089 gp[strcnt][strpos]= nmea[k]; // add char to string 00090 strpos += 1; 00091 } 00092 } 00093 return 0; 00094 } 00095 00096 // --------------- Dump only $GPGGA on the screen------------------ 00097 void present_array(void) { 00098 if ((gp[0][2]=='P') and (gp[0][3]=='G') and (gp[0][4]=='G') and (gp[0][5]=='A')) { 00099 pc.printf("Chop results "); 00100 for (int k=0; k<MAX_STR; k++) { 00101 pc.printf("r%d=%s ",k, gp[k]); 00102 } 00103 pc.printf("\n\r"); 00104 } 00105 }
Generated on Fri Jul 15 2022 19:19:09 by
1.7.2