Friday, February 27, 2009

Here is the original GPS code that I received from my professor.

/*
* SoftwareSerial Library provides Arduino an additional
* "Software" Serial Port
*/
#include

// SoftwareSerial TX & RX Pins
#define SoftrxPin 3
#define SofttxPin 2

//variables for parsing

char *parseptr;
char buffidx;
uint8_t hour, minute, second, year, month, date;
uint32_t latitude, longitude;
uint8_t groundspeed, trackangle;
char latdir, longdir;
char status;


/* Declare and Initialise SoftwareSerial Object
* - Setup the Software Serial Port
*/
SoftwareSerial mySerial = SoftwareSerial(SoftrxPin, SofttxPin);

// GPRMC byte variable from the GPS
byte GPRMC = 0;

// MessageLine - The Entire GPS Message Received
char messageLine[128];

void setup()
{
// Set the computer baud rate
Serial.begin(9600);

// Set the GPS BAUD RATE
mySerial.begin(4800);

// Receive GPS Serial Data on Digital Pin 2
pinMode(SoftrxPin, INPUT);
}

void loop()
{
uint32_t tmp;

GPRMC = mySerial.read();

if(GPRMC == '$')
{
// Clear out the previous GPS Message
for(int i =0; i< index =" 2;" gprmc =" mySerial.read();" parseptr =" messageLine+9;" tmp =" parsedecimal(parseptr);" parseptr =" strchr(parseptr," status =" parseptr[0];" latitude =" parsedecimal(parseptr);" parseptr =" strchr(parseptr," parseptr =" strchr(parseptr," latdir =" parseptr[0];" parseptr =" strchr(parseptr," longitude =" parsedecimal(parseptr);" parseptr =" strchr(parseptr," parseptr =" strchr(parseptr," longdir =" parseptr[0];" latdir ="=" latdir ="=" longdir ="=" longdir ="="> 32450200){
Serial.println("latitude");
}
if(longitude == 117101674){
Serial.println("longitude");
}

//if (latitude != 0) {
// latitude *= 10000;
// parseptr = strchr(parseptr, '.')+1;
// latitude += parsedecimal(parseptr);
//}

}

for(int i = 0; i < d =" 0;"> '9') || (str[0] < '0')) return d; d *= 10; d += str[0] - '0'; str++; } return d; }