Data log for logging enviornmental, process and system state to FRAM or EPROM chips that do not have support for a file system. Includes support for multiple record types, evolving record types, automatic date and time stamp and copying contents to serial. Will soon support journaling to micro SD file system. We always log to fram first for speed and power conserfaction then copy in bulk to SD cards when we have charging power available.

Dependencies:   data_log mbed

Flexible Data Logger Example Use and Test Code

Detailed Documentation

See home page for data log library https://developer.mbed.org/users/joeata2wh/code/data_log/

License

By Joseph Ellsworth CTO of A2WH Take a look at A2WH.com Producing Water from Air using Solar Energy March-2016 License: https://developer.mbed.org/handbook/MIT-Licence Please contact us http://a2wh.com for help with custom design projects.

Revision:
2:74a52e5fd1ed
Parent:
1:58f86fb1fb22
Child:
3:ee7427ad4745
diff -r 58f86fb1fb22 -r 74a52e5fd1ed main.cpp
--- a/main.cpp	Thu Mar 31 05:02:57 2016 +0000
+++ b/main.cpp	Thu Mar 31 16:18:09 2016 +0000
@@ -24,6 +24,9 @@
 #define dataLogSelectPin PC_12
 
 //#define DO_LOG_ERASE  // uncomment to erase the existing log.
+//#define DO_SEND_MANUAL  // uncomment to send first 1000 bytes to pc on startup
+//#define DO_SEND_ALL // uncomment to send entire log to PC on startup
+#define DO_SEND_LAST // uncomment to sent last 900 bytes to pc on startup
 
 AnalogIn waterTempSense(A0);
 AnalogIn oxygenLevelSense(A1);
@@ -96,29 +99,43 @@
     DataLogChipType dlchip(dataLogMOSIPin, dataLogMISOPin, dataLogCLKPin, dataLogSelectPin);
     pc.printf("\r\nInitialized Data Log Chip");
     struct DLOG *lgr = dlMake(&dlchip, dlbuff, 80);    
+    
     pc.printf("\r\nInitialized Logger\r\n");    
     pc.printf("logger nextWritePos=%ld", lgr->nextWritePos);
     
     #ifdef DO_LOG_ERASE
-    //Erase the log But only if you really want to loose the
-    // data
-    pc.printf("ERASE LOG");
-    dlEraseLog(lgr);
-    pc.printf("afer erase logger nextWritePos=%ld", lgr->nextWritePos);
+      //Erase the log But only if you really want to loose the
+      // data
+      pc.printf("ERASE LOG");
+      dlEraseLog(lgr);
+      pc.printf("afer erase logger nextWritePos=%ld", lgr->nextWritePos);
     #endif 
     
-    // Manually Read first 1,000 bytes from the log
-    char rbuff[1001];
-    memset(rbuff,1001,0);
-    dlchip.readStream(dlFirstLogEntry, rbuff, 1000);
-    pc.printf("first 1000 characters from log\r\n%s\r\n", rbuff);
+    #ifdef DO_SEND_MANUAL
+      // Manually Read first 1,000 bytes from the log
+      // could contain some garbage since it does not
+      // pay attention to current log length.
+      char rbuff[1001];
+      memset(rbuff,1001,0);
+      dlchip.readStream(dlFirstLogEntry, rbuff, 1000);
+      pc.printf("first 1000 characters from log\r\n%s\r\n", rbuff);
+    #endif
     
-    // Send Log Contents to Serial port
-    // sends from byte zero of the log
-    // to byte 100,000 or end of log which ever comes 
-    // first. 
-    pc.printf("\r\nSend the contents of log to PC automated way\r\n");
-    dlReadSend(lgr, &pc, 0, 100000);
+    #ifdef DO_SEND_ALL
+      // Send Log Contents to Serial port
+      // sends from byte zero of the log
+      // to byte 100,000 or end of log which ever comes 
+      // first. 
+      pc.printf("\r\nSend the contents of log to PC automated way\r\n");
+      dlReadSendAll(lgr, &pc);
+      pc.printf("\r\nDONE SEND ALL\r\n");
+    #endif
+    
+    #ifdef DO_SEND_LAST
+      pc.printf("\r\nSend the last 900 bytes\r\n");
+      dlReadSendLast(lgr, &pc, 50000);
+      pc.printf("\r\nDONE Send Last\r\n");
+    #endif
     
     
     // Record our record headers.  These need to match the records we will