Arianna autonomous DAQ firmware

Dependencies:   mbed SDFileSystemFilinfo AriSnProtocol NetServicesMin AriSnComm MODSERIAL PowerControlClkPatch DS1820OW

Revision:
36:87865913ae6f
Parent:
35:549714a257a4
Child:
37:ff95e7070f26
--- a/main.cpp	Thu Feb 07 23:06:36 2013 +0000
+++ b/main.cpp	Thu May 23 22:26:39 2013 +0000
@@ -3,9 +3,9 @@
 #include "Watchdog.h"
 Watchdog::SnKickStarter gKickStarter(WDFAILSAFE);
 
-#define DISABLE_CONFIG_SAFETYNETS
+//#define DISABLE_CONFIG_SAFETYNETS
 
-#define ENABLE_AFAR_COMM
+//#define ENABLE_AFAR_COMM
 #define ENABLE_SBD_COMM
 //#define ENABLE_USB_COMM
 //#define ENABLE_AFAR_TWITTER
@@ -13,7 +13,7 @@
 //#define USE_RTOS_TIMER
 //#define USE_ETH_INTERFACE
 //#define EVT_TIME_PROFILE
-//#define DEBUG
+#define DEBUG
 //#define SSNOTIFY
 #define USE_MODSERIAL
 
@@ -537,7 +537,18 @@
     // seq 0 being overwritten upon power up or the SD card first
     // being insterted
     sd.disk_initialize();
-
+    
+    /*
+    {
+        uint32_t nfls=0; float totkb=0;
+        SnSDUtils::GetDirProps(SnSDUtils::kSDdir, nfls, totkb);
+        totkb /= 1e3; // KB
+#ifdef DEBUG
+        printf("nfiles=%u, tb=%g kb (%g)\r\n",nfls,totkb,totkb/1024.0);
+#endif
+    }
+    */
+    
 #ifdef DEBUG
     printf("making comm objects\r\n");
 #endif
@@ -1389,21 +1400,24 @@
                 continue;
             }
             // check Iridium time
+            // add on the SBD connect timeout so that we have a
+            // chance to set the clock even if we never got a response from UCI
+            const uint32_t extraTime = gLastCommWin + kConnectSBDTO;
             if ((*cw)->GetCommType()==SnConfigFrame::kIrid) {
 #ifdef DEBUG
                 printf("try to set iridium time\r\n");
 #endif
                 // set the clock before closing connection
-                 const bool con = 
-                    (*cw)->Connect(gConf.GetTimeoutTime(gLastCommWin,
-                                                  gConf.GetCommWinDuration()));
+                const bool con = 
+                    (*cw)->Connect(gConf.GetTimeoutTime(extraTime,
+                        gConf.GetCommWinDuration()));
                 if (con) {
                     const uint32_t nt = (*cw)->TrySetSysTimeUnix(
-                        gConf.GetTimeoutTime(gLastCommWin,gConf.GetCommWinDuration()));
+                        gConf.GetTimeoutTime(extraTime,gConf.GetCommWinDuration()));
                 }
             }
             // close the connection
-            (*cw)->CloseConn(gConf.GetTimeoutTime(gLastCommWin,gConf.GetCommWinDuration()));
+            (*cw)->CloseConn(gConf.GetTimeoutTime(extraTime,gConf.GetCommWinDuration()));
             Watchdog::kick(); // don't reset!
             // after normal Afar connection closed, try to tweet
 #if defined(ENABLE_AFAR_TWITTER) && defined(ENABLE_AFAR_COMM)