Arianna autonomous DAQ firmware

Dependencies:   mbed SDFileSystemFilinfo AriSnProtocol NetServicesMin AriSnComm MODSERIAL PowerControlClkPatch DS1820OW

Revision:
3:24c5f0f50bf1
Parent:
2:e67f7c158087
Child:
6:6f002d202f59
--- a/SnCommWin.cpp	Tue Jul 24 02:07:23 2012 +0000
+++ b/SnCommWin.cpp	Tue Jul 31 04:59:16 2012 +0000
@@ -11,19 +11,29 @@
 SnCommWin::ECommWinResult SnCommWin::SendData(SnConfigFrame& conf,
                                               SnEventFrame& evt,
                                               char* const genBuf,
+                                              const uint32_t bsize,
                                               const uint32_t timeout) {
+    printf("SnCommWin::SendData\r\n");
     ECommWinResult res = kUndefFail;
     if (conf.IsSendingAllFiles()) {
-        res = SnSDUtils::SendAllFiles(this, conf.IsDeletingFiles());
+        printf("sending all files\r\n");
+        const uint32_t to = (conf.IsObeyingTimeout()) ? timeout : kSecsPerYear;
+        res = SnSDUtils::SendAllFiles(this, conf.IsDeletingFiles(), to, genBuf, bsize);
     } else {
         if (conf.GetCommSendData()==0) {
+            printf("no data to send\r\n");
             res = kOkNoMsg;
         } else {
             const uint32_t nev = (conf.GetCommSendData()>0) ?
-                                  conf.GetCommSendData() 
-                                  : 0u; // send all events in file
+                                  conf.GetCommSendData() // send N events
+                                  : 0u; // send all events in last file
             res = SendData(SnSDUtils::GetCurFile(), SnSDUtils::GetCurFileName(),
                            conf, evt, genBuf, nev);
+            printf("after send data cur file, res=%d\r\n",(int)res);
+            if (res>kAllFails) {
+                printf("waiting for handshake\r\n");
+                res = WaitHandshake(timeout, genBuf, bsize);
+            }
         }
     }
     return res;
@@ -37,26 +47,28 @@
                                               const uint32_t firstEvt) {
     // nevts==0 ==> send all events
     // evtBuf should be 0 only if nevts==0
-    //
-    // this version should be used to send the current file (avoid fopen/fclose)
     
+    printf("SnCommWin::SendData cur file\r\n");
     ECommWinResult res = kUndefFail;
     if (inf!=0) {
-        if (nevts==0) {
-            res = SendData(inf);
-            if (curConf.IsDeletingFiles() && res>=kOkMsgSent) {
-                SnSDUtilsWhisperer::DeleteFile(inf, infn);
-            }
-        } else {
-            if (genBuf!=0) {
-                res = SendConfAndEvents(inf, curConf, evt, genBuf, nevts, firstEvt);
+        res = SendFilename(infn, genBuf);
+        if (res>kAllFails) {
+            if (nevts==0) {
+                res = SendData(inf);
+                if (curConf.IsDeletingFiles() && res>=kOkMsgSent) {
+                    SnSDUtilsWhisperer::DeleteFile(inf, infn);
+                }
+            } else {
+                if (genBuf!=0) {
+                    res = SendConfAndEvents(inf, curConf, evt, genBuf, nevts, firstEvt);
+                }
             }
         }
     }
     return res;
 }
 
-
+/*
 SnCommWin::ECommWinResult SnCommWin::SendData(const char* infn,
                                               const SnConfigFrame& curConf,
                                               SnEventFrame& evt,
@@ -78,3 +90,4 @@
     }
     return res;
 }
+*/
\ No newline at end of file