Test software for SatChat prototype hardware Platform - MAX32630FTHR

Dependencies:   USBDevice max32630fthr

Revision:
6:af25f19eb4e6
Parent:
5:703f61be6ee2
Child:
7:4218bb385ca4
--- a/main.cpp	Sat Jul 01 01:35:47 2017 +0000
+++ b/main.cpp	Sat Jul 01 02:02:38 2017 +0000
@@ -29,7 +29,7 @@
     char nmea_descriptor[5] = {0};
     gps_power(on);
     while (1) {
-        char nmea_sentence[82] = {0}; //Fill with NUL terminators
+        char nmea_sentence[82] = {0}; //Fill with NULL terminators
         gps.format(8,Serial::None,1);
         while (gps.getc()!='$');   //wait for start of sentence
         int nmea_index = 0;
@@ -47,6 +47,14 @@
                 nmea_index=80;          //Don't overflow buffer
             }
         }
+        // Checksum
+        bool checksum_valid = FALSE;
+        int checksum = 0;
+        int i = 1;  //After the '$'
+        while (nmea_sentence[i++] != '*'){
+            checksum ^= nmea_sentence[i];
+        }
+        pc.printf( "Checksum: %i\n\r", checksum );
         //     const char s[2] = ",";
         const char gprmc[7] = "$GPRMC";
         char *token;
@@ -77,7 +85,7 @@
     data[1] = 0x19;     //3.3V
     i2c.write( 0x50, data, 2 );
     gps_power(off);
-    wait(5);
+    wait(2);
     while (1) {
         gps_update();
     }