/* ********************************************************************* Hello, with this little tool you can analyze the GPS-Out-string I use only the GPPGGA string. You must the code include in "Antonio Scarfone" "gps_master_1_04.nxc" copy and paste or #include "strip_gps.nxc" after ..... #include "NXCDefs.h" ....... start the tool with ....... //debug output //tmpstr=SubStr(out, 5, 13); //TextOut(0,LCD_LINE4,tmpstr); //NumOut(0,LCD_LINE5,numsent); //write the sentences in a file strip_gps_data(out); //----------------this is new // WriteData(FILENAME,out); numsent = 0; ........... possibly you must comment out TextOUT or NumOUT from gps_master_1_04.nxc Author: Robokalle Date: 19.11.2007 ************************************************************************** */ #include "NXCDefs.h" struct GPGGA_struct { long clock_high; long clock_low; unsigned int latitude_high; int latitude_low; string N_direction; unsigned int longitude_high; int longitude_low; string E_direction; byte quality; byte Sat_number; byte accurateness_high; byte accurateness_low; int altitude_high; int altitude_low; string altitude_measure; }; GPGGA_struct GPGGA; void GPGGAtoScreen() { ClearScreen(); NumOut(0,LCD_LINE1,GPGGA.clock_high); TextOut(36,LCD_LINE1,"."); NumOut(42,LCD_LINE1,GPGGA.clock_low); NumOut(0,LCD_LINE2,GPGGA.latitude_high); TextOut(36,LCD_LINE2,"."); NumOut(42,LCD_LINE2,GPGGA.latitude_low); NumOut(0,LCD_LINE3,GPGGA.longitude_high); TextOut(36,LCD_LINE3,"."); NumOut(42,LCD_LINE3,GPGGA.longitude_low); NumOut(0,LCD_LINE4,GPGGA.altitude_high); TextOut(36,LCD_LINE4,"."); NumOut(42,LCD_LINE4,GPGGA.altitude_low); TextOut(48,LCD_LINE4,GPGGA.altitude_measure); NumOut(0,LCD_LINE5,GPGGA.accurateness_high); TextOut(36,LCD_LINE5,"."); NumOut(42,LCD_LINE5,GPGGA.accurateness_low); NumOut(0,LCD_LINE6,GPGGA.quality); NumOut(0,LCD_LINE7,GPGGA.Sat_number); } // GPGGA void copytostruct(int item,string sdumy){ int len,j; string dumy, dumy1; len= StrLen(sdumy); switch(item){ case 1: for (j=0; j < len ;j++){ if (StrIndex(sdumy,j)== 46){ // nach "." suchen dumy1= SubStr( sdumy,0,j ) ; GPGGA.clock_high = StrToNum(dumy1); dumy1=SubStr( sdumy,j+1, len - j); GPGGA.clock_low =StrToNum(dumy1); }// if str } // for j break; case 2: for (j=0; j < len ;j++){ if (StrIndex(sdumy,j)== 46){ // nach "." suchen dumy1= SubStr( sdumy,0,j ) ; GPGGA.latitude_high = StrToNum(dumy1); dumy1=SubStr( sdumy,j+1, len - j); GPGGA.latitude_low =StrToNum(dumy1); }// if str } // for j break; case 3: GPGGA.N_direction=sdumy; break; case 4: for (j=0; j < len ;j++){ if (StrIndex(sdumy,j)== 46){ // nach "." suchen dumy1= SubStr( sdumy,0,j ) ; GPGGA.longitude_high = StrToNum(dumy1); dumy1=SubStr( sdumy,j+1, len - j); GPGGA.longitude_low =StrToNum(dumy1); }// if str } // for j break; case 5: GPGGA.E_direction=sdumy; break; case 6: GPGGA.quality=StrToNum(sdumy); break; case 7: GPGGA.Sat_number=StrToNum(sdumy); break; case 8: for (j=0; j < len ;j++){ if (StrIndex(sdumy,j)== 46){ // nach "." suchen dumy1= SubStr( sdumy,0,j ) ; GPGGA.accurateness_high = StrToNum(dumy1); dumy1=SubStr( sdumy,j+1, len - j); GPGGA.accurateness_low =StrToNum(dumy1); }// if str } // for j break; case 9: for (j=0; j < len ;j++){ if (StrIndex(sdumy,j)== 46){ // nach "." suchen dumy1= SubStr( sdumy,0,j ) ; GPGGA.altitude_high = StrToNum(dumy1); dumy1=SubStr( sdumy,j+1, len - j); GPGGA.altitude_low =StrToNum(dumy1); }// if str } // for j break; case 10: GPGGA.altitude_measure=sdumy; break; }// switch } // ----------------------------------copytostr void strip_gps_data(string GPS_data){ int lendata, i, begin, last, item ; string sdumy; bool GGA; GGA = false; i=0; lendata= StrLen(GPS_data); begin = -1; item=0; while (StrIndex(GPS_data,i) ==36 && i < lendata){// suchen "$" i++; begin =i; } // while if (begin >-1){ for (i=begin; i < lendata ;i++) { if (StrIndex(GPS_data,i)== 44){ last=i; sdumy=SubStr(GPS_data,begin,last-begin); if (sdumy == "GPGGA"){ GGA = true; } if (GGA){ NumOut(0,LCD_LINE6,GGA); copytostruct(item,sdumy); begin=i+1; // NumOut(0,LCD_LINE8,item); item++; if (item > 10){ i=lendata; // Wait(500); GPGGAtoScreen(); } } else { i=lendata; } }// if strindex }// for begin } // if } // ---------------------------------copy /* task main (){ // Testing main string GPS_data = "$GPGGA,123522.798,5016.9430,N,01776.7081,E,1,05,5.0,564.2,M,,,,0000*0F"; strip_gps_data(GPS_data); Wait(1000); } //----------------------------------------main */