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:
10:37ff5b97cf98
Parent:
9:893481b2e488
Child:
12:c2f60b3ceb74
--- a/main.cpp	Sun May 05 17:05:02 2013 +0000
+++ b/main.cpp	Sun May 05 22:03:52 2013 +0000
@@ -49,12 +49,12 @@
 {
     SDShell emulate;
     emulate.init();
-    
+    // just indicate that we're in here
     trig1led = ppsled = rxMsg = txMsg = 1;
-    while(1)
-    {
-        emulate.shell(toPC, sd, "/sd");
-    }
+    
+    toPC.printf("Entering Shell Emulator...\n");
+    wait(0.1f);
+    emulate.shell(toPC, sd, "/sd");
 }
 
 //////////////////////////////////////////////////////////////////////
@@ -186,7 +186,8 @@
 /////////////////////////////////////////////////////////////////////
 //  mbed main to support the Waldo_FCS
 /////////////////////////////////////////////////////////////////////
-int main() {
+int main() 
+{
     
     //these are structures for the to GPS messages that must be parsed
     MESSAGEHEADER msgHdr;
@@ -246,23 +247,26 @@
     ///////////////////////////////////////////////////////////////////////////
     while(1)
     {        
+            
         //read the USB serial data from the PC to check for commands
         //in the primary real-time portion, there are no bytes from the PC so this has no impact
         readFromPC();
         
-        /*
+        //
         //this will close the fpNav file on the SD card if the file is open 
         //and the elapsed time from PosVel messages is > 60 secs
         //this prevents loosing the fpNav file if the PC goes down
-        if (fpNav && (timeFromPosVelMessageReceipt.read() > 60) )
+        if (fpNav && (timeFromPosVelMessageReceipt.read() > 10) )
         {
             sendRecData = true;
             recordData  = false;
         }
-        */
+        //
                 
         processPCmessages(fpNav, posMsg, velMsg);
         
+        if (get_file_msg) break;  //terminate the while loop when we receive this message from the PC
+        
         if(fireTrigger)  //comes from a PC request message
         {
             //pre-fire the trigger using the mid-body 2.5mm connection (T2i)
@@ -392,18 +396,27 @@
             IMURecordCounter = 0;
             detectedGPS1PPS = false;
         }
-        if(get_file_msg)
-        {
-            // stop hardware
-            ADIS_RST = 0;
-            GPS_Reset = 0;
-            // reset the flag
-            get_file_msg = false;
-            // transfer the file
-            transferFile();
-        }
     }
       
-    fclose(fpNav);
+    if (fpNav != NULL) fclose(fpNav);  //insurance
     toPC.printf(" normal termination \n");
+    
+    /*
+    //at this point we have terminated the dat collection and we need to send the stored nav file to the PC 
+    FILE* fpNavStored = fopen("/sd/Data/NAV.bin", "rb");
+    unsigned char tempArray[512];
+    toPC.printf(" beginning the file transfer \n");
+    int i = 0;
+    while(!feof(fpNavStored) )
+    {
+        
+        toPC.printf(" reading the 512 bytes: %3d  \n", i);
+        fread(tempArray, 1, 512, fpNavStored);
+        toPC.printf(" writing the 512 bytes: %3d  \n", i);
+        fwrite(tempArray, 1, 512, toPC); 
+        i++;
+    }
+    */
+
+    
 }
\ No newline at end of file