Lucy Luz / Mbed 2 deprecated RwSDCard_Xml_GPS

Dependencies:   FileManager GPSGms6 SDFileSystem mbed

Fork of 2545_SD_Card by Craig Evans

Revision:
6:a05ec997c496
Parent:
5:07aaa6e3784c
diff -r 07aaa6e3784c -r a05ec997c496 FileManager.cpp
--- a/FileManager.cpp	Mon May 09 09:02:56 2016 +0000
+++ b/FileManager.cpp	Mon May 09 09:31:44 2016 +0000
@@ -15,15 +15,14 @@
     char* cpy = s;  // an alias to iterate through s without moving s
     char* temp = s;
 
-    for (int i = 0 ; i < size ; i++)
-    {
+    for (int i = 0 ; i < size ; i++) {
         if (*cpy != ' ')
             *temp++ = *cpy;
         cpy++;
     }
     *temp = 0;
     return;
-}    
+}
 static void getXmlText(char *str, char *ret)
 {
     int size = strlen(str);
@@ -31,25 +30,19 @@
     bool begin_text = false;
     char * ret_addr = ret;
     memset (ret,' ',XMLTEXT_SIZE);
-    
-    for(i = 0; i < size ; i++)
-    {
-        
-        if (*str == '>')
-        {
+
+    for(i = 0; i < size ; i++) {
+
+        if (*str == '>') {
             begin_text = true;
-        }
-        else if (begin_text && *str == '<')
-        {
+        } else if (begin_text && *str == '<') {
             begin_text = false;
             break;
-        }
-        else if (begin_text && *str != ' ')
-        {
+        } else if (begin_text && *str != ' ') {
             *ret = *str;
             ret++;
         }
-        
+
         str++;
     }
     removeSpaces(ret_addr, XMLTEXT_SIZE);
@@ -67,34 +60,25 @@
 
         ReadingFileState  state = STATE_FINDING;
         char buf[1024];
-        while (fgets(buf, sizeof(buf), fp) != NULL)
-        {
-            if (strstr (buf,DATA_TAG))
-            {
+        while (fgets(buf, sizeof(buf), fp) != NULL) {
+            if (strstr (buf,DATA_TAG)) {
                 state = STATE_FOUND_DATA;
-            }
-            else if (strstr (buf,GPS_TAG))
-            {
+            } else if (strstr (buf,GPS_TAG)) {
                 state = STATE_FOUND_GPS;
-            }
-            else if (strstr (buf,UPDATE_INTERVAL_TAG))
-            {
-                if (state == STATE_FOUND_GPS)
-                {
+            } else if (strstr (buf,UPDATE_INTERVAL_TAG)) {
+                if (state == STATE_FOUND_GPS) {
                     getXmlText(buf, m_GpsInterval);
                     printf("\r\n-found GPS interval %s ", m_GpsInterval);
                     state = STATE_FINDING;
-                }
-                else if(state == STATE_FOUND_DATA)
-                {
+                } else if(state == STATE_FOUND_DATA) {
                     getXmlText(buf, m_DataInterval);
                     printf("\r\n-found Data interval %s ", m_DataInterval);
                     state = STATE_FINDING;
                 }
             }
-        } 
+        }
         fclose(fp);  // ensure you close the file after reading
-    }   
+    }
 }
 void logGPSData(char date[], char time[])
 {
@@ -109,19 +93,19 @@
 
         printf("Done");
         fclose(fp);  // ensure you close the file after writing
-    }    
+    }
 }
 void logSystemData(float gps_interval)
 {
     FILE *fp = fopen(MINIRMS_LOG_FILE_NAME, "a");
 
-    
+
     if (fp == NULL) {  // if it can't open the file then print error message
         printf("Error! Unable to open file!\n");
     } else {  // opened file so can write
         fprintf(fp, "Start Mini-RMS System with Gps Interval = %f",gps_interval); // ensure data type matches
         fclose(fp);  // ensure you close the file after writing
-    }  
+    }
 }
 void delete_file(char filename[])
 {
@@ -158,30 +142,28 @@
         char buf[1024];
         int index = 0;
         memset(m_varList, ' ', sizeof(m_varList));
-        while (fgets(buf, sizeof(buf), fp) != NULL)
-        {
-            if (strstr (buf,VAR_NAME_TAG))
-            {
+        while (fgets(buf, sizeof(buf), fp) != NULL) {
+            if (strstr (buf,VAR_NAME_TAG)) {
                 getXmlText(buf , m_varList[index].varName);
-                
-            }
-            else if (strstr (buf,VAR_ADDR_TAG))
-            {
+
+            } else if (strstr (buf,VAR_ADDR_TAG)) {
                 getXmlText(buf , m_varList[index].varAddress);
                 index++;
             }
 
-        } 
+        }
         fclose(fp);  // ensure you close the file after reading
         m_amountVarList = index;
         return m_varList;
-    }   
+    }
 }
-int getAmountVarList(){
+int getAmountVarList()
+{
     return m_amountVarList;
-} 
-Variable_Data_TypeDef * getVarList(){
+}
+Variable_Data_TypeDef * getVarList()
+{
     return m_varList;
-} 
+}
 
-    
+