Arianna autonomous DAQ firmware

Dependencies:   mbed SDFileSystemFilinfo AriSnProtocol NetServicesMin AriSnComm MODSERIAL PowerControlClkPatch DS1820OW

Revision:
39:2f17131d22a5
Parent:
31:b5bd3b189150
Child:
40:1324da35afd4
--- a/SnConfigFrame.h	Wed May 29 18:54:19 2013 +0000
+++ b/SnConfigFrame.h	Tue Jul 30 02:03:21 2013 +0000
@@ -31,7 +31,9 @@
     static const uint32_t   kMaxSizeOfV3 =
             kMaxSizeOfV2 + (2u*sizeof(uint16_t)) + (4u*kIPLen*sizeof(char));
     static const uint32_t   kMaxSizeOfV4 = kMaxSizeOfV3 + (sizeof(float)-sizeof(uint16_t));
-    static const uint32_t   kMaxSizeOf = kMaxSizeOfV4;
+    static const uint32_t   kMaxSizeOfV5 = kMaxSizeOfV4;
+    static const uint32_t   kMaxSizeOfV6 = kMaxSizeOfV5 + sizeof(int16_t);
+    static const uint32_t   kMaxSizeOf = kMaxSizeOfV6;
     
     enum EDatPackBit {
         kSDcard = BIT(0),
@@ -46,7 +48,7 @@
         kTimeout        =  BIT(2), // if bit=0 => ignore timeout
         kDelete         =  BIT(3), // if bit=0 => do not delete sent files
         kForceSBDdata   =  BIT(4), // if bit=0 => do not send data over SBD
-        kUseBits        = -BIT(15) // useful to initialize fCommSendData as a bit word
+        kUseBits        = static_cast<int16_t>(-BIT(14)) // useful to initialize fCommSendData as a bit word
     };
     
     enum EPowerModeBit {
@@ -100,7 +102,9 @@
     uint16_t    fEvtThrtlPeriodMs;         // throttle period to write events (ms)
     // power
     uint8_t     fPowerMode;                // power mode bit word: see EPowerModeBit
-    int16_t     fBatVoltLowPwr;            // battery level at which to switch to low power (not used?)
+    //int16_t     fBatVoltLowPwr;            // battery level at which to switch to low power (not used?) deprecated for hysteresis
+    int16_t     fBatVoltToLowPwr;          // battery level at which to switch to low power (not used?)
+    int16_t     fBatVoltFromLowPwr;        // battery level at which to switch back from low power (not used?)
     uint16_t    fVoltCheckPeriod;          // how often to check the voltages (s)
     // communication
     uint32_t    fCommWinPeriod;            // seconds between communication window startup (0=always on)
@@ -141,8 +145,18 @@
             maxsize = kMaxSizeOfV2;
         } else if (rv==3) {
             maxsize = kMaxSizeOfV3;   
+        } else if (rv==4) {
+            maxsize = kMaxSizeOfV4;   
+        } else if (rv==5) {
+            maxsize = kMaxSizeOfV5;   
+        } else if (rv==6) {
+            maxsize = kMaxSizeOfV6;   
         }
-        uint32_t sz = maxsize - kConfLblLen + lblLen;
+        const int32_t lbldiff = kConfLblLen - lblLen;
+        uint32_t sz = maxsize - lbldiff;
+        if ((lbldiff!=0) && (rv>=4)) {
+            sz += 1; // the \0 at the end of the string
+        }
         static const uint32_t mhlp = 2u*kNplas*sizeof(uint16_t);
         const int32_t dp = (nplas-kNplas)*sizeof(uint16_t);
         const uint8_t fac = (streamHiLoPlas) ? 3u : 1u;
@@ -179,7 +193,8 @@
     uint16_t GetEvtThrtlPeriodMs() const { return fEvtThrtlPeriodMs; }
     float    GetForceTrigPeriod() const { return fForceTrigPeriod; }
     uint16_t GetHeartbeatPeriod() const { return fHeartBeatPeriod; }
-    uint16_t GetBatVoltLowPwr() const { return fBatVoltLowPwr; }
+    uint16_t GetBatVoltToLowPwr() const { return fBatVoltToLowPwr; }
+    uint16_t GetBatVoltFromLowPwr() const { return fBatVoltFromLowPwr; }
     uint16_t GetVoltCheckPeriod() const { return fVoltCheckPeriod; }
     uint32_t GetWatchdogPeriod() const { return fWatchDogPeriod; }
     uint16_t GetDac(const uint8_t ch, const uint8_t dn) const { return fDAC[ch][dn]; }
@@ -369,9 +384,17 @@
 #ifdef DEBUG
             printf("pow=%hhu\r\n",fPowerMode);
 #endif
-            b           = SnBitUtils::ReadFrom(b, fBatVoltLowPwr);
+            if (Rv<6) {
+                b       = SnBitUtils::ReadFrom(b, fBatVoltToLowPwr);
 #ifdef DEBUG
-            printf("batlow=%hd\r\n",fBatVoltLowPwr);
+                printf("batlow=%hd\r\n",fBatVoltToLowPwr);
+#endif
+            } else {
+                b       = SnBitUtils::ReadFrom(b, fBatVoltToLowPwr);
+                b       = SnBitUtils::ReadFrom(b, fBatVoltFromLowPwr);
+            }
+#ifdef DEBUG
+                printf("batlow(to,from)=(%hd,%hd)\r\n",fBatVoltToLowPwr,fBatVoltFromLowPwr);
 #endif
             if (Rv>2) {
                 b       = SnBitUtils::ReadFrom(b, fVoltCheckPeriod);
@@ -478,6 +501,7 @@
         b           = SnBitUtils::WriteTo(b, kIOVers); // i/o version
         b           = SnBitUtils::WriteTo(b, llen);
         b           = SnBitUtils::WriteTo(b, fLabel, llen);
+        b           = SnBitUtils::WriteTo(b, char('\0'));
         b           = SnBitUtils::WriteTo(b, fConfTime);
         b           = SnBitUtils::WriteTo(b, fRun);
         b           = SnBitUtils::WriteTo(b, fFirstEvt);
@@ -504,7 +528,8 @@
         b           = SnBitUtils::WriteTo(b, fAmpsOn);
         b           = SnBitUtils::WriteTo(b, fEvtThrtlPeriodMs);
         b           = SnBitUtils::WriteTo(b, fPowerMode);
-        b           = SnBitUtils::WriteTo(b, fBatVoltLowPwr);
+        b           = SnBitUtils::WriteTo(b, fBatVoltToLowPwr);
+        b           = SnBitUtils::WriteTo(b, fBatVoltFromLowPwr);
         b           = SnBitUtils::WriteTo(b, fVoltCheckPeriod);
         b           = SnBitUtils::WriteTo(b, fCommWinPeriod);
         b           = SnBitUtils::WriteTo(b, fCommWinDuration);