# HG changeset patch # User mkanning@CL-ENS241-10.cedarville.edu # Date 2013-01-10 15:03:18 # Node ID e5c11279c2a031ff0b6570d8ccca42b3f8d6fbf2 # Parent 1614c3d5e9cd1ed1415177d2b71397fb3de20b87 checksum calculator and comparator for NMEA diff --git a/master/master/lib/trackuinoGPS/gpsMKa.c b/master/master/lib/trackuinoGPS/gpsMKa.c --- a/master/master/lib/trackuinoGPS/gpsMKa.c +++ b/master/master/lib/trackuinoGPS/gpsMKa.c @@ -42,13 +42,14 @@ uint8_t course[5]; //xxx.x uint8_t datestamp[6]; //ddmmyy uint8_t variation[6]; //xxx.xb int calculatedChecksum; +int receivedChecksum; // transmission state machine enum decodeState { //shared fields INITIALIZE=0, GET_TYPE, - GPS_CHECKSUM, //need to find out how this is calculated/compared + GPS_CHECKSUM, //XOR of all the bytes between the $ and the * (not including the delimiters themselves), written in hexadecimal //GGA data fields GGA_TIME, GGA_LATITUDE, @@ -410,7 +411,7 @@ void parse_gps_transmission(void){ //magnetic variation else if(decodeState == RMC_MAG_VARIATION) { - if (byte == ',') //end of this data type + if (byte == '*') //end of this data type { decodeState = GPS_CHECKSUM; numBytes = 0; //prep for next phase of parse @@ -429,6 +430,18 @@ void parse_gps_transmission(void){ { if (numBytes == 2) //end of data - terminating character ?? { + //checksum calculator for testing http://www.hhhh.org/wiml/proj/nmeaxor.html + //TODO: must determine what to do with correct and incorrect messages + receivedChecksum = checksum[0] + (checksum[1]*16); //convert bytes to int + if(calculatedChecksum==receivedChecksum) + { + + } + else + { + + } + decodeState = INITIALIZE; numBytes = 0; //prep for next phase of parse } @@ -439,8 +452,13 @@ void parse_gps_transmission(void){ } } - //input byte into running checksum - XORbyteWithChecksum(byte); + if (decodeState!=GPS_CHECKSUM && decodeState!=INITIALIZE) //want bytes between '$' and '*' + { + //input byte into running checksum + XORbyteWithChecksum(byte); + } + + } /// MKa GPS transmission parser END