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:
Sun May 05 17:05:02 2013 +0000
Parent:
6:71da5b99de97
Child:
10:37ff5b97cf98
Commit message:
tweaked parameters for the trigger message receive. Used to test with mbed_test where 250 images collected.

Changed in this revision

PCMessaging.h Show annotated file Show diff for this revision Revisions of this file
SDShell.lib 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	Sun May 05 14:35:25 2013 +0000
+++ b/PCMessaging.h	Sun May 05 17:05:02 2013 +0000
@@ -9,6 +9,7 @@
 const unsigned char  STOPSTREAM_MSG     =6;
 const unsigned char  STARTLOGINFO_MSG   =7;
 const unsigned char  STOPLOGINFO_MSG    =8;
+const unsigned char  GETFILE_MSG        =9;
 
 const double  DEGREES_TO_RADIANS = acos(-1.0)/180.0;
 const double eccen          = 0.0818191908426;  //WGS84 earth eccentricity
@@ -28,9 +29,10 @@
 bool sendLogMsgInfo =false;
 bool recordData     =false;
 bool fireTrigger    =false;
+bool get_file_msg   =false;
 
 
-const unsigned char numMessages = 9;    //number of potential messages
+const unsigned char numMessages = 10;    //number of potential messages
 char msgList[numMessages][32];          //text array storing the command messages from the PC
 char minMessageSize = 11;               //minimum size of a text message
 unsigned char CR = 0x0d;                //ASCII Carriage Return
@@ -51,6 +53,7 @@
     sprintf(msgList[STARTLOGINFO_MSG],  "WMsg LOGINFO Y");
     sprintf(msgList[STOPLOGINFO_MSG],   "WMsg LOGINFO N");
     sprintf(msgList[FIRE_TRIGGER_MSG],  "WMsg TRIGGER");
+    sprintf(msgList[GETFILE_MSG],       "WMsg GETFILE");
     //message length is from 10 to 16 chars
     
  //   toPC.printf(" finished setting up messages \n");
@@ -59,7 +62,7 @@
 void readFromPC()
 {
     //  should this be a while rather than if ??? -- may have multiple bytes in buffer
-    if (toPC.readable()) //read a PC serial byte and test it for a command
+    while (toPC.readable()) //read a PC serial byte and test it for a command
     {
         // Read in next character  -- why not read all available??
         unsigned char inChar = 0;
@@ -67,7 +70,7 @@
         //toPC.printf("%02x ",inChar);
         
         //incoming messages will end witb a CR / LF -- disregard these chars
-        if (inChar == CR || inChar == LF)  return; //CR is a 0x0a
+        if (inChar == CR || inChar == LF)  continue; //CR is a 0x0a
         
         //all received messages assumed to have a WMsg preamble
         //if we have read 4 chars, test these for "WMsg", if they are not WMsg, reset the buffer counter
@@ -90,13 +93,13 @@
             {
                 toPC.printf("WMsg preamble mismatch \n");
                 serBufChars = 0;  //if they dont match -- restart the search for a preamble
-                return;
+                continue;
             }
         }
         
         //if we get here, we have found a preamble and we are looking for a complete message
         //no need to continue if numChars are less than the shortest candidate message
-        if (serBufChars < minMessageSize) return;
+        if (serBufChars < minMessageSize) continue;
                 
         // Append end of string
         // We always assume we have a complete message string and test for this below
@@ -126,33 +129,44 @@
                 {
                     case STATUS_MSG:
                         sendStatus = true;  //send a status message back to PC
-                    break;
+                        break;
+                    
                     case POSVEL_MSG:
                         sendPosVel = true;  //send a posvel message back to PC
                         timeFromPosVelMessageReceipt.reset();  //start time and close SD card file if too long
-                    break;
+                        break;
+                    
                     case STARTDATA_MSG:  //start the data recording to the SD card
                         recordData = true;
                         sendRecData = true;
                         break;
+                    
                     case STOPDATA_MSG:   //stop the data recording to the SD card
                         recordData = false;
                         sendRecData = true;
                         break;
+                    
                     case STARTSTREAM_MSG:
                     case STOPSTREAM_MSG:
                         streamPos = (m == STARTSTREAM_MSG);
                         sendStreamPos = true;
-                    break;
+                        break;
+                    
                     case STARTLOGINFO_MSG:
                     case STOPLOGINFO_MSG:
                         logMsgInfo = (m == STARTLOGINFO_MSG);
                         sendLogMsgInfo = true;
-                    break;  
+                        break;  
+                    
                     case FIRE_TRIGGER_MSG:
                         fireTrigger = true;
                         toPC.printf("MBED received trigger command \n");
+                        break;
+                    
+                    case GETFILE_MSG:
+                        get_file_msg = true;
                     break;
+                    
                 }  //end Switch statement
                 break;
             } //end test for a valid message
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SDShell.lib	Sun May 05 17:05:02 2013 +0000
@@ -0,0 +1,1 @@
+https://mbed.org/users/sam_grove/code/SDShell/#254c2fe9c101
--- a/main.cpp	Sun May 05 14:35:25 2013 +0000
+++ b/main.cpp	Sun May 05 17:05:02 2013 +0000
@@ -6,6 +6,7 @@
 
 #include "MODSERIAL.h"
 #include "SDFileSystem.h"      //imported using the import utility    
+#include "SDShell.h"
 
 //general digital I/O specifications for this application
 //SDFileSystem(PinName mosi, PinName miso, PinName sclk, PinName cs, const char* name);
@@ -43,6 +44,19 @@
 
 volatile int PPSTimeOffset = 0;
 
+// stuff to send the SD file to the PC
+void transferFile()
+{
+    SDShell emulate;
+    emulate.init();
+    
+    trig1led = ppsled = rxMsg = txMsg = 1;
+    while(1)
+    {
+        emulate.shell(toPC, sd, "/sd");
+    }
+}
+
 //////////////////////////////////////////////////////////////////////
 // the below should become classes
 //////////////////////////////////////////////////////////////////////
@@ -378,6 +392,16 @@
             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);