.

Dependencies:   SDHCFileSystem mbed

Revision:
23:7e6a9684f647
Parent:
22:605c2f33b340
Child:
24:4c823092012a
--- a/main.cpp	Sun Jan 27 20:14:11 2013 +0000
+++ b/main.cpp	Sat Apr 13 05:05:23 2013 +0000
@@ -87,8 +87,8 @@
 #define canTimeout 5
 #define maxFileNum 30
 
-void Log (char *message);
-void LogErr (char *message);
+void Log (char *message); //delete
+void LogErr (char *message); //deltete
 extern "C" void mbed_reset();
 
 time_t seconds ;
@@ -297,6 +297,7 @@
 
                 pc.printf("Using file %s\n",fileName);
                 file = fopen(fileName, "ab");
+                pc.printf("Using file2 %s\n",fileName);
                 
                 if(file==NULL){
                     pc.printf("\nUnable to open canlog\n\n\n\n");
@@ -341,11 +342,11 @@
                     file = fopen("/sd/loglog.new", "w");
                     while (!feof(rfile)) {
                         fscanf(rfile,"/sd/%2d%2d%4d.alc\r\n",&fmon,&fday,&ftime);
-                        //if ((fmon<t.tm_mon)&&(fday<=t.tm_mday)){ // Delete all files more than 1 month old
-                        if ((fmon < 12) || (t.tm_mon > 1)){
-                            fday = fday + fmon*31; //crude - february will store 3 extra days of data
-                        }
-                        if ((fday+14)<(t.tm_mday+t.tm_mon*31)){ // Delete all files more than ~14 days old
+                        //if ((fmon < 12) || (t.tm_mon > 1)){
+                        //    fday = fday + fmon*31; //crude - february will store 3 extra days of data
+                        //}
+                        //if ((fday+14)<(t.tm_mday+t.tm_mon*31)){ // Delete all files more than ~14 days old
+                        if (((fmon<=t.tm_mon)&&(fday<t.tm_mday))||(fmon>t.tm_mon+2)){ // Delete all files more than 1 month old
                             bit=true;
                             sprintf(sTemp,"/sd/%02d%02d%04d.alc",fmon,fday,ftime);
                             if ((remove(sTemp)==NULL)) {