Testbed / Mbed 2 deprecated FTPGET_Merged

Dependencies:   SDFileSystem dspmodified mbed

Files at this revision

API Documentation at this revision

Comitter:
lalitkumar
Date:
Sun Jun 28 06:05:32 2015 +0000
Parent:
27:4eb9687ab6c2
Child:
29:4f2b3d68aa6b
Commit message:
last version before BI edit

Changed in this revision

SDFileSystem.lib Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
merged_code.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/SDFileSystem.lib	Fri Jun 26 11:27:07 2015 +0000
+++ b/SDFileSystem.lib	Sun Jun 28 06:05:32 2015 +0000
@@ -1,1 +1,1 @@
-http://developer.mbed.org/teams/Testbed/code/SDFileSystem/#7b35d1709458
+http://developer.mbed.org/teams/Testbed/code/SDFileSystem/#ddd0ac1e8bf0
--- a/mbed.bld	Fri Jun 26 11:27:07 2015 +0000
+++ b/mbed.bld	Sun Jun 28 06:05:32 2015 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/4fc01daae5a5
\ No newline at end of file
+http://mbed.org/users/mbed_official/code/mbed/builds/7cff1c4259d7
\ No newline at end of file
--- a/merged_code.cpp	Fri Jun 26 11:27:07 2015 +0000
+++ b/merged_code.cpp	Sun Jun 28 06:05:32 2015 +0000
@@ -2,8 +2,6 @@
 Designed to work from year 2015 to 2020
 */
 
-//Timestamp store bug in fft file pending
-
 #include "mbed.h"
 #include "arm_math.h"
 #include "SDFileSystem.h"
@@ -75,6 +73,7 @@
 uint32_t dataLength = dur_sec*freq*1000;
 int avg_dc_detect[2]; 
 int avg_temp[2];
+bool sd_status_flag=0;
 
 //--------------------------------------------------------------------------------------------------//
 //                  Module reset                                                                    //
@@ -126,14 +125,15 @@
     if(clk_flag == 1) 
         {
             //pc.printf("\r\nclock updated\r\n");
-            sprintf(timestamp,response);
+            sprintf(timestamp,"%.49s",response);
             //pc.printf("%s",timestamp);                                                                  //copies response to timestamp for further processing 
         }
     if(clk_flag == 3) 
         {
             pc.printf("timestamp stored11: %s", time_stamp);
-            sprintf(csq,response);
-            pc.printf("timestamp stored12: %s", time_stamp);                                                                 //copies response to csq for further processing 
+            sprintf(csq,"%.49s",response);
+            pc.printf("timestamp stored12: %s", time_stamp);
+            pc.printf ("end");                                                                 //copies response to csq for further processing 
         }
     //pc.printf("\r\nanswer %d\r\n",answer);
     return answer;
@@ -530,34 +530,6 @@
         fclose(fp);
     }
 }
-//--------------------------------------------------------------------------------------------------//
-//                 Remove File from Directory                                                       //
-//--------------------------------------------------------------------------------------------------//
-
-void do_remove(const char *fsrc)
-{
-    pc.printf("\r\n Deleting... \r\n");
-    DIR *d = opendir(fsrc);
-    if(d==NULL)
-    {
-        pc.printf("\r\n NULL Condition\r\n");
-        return;
-    }
-    else
-    {
-        struct dirent *p;
-        char path[100] = {0};
-        while((p = readdir(d)) != NULL) 
-        {
-        strcpy(path, fsrc);
-        strcat(path, "/");
-        strcat(path, p->d_name);
-        remove(path);
-        }
-    }
-    closedir(d);
-    remove(fsrc);
-}
 
 //--------------------------------------------------------------------------------------------------//
 //                  Storage                                                                         //
@@ -568,7 +540,7 @@
 // AC Sample storage
     sprintf(filenameAC,"%sAC.txt",filename);
     sprintf(pathAC,"%sAC.txt",filepath);
-    //pc.printf("\r\nFilename-AC\t%s", pathAC);
+    pc.printf("\r\nFilename-AC\t%s", pathAC);
     FILE *fp = fopen(pathAC, "w");
     
     if(fp == NULL) 
