most functionality to splashdwon, find neutral and start mission. short timeouts still in code for testing, will adjust to go directly to sit_idle after splashdown

Dependencies:   mbed MODSERIAL FATFileSystem

Revision:
48:20e681885161
Parent:
47:fb3c7929d3f3
Child:
49:47ffa4feb6db
--- a/main.cpp	Thu Feb 15 03:07:16 2018 +0000
+++ b/main.cpp	Thu Feb 15 04:01:57 2018 +0000
@@ -1,17 +1,29 @@
 /*
-    Modified 2017-12-19 revA by Troy
-        - Fixed OpenLog printing to include states and variable names.  Currently logs to LOG#####.TXT files
-            1) Note: The OpenLog only starts a new log when it is power-cycled (with the MBED)
-    Modified 2017-12-20 revA by Troy
-        - Modified code to log every 1 second in current iteration
-    Modified 2017-12-20 revB by Troy
-        - Fixed bug where Dive depth was resetting to rise depth
-    Modified 2017-12-21 revA by Troy
-        - 2 minute timeout default
-        - Added system time to MBED logger and OpenLog
-        - Fixed bug where it was recording random keyboard presses (other FSM states)
-        - Added the ability to save the batt and BCE PID config files
-        - Fixed bug with FIND_NEUTRAL sub-FSM (command was not updating with each timer cycle)
+    Modified 2018-02-01 revA by Troy
+        - Fixed bugs with file opening and closing
+        - Made a directory printing function in the MbedLogger class that does not use the Directory List library (removed)
+    Modified 2018-02-02 revA by Troy
+        - Placed mbed file transmitter functionality into MbedLogger class
+        - created a macro for printing out files to PC and serial port simultaneously (placed in main)
+    Modified 2018-02-07 revA by Troy
+        - SDFileSystem class added to code along with sd card file system in System "StaticDefs"
+        - Had to fix bug with SDFileSystem, the imported version uses a buggy FATFileSystem class
+        - Update came from https://os.mbed.com/teams/mbed-official/code/FATFileSystem/  (not the library importer tool)
+        - Modified MbedLogger constructor to include string for file system, e.g. "/sd/" and "/local/"
+        - Modified MbedLogger class to use local or sd card
+        - Created SD card file system using reader on pins p11, p12, p13, p14 (SPI interface)
+    Modified 2018-02-08 revA by Troy
+        - Test code without ADC running to check behavior (timing issue)
+        - Modified sequence to use sequence.txt and fixed warnings
+        - Fixed CRC issue with file reception (the command that the MBED sends out)
+        - Issue with IMU data on p27, need to check wiring and or MAX232
+    Modified 2018-02-14 revA by Troy
+        - IMU tested and working correctly
+        - Data logging on SD card and MBED working simultaneously
+        - State Machine is being used to transmit data over Xbee instead of a separate ticker
+        - Servo driver tested separately in FSG_servo_test program (verified servo works separately) 
+        - Electrical issue with PWM signal interfering with motor driver signal (disabled for now)
+        - 
 */
  
 #include "mbed.h"
@@ -50,8 +62,11 @@
     depth().init();
     depth().tare();
     
-    // construct a local file system
+    // construct the MBED local file system
     local();
+    
+    // construct the SD card file system
+    sd_card();
  
     // load config data from files
     configFileIO().load_BCE_config();      // load the buoyancy engine parameters from the file "bce.txt"
@@ -103,6 +118,7 @@
     
     //create log files if not present on file system
     mbedLogger().initializeLogFile();
+    sdLogger().initializeLogFile();
     
     pc().printf("Size of ConfigFile: %d\n\r", sizeof(ConfigFile));
     pc().printf("Size of ConfigFileIO: %d\n\r", sizeof(ConfigFileIO));
@@ -148,7 +164,7 @@
             else if(current_state != 0) {
                 if (!file_opened) {                                 //if the log file is not open, open it
                     mbedLogger().appendLogFile(current_state, 0);   //open MBED file once
-                    //sdLogger().appendLogFile(current_state, 0);     //open SD file once
+                    sdLogger().appendLogFile(current_state, 0);     //open SD file once
                                
                     file_opened = true;                             //stops it from continuing to open it
 
@@ -157,7 +173,7 @@
                 
                 //record to Mbed file system     
                 mbedLogger().appendLogFile(current_state, 1);    //writing data
-                //sdLogger().appendLogFile(current_state, 1);    //writing data
+                sdLogger().appendLogFile(current_state, 1);    //writing data
             }
             
             //when the current FSM state is zero, reset the file
@@ -165,7 +181,7 @@
                 //this can only happen once
                 if (file_opened) {
                     mbedLogger().appendLogFile(current_state, 0);    //close log file
-                    //sdLogger().appendLogFile(current_state, 0);    //close log file
+                    sdLogger().appendLogFile(current_state, 0);    //close log file
                     
                     file_opened = false;