Rev 3885 Rev 3886
Line 56... Line 56...
56 // don't do anything more: 56 // don't do anything more:
57 return; 57 return;
58 } 58 }
59 Serial.println("card initialized."); 59 Serial.println("card initialized.");
60   60  
-   61 dataString = "";
61 ReadGPS(); 62 ReadGPRMC();
-   63  
62 // filename = dataString.substring(0,5) + dataString.substring(dataString.length()-5,dataString.length()) + filename; 64 // filename = dataString.substring(0,5) + dataString.substring(dataString.length()-5,dataString.length()) + filename;
63 int len = dataString.length()-1; 65 int len = dataString.length()-1;
64 filename = dataString.substring(len-2,len) + dataString.substring(len-4,len-2) + dataString.substring(len-6,len-4) + dataString.substring(0,2) + ".CSV "; 66 filename = dataString.substring(len-2,len) + dataString.substring(len-4,len-2) + dataString.substring(len-6,len-4) + dataString.substring(0,2) + ".CSV ";
65 } 67 }
66   68  
67 void loop() 69 void loop()
68 { 70 {
-   71 dataString = "";
-   72 ReadGPRMC();
69 ReadGPS(); 73 ReadGPGGA();
70   74
71 digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) 75 digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
72 delay(20); // wait for a second 76 delay(20); // wait for a second
73 digitalWrite(led, LOW); // turn the LED off by making the voltage LOW 77 digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
74 delay(20); // wait for a second 78 delay(20); // wait for a second
Line 109... Line 113...
109 Serial.println("error opening datalog.txt"); 113 Serial.println("error opening datalog.txt");
110 } 114 }
111 } 115 }
112   116  
113   117  
114 void ReadGPS() 118 void ReadGPRMC()
115 { 119 {
116 dataString = ""; 120 // $GPRMC,091451.00,A,4915.64143,N,01441.50397,E,0.053,,090215,,,A*74
-   121  
117 coll = 0; 122 coll = 0;
118 123
119 while(1) 124 while(1)
120 { 125 {
121 // get incoming byte: 126 // get incoming byte:
Line 145... Line 150...
145 } 150 }
146 while (coll < 9); 151 while (coll < 9);
147 } 152 }
148   153  
149   154  
-   155 void ReadGPGGA()
-   156 {
-   157 // $GPGGA,091451.00,4915.64143,N,01441.50397,E,1,09,0.90,443.2,M,44.0,M,,*50
-   158  
-   159 coll = 0;
-   160
-   161 while(1)
-   162 {
-   163 // get incoming byte:
-   164 while (!Serial.available());
-   165 if (Serial.read() != '$') continue;
-   166 while (!Serial.available());
-   167 if (Serial.read() != 'G') continue;
-   168 while (!Serial.available());
-   169 if (Serial.read() != 'P') continue;
-   170 while (!Serial.available());
-   171 if (Serial.read() != 'G') continue;
-   172 while (!Serial.available());
-   173 if (Serial.read() != 'G') continue;
-   174 while (!Serial.available());
-   175 if (Serial.read() != 'A') continue;
-   176 while (!Serial.available());
-   177 if (Serial.read() != ',') continue;
-   178 break;
-   179 }
-   180
-   181 do
-   182 {
-   183 while (!Serial.available());
-   184 inChar = (char)Serial.read();
-   185 if (inChar == ',') coll++;
-   186 if (coll > 4) dataString += inChar;
-   187 }
-   188 while (coll < 12);
-   189 }
150   190  
151   191  
152   192  
153   193