File manager

Dependencies:   SDFileSystem

Dependents:   RwSDCard_Xml_GPS

Revision:
25:7f3420c04178
Parent:
24:5ee719582d1e
Child:
26:2f10fcabed0e
diff -r 5ee719582d1e -r 7f3420c04178 FileManager.cpp
--- a/FileManager.cpp	Wed May 25 12:02:43 2016 +0000
+++ b/FileManager.cpp	Thu May 26 09:40:49 2016 +0000
@@ -262,9 +262,11 @@
  * @param timestamp - time structure to get Date 
  * @param var       - float array to be log in the file
  * @param size      - size of the float array
+ * @param p_headerRequired - pointer to flag for log header
+ * @param msec      - time in millisecond
  * @retval None
  */
-void FILEMANAGER_LogRMSData(time_t timestamp ,float * var, int size, bool *  p_headerRequired)
+void FILEMANAGER_LogRMSData(time_t timestamp ,float * var, int size, bool *  p_headerRequired, uint32_t msec)
 {
     if (!m_sdCardIsPresent)
     {
@@ -280,7 +282,11 @@
     char file_name[] = RTL_LOG_FILE_NAME;
     
     /* Generate File name with timestamp */
+
     FILEMANAGER_GenerateFileNameWithTime(timestamp,file_name);
+    #if DEBUG
+    printf("\r\n File name is generated \n");
+    #endif
     if (*p_headerRequired || !FILEMANAGER_IsFileExist(file_name))
     {
         /* If file is not exist, log the header */
@@ -289,6 +295,9 @@
         /* Clear flag once header has been written */
         *p_headerRequired = false;
     }   
+    #if DEBUG
+    printf("\r\n Going to Open RMS File For write \n");
+    #endif
     /* Open file with "APPEND" mode */
     FILE *fp  = fopen(file_name, "a");
 
@@ -309,7 +318,7 @@
         printf("\r\n Writing to Log File (%s)....",file_name);
 
         /* Write timestamp */
-        fprintf(fp, "%d,%d",timestamp,(msec.read_ms()%MSEC_SCALE)); 
+        fprintf(fp, "%d,%d",timestamp,msec);
 
         /* Write variable data */
         for(int i = 0; i < size; i++)
@@ -393,7 +402,7 @@
  * @param gps_interval - 
  * @retval None
  */
-void FILEMANAGER_LogSystemData(float gps_interval)
+void FILEMANAGER_LogSystemData(float gps_interval,float rms_interval)
 {
     /* Open the file in append mode */
     FILE *fp = fopen(MINIRMS_LOG_FILE_NAME, "a");
@@ -409,9 +418,11 @@
     {
         /* Indicate LED Status (ON)*/
         FILEMANAGER_SetLedStatus(true);
-        
+        /* get Timestamp  */
+        time_t seconds = time(NULL);
+
         /* Write some message, which is TBD */    
-        fprintf(fp, "\nStart Mini-RMS System with Gps Interval = %f",gps_interval); 
+        fprintf(fp, "\nStart Mini-RMS System with At UTC Time %s , Gps Interval = %f second, RMS Interval = %f second, Variable = %d variable(s) ",ctime(&seconds),gps_interval,rms_interval,m_amountVarList); 
         fclose(fp);  // ensure you close the file after writing
     }
 }