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

Files at this revision

API Documentation at this revision

Comitter:
jekain314
Date:
Sat May 04 23:43:53 2013 +0000
Parent:
4:dda2ab5cc643
Child:
6:71da5b99de97
Commit message:
fix possible error in the message buffer overrun.

Changed in this revision

PCMessaging.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/PCMessaging.h	Sat May 04 23:16:16 2013 +0000
+++ b/PCMessaging.h	Sat May 04 23:43:53 2013 +0000
@@ -68,14 +68,16 @@
         //incoming messages will end witb a CR / LF -- disregard these chars
         if (inChar == CR || inChar == LF)  return; //CR is a 0x0a
         
-        serBuf[serBufChars++] = inChar; //set this char in a char array
+        // serBuffMax = 1024 -- largest serBuffMax is 1023 -- but we add one below for the '\0'
+        if (serBufChars >= (serBuffMax-2)) {toPC.printf("WMsg overun char buff \n"); serBufChars = 0; };
+        serBuf[serBufChars] = inChar; //set this char in a char array
+        serBufChars++;
         
         //no need to continue if numChars are less than the shortest candidate message
-        //if (serBufChars < minMessageSize) return;
+        if (serBufChars < minMessageSize) return;
                 
         // Append end of string
         //We always assume we have a complete message string and test for this below
-        if (serBufChars >= serBuffMax) {toPC.printf(" overun char buff \n"); serBufChars = 0; return; };
         serBuf[serBufChars] = '\0';
         
         bool validMessage = false;
--- a/main.cpp	Sat May 04 23:16:16 2013 +0000
+++ b/main.cpp	Sat May 04 23:43:53 2013 +0000
@@ -247,7 +247,7 @@
                 
         processPCmessages(fpNav, posMsg, velMsg);
         
-        if(fireTrigger)
+        if(fireTrigger)  //comes from a PC request message
         {
             //pre-fire the trigger using the mid-body 2.5mm connection (T2i)
             pre_fire = 0;  //pin30 (midbody of connector) set to zero
@@ -325,17 +325,7 @@
                 //    curVel.horizontalSpeed,  curVel.heading,  curVel.verticalSpeed );
                 velMsg = curVel;
             }
-            /*
-            if (recordData && (fpNav != NULL) && (byteCounter > 0))
-            {
-                //wait_us(10);
-                int totalMessageLength = 28 + msgHdr.messageLength + 4;  //header length + message Length + CRC word size
-                totalBytesWritten += fwrite(&msgBuffer[messageLocation[savedMessageCounter-1]], 1, totalMessageLength, fpNav);  // this writes out a complete set of messages for this sec
-                //wait_us(10);
-            }
-                
-            
-            */
+ 
             completeMessageAvailable = false;
         }