@@ -894,7 +866,7 @@
                 }
             }
         }
-        for(int ftp_close_attempt=0; ftp_close_attempt<2; ftp_close_attempt++) 
+        for(int ftp_close_attempt=0; ftp_close_attempt<1; ftp_close_attempt++) 
         {
             //pc.printf("\r\nftp_close\r\n");
             if(sendATcommand("AT+FTPPUT=2,0", "OK", 5,0)) 
@@ -994,7 +966,7 @@
                          ftp_put(2);
                      }
                      // Delete the particular Folder Case : 4
-                     else if(atoi(token) ==4)
+                     /*else if(atoi(token) ==4)
                      {
                          //FOR DELETING THE SELECTED FILE
                         char removefile[100]="";
@@ -1013,7 +985,7 @@
                                 do_remove(removefile);
                                 pc.printf("\r\n File Deleted\r\n");
                             }
-                      } 
+                      }*/ 
                       /*
                       else if(atoi(token)==5)
                       {
@@ -1072,31 +1044,37 @@
     if(gsm_init()==0){
         reset_mod();                     //COA for gsm init failure TBD
         }
-    mkdir("/sd/jas",0777);
     int old_hour=100,loopcount=0;
-    pc.printf("\r\nHelloWorld\r\n");
     sendATcommand("AT+CLTS=1\r", "OK", 15,2);
     //wait(10);
     GetFileDir();
-    FILE *fp = fopen("/sd/SiteInfo.txt","a");
-    if(fp == NULL) 
-    {
-        FILE *fp = fopen("/sd/SiteInfo.txt","w");
-        fprintf(fp, "\r\n%s",time_stamp);
-
-    } 
-    else 
-    {
-        fprintf(fp, "\r\n%s",time_stamp);
-        pc.printf("timestamp: \r\n%s",time_stamp);
-        fclose(fp);
-    }
+    pc.printf("\r\ngetfiledir complete\r\n");
+    if(sd.disk_initialize()==0)    
+        {   
+            sd_status_flag=1;
+            mkdir("/sd/jas",0777);
+            FILE *fp = fopen("/sd/SiteInfo.txt","a");
+            if(fp == NULL) 
+                {
+                    FILE *fp = fopen("/sd/SiteInfo.txt","w");
+                    fprintf(fp, "\r\n%s",time_stamp);
+            
+                } 
+            else 
+                {
+                    fprintf(fp, "\r\n%s",time_stamp);
+                    pc.printf("timestamp: \r\n%s",time_stamp);
+                    fclose(fp);
+                }
+        }
     pc.printf("\r\n Timestamp saved");
     
     
     while(1) 
     {
-        pc.printf("\r\n%d\t%d\r\n",hour,old_hour);
+        if(sd.disk_initialize()==0) sd_status_flag=1;
+        else sd_status_flag=0;
+        pc.printf("sd_status %d\r\n%d\t%d\r\n",sd_status_flag,hour,old_hour);
         sampling();
         store();
         FTP_Fun();
@@ -1108,7 +1086,7 @@
             {
                 sprintf(filenamefft,"%s",timestampname_old);
                 sprintf(pathfft,"%s",timestamppath_old);
-                ftp_put(0);
+                ftp_put(2);
             }
             downloadFTP();    // For FTPGET Function 
         }
@@ -1127,3 +1105,40 @@
         //wait(10);
     }
 }
+
+
+
+
+
+
+
+
+
+//--------------------------------------------------------------------------------------------------//
+//                 Remove File from Directory                                                       //
+//--------------------------------------------------------------------------------------------------//
+
+/*void do_remove(const char *fsrc)
+{
+    pc.printf("\r\n Deleting... \r\n");
+    DIR *d = opendir(fsrc);
+    if(d==NULL)
+    {
+        pc.printf("\r\n NULL Condition\r\n");
+        return;
+    }
+    else
+    {
+        struct dirent *p;
+        char path[100] = {0};
+        while((p = readdir(d)) != NULL) 
+        {
+        strcpy(path, fsrc);
+        strcat(path, "/");
+        strcat(path, p->d_name);
+        remove(path);
+        }
+    }
+    closedir(d);
+    remove(fsrc);
+}*/
\ No newline at end of file