this version has all of Jim's fixes for reading the GPS and IMU data synchronously

Dependencies:   MODSERIAL SDFileSystem mbed SDShell CRC CommHandler FP LinkedList LogUtil

Revision:
30:96d133f3008e
Parent:
29:dead10cce6e9
diff -r dead10cce6e9 -r 96d133f3008e OEM615.h
--- a/OEM615.h	Thu Jan 09 14:09:05 2014 +0000
+++ b/OEM615.h	Mon Mar 03 13:19:31 2014 +0000
@@ -13,12 +13,12 @@
 
 bool loadingMessageBuffer = false;
 
-const unsigned short maxGPSbytesPerSec = 512;
+const unsigned short maxGPSbytesPerSec = 2048;
 
 int messagePerSecCounter = 0;
-unsigned char msgBuffer0[maxGPSbytesPerSec];  //array to contain one full second of GPS bytes
-unsigned char msgBuffer1[maxGPSbytesPerSec];  //array to contain one full second of GPS bytes
-unsigned char msgBuffer2[maxGPSbytesPerSec];  //array to contain one full second of GPS bytes
+char msgBuffer0[2048];  //array to contain one full second of GPS bytes
+char msgBuffer1[512];  //array to contain one full second of GPS bytes
+char msgBuffer2[512];  //array to contain one full second of GPS bytes
 int GPSbyteCounter0 = 0;
 int GPSbyteCounter1 = 0;
 int GPSbyteCounter2 = 0;
@@ -26,6 +26,27 @@
 bool message1Complete = false;
 bool message2Complete = false;
 
+////////////////////////////////////////////////////////////
+//hotstart procedure
+////////////////////////////////////////////////////////////
+// Novatel OEM615 startup messages:
+//   setapproxtime 1605 425384       // GPSWeek & GPSSeconds
+//   setapproxpos 51.116 -114.038 0  //lat, lon, alt
+////////////////////////////////////////////////////////////
+//  how to use?
+//  Assumes a certain power-up sequence: WALDO_FCS must be running on the PC??
+//  unlikely this start-up sequence will work!!
+//  PC MAY generates a startUp message that is checked for before the GPS RX starts
+//  mbed looks for the startup message for 1 sec.
+//  startUp message contains: Last PCTime, lastLat, lastLon, LastAlt, LastGPSWeek, LastGPSSeconds
+//  If it is found, send the startup messages to the receiver
+//  if it is not found, then just start without the messages (cold start)
+//  On the PC side, check for a startUp file stored within the .exe folder.
+//  However, if the PC clock time between now and the lastStart is > 24 hours, ignore startup file
+//  if the startUp file IS PRESENT, use it to send the startUp message
+//  After reading the startUp file on the PC, always delete it.
+//  Every time the system enters "FINESTEERING", save the StartUp file
+
 void sendASCII(char* ASCI_message, int numChars)
 {
     /////////////////////////////////////////////////
@@ -62,19 +83,33 @@
         if     (messagePerSecCounter == 0)  GPSbyteCounter0 = 0;
         else if(messagePerSecCounter == 1)  GPSbyteCounter1 = 0;
         else if(messagePerSecCounter == 2)  GPSbyteCounter2 = 0;
-        loadingMessageBuffer = true;
+        //loadingMessageBuffer = true;
     }
 
-    if     (messagePerSecCounter == 0)  { msgBuffer0[GPSbyteCounter0 % maxGPSbytesPerSec] = synch0; GPSbyteCounter0++; }
-    else if(messagePerSecCounter == 1)  { msgBuffer1[GPSbyteCounter1 % maxGPSbytesPerSec] = synch0; GPSbyteCounter1++; }
-    else if(messagePerSecCounter == 2)  { msgBuffer2[GPSbyteCounter2 % maxGPSbytesPerSec] = synch0; GPSbyteCounter2++; }
+    if     (messagePerSecCounter == 0)  { msgBuffer0[GPSbyteCounter0 % 1024] = synch0; GPSbyteCounter0++; }
+    else if(messagePerSecCounter == 1)  { msgBuffer1[GPSbyteCounter1 % 512]  = synch0; GPSbyteCounter1++; }
+    else if(messagePerSecCounter == 2)  { msgBuffer2[GPSbyteCounter2 % 512]  = synch0; GPSbyteCounter2++; }
     
     //stop storing the message when we get a LF
     if (synch0 == 0x0a /* LF*/)   //test for line feed
     {
-        if     (messagePerSecCounter == 0)  message0Complete = true;
-        else if(messagePerSecCounter == 1)  message1Complete = true;
-        else if(messagePerSecCounter == 2)  message2Complete = true;
+        //as further confirmation, we could test the prior byte for a CR = 0x0d;
+        
+        if     (messagePerSecCounter == 0)  
+        { 
+            if ( msgBuffer0[GPSbyteCounter0 - 2] == 0x0d) //ensure the two byte end of message
+                message0Complete = true;
+        }
+        else if(messagePerSecCounter == 1)  
+        {
+            if ( msgBuffer0[GPSbyteCounter0 - 2] == 0x0d) //ensure the two byte end of message
+                message1Complete = true;
+            }
+        else if(messagePerSecCounter == 2)  
+        {
+            if ( msgBuffer0[GPSbyteCounter0 - 2] == 0x0d) //ensure the two byte end of message
+                message2Complete = true;
+        }
         messagePerSecCounter++;        //count the messages per second
     }
     
@@ -87,9 +122,3 @@
     
 };
 
-
-
-
-
-
-