Arianna autonomous DAQ firmware

Dependencies:   mbed SDFileSystemFilinfo AriSnProtocol NetServicesMin AriSnComm MODSERIAL PowerControlClkPatch DS1820OW

Revision:
40:1324da35afd4
Parent:
28:484943132bb0
Child:
56:0bba0ef15697
--- a/SnStatusFrame.h	Tue Jul 30 02:03:21 2013 +0000
+++ b/SnStatusFrame.h	Sat Oct 05 04:45:22 2013 +0000
@@ -8,6 +8,7 @@
 #include "SnConfigFrame.h"
 #include "SnEventFrame.h"
 #include "SnSDUtils.h"
+#include "Watchdog.h"
 
 //#define ST_DEBUG
 
@@ -34,18 +35,29 @@
             + SnConfigFrame::kConfLblLen;
     static const uint32_t   kMaxSizeOfV3 = 
             kMaxSizeOfV2 + sizeof(uint32_t) + sizeof(float);
+    static const uint32_t   kMaxSizeOfV4 = kMaxSizeOfV3 - sizeof(uint32_t);
+    static const uint32_t   kMaxSizeOfV5 = kMaxSizeOfV4 + sizeof(uint8_t);
     static const uint32_t   kMaxSizeOf   = kMaxSizeOfV1;
     
+
  public:
     static bool             fgRecalcFiles;
  private:
+/*
     static uint32_t         fgNfiles;
     static float            fgTotKbytes;
+*/
+    static float            fgFreeMB;
+
  public:
+    /*
     static
     uint32_t    GetNfiles() { return fgNfiles; }
     static
     float       GetTotKbytes() { return fgTotKbytes; }
+    */
+    static
+    float       GetFreeMB() { return fgFreeMB; }
     
     static
     uint32_t    GetMaxSizeOf(const uint8_t rv) {
@@ -53,8 +65,14 @@
             return kMaxSizeOfV1;
          } else if (rv==2) {
             return kMaxSizeOfV2;
+         } else if (rv==3) {
+            return kMaxSizeOfV3;
+         } else if (rv==4) {
+            return kMaxSizeOfV4;
+         } else if (rv==5) {
+            return kMaxSizeOfV5;
          } else {
-            return kMaxSizeOfV3;
+            return kMaxSizeOf;
          }
     }
     
@@ -89,6 +107,7 @@
         x = SnBitUtils::WriteTo(x, evtrate);
         // file info
         if (fgRecalcFiles) {
+            /*
 #ifdef ST_DEBUG
             printf("Calling GetDirProps for %s\r\n",SnSDUtils::kSDdir);
 #endif
@@ -97,11 +116,23 @@
 #ifdef ST_DEBUG
             printf("nfiles=%u, tb=%g kb\r\n",fgNfiles,fgTotKbytes);
 #endif
+            */
+            fgFreeMB = SnSDUtils::GetFreeBytes() / 1048576.0;
+#ifdef ST_DEBUG
+            printf("fgFreeMB = %g\r\n",fgFreeMB);
+#endif
             fgRecalcFiles = false;
         }
+        /*
         x = SnBitUtils::WriteTo(x, fgNfiles);
         x = SnBitUtils::WriteTo(x, fgTotKbytes);
+        */
+        x = SnBitUtils::WriteTo(x, fgFreeMB);
         
+        // watchdog reset bit cleared after status received successfully, not here
+        const uint8_t wdreset = Watchdog::didWatchdogReset();
+        x = SnBitUtils::WriteTo(x, wdreset);
+
         return SnCommWin::kOkMsgSent;
     }