Arianna autonomous DAQ firmware

Dependencies:   mbed SDFileSystemFilinfo AriSnProtocol NetServicesMin AriSnComm MODSERIAL PowerControlClkPatch DS1820OW

Revision:
40:1324da35afd4
Parent:
37:ff95e7070f26
Child:
41:d6f5e2f09e07
--- a/SnCommWinTwitter.cpp	Tue Jul 30 02:03:21 2013 +0000
+++ b/SnCommWinTwitter.cpp	Sat Oct 05 04:45:22 2013 +0000
@@ -25,7 +25,7 @@
                                       conf.GetMbedGate())) {
     // prevent this second NetIf from re-initializing the ethernet,
     // which would cause a crash
-    dynamic_cast<SnCommAfarNetIf*>(fComm)->SetEthSetup(true);
+    static_cast<SnCommAfarNetIf*>(fComm)->SetEthSetup(true);
     // make the random number sequence unique for each station
     srand(conf.GetMacAddress() & 0xFFFFFFFF);
 }
@@ -54,21 +54,20 @@
     printf("%s",post.c_str());
 #endif
     const uint32_t ps = post.size();
-    int mlen = fComm->SendAll(post.c_str(), ps, timeout);
+    int32_t mlen = fComm->SendAll(post.c_str(), ps, timeout);
+    mlen += fComm->FinishSending(timeout);
     if (ps==mlen) {
         // send content
 #ifdef DEBUG
         printf("%s\r\n",str);
 #endif
-        mlen = fComm->SendAll(str, len, timeout);
-        if (len==mlen) {
-            mlen = fComm->SendAll("\r\n\r\n\r\n", 6u, timeout);
-            if (6u==mlen) {
-                res = SnCommWin::kOkMsgSent;
-            }
+        mlen  = fComm->SendAll(str, len, timeout);
+        mlen += fComm->SendAll("\r\n\r\n\r\n", 6u, timeout);
+        mlen += fComm->FinishSending(timeout);
+        if ((6u+len)==mlen) {
+            res = SnCommWin::kOkMsgSent;
         }
     }
-    
     return res;
 }
 
@@ -87,9 +86,9 @@
 }
 
 void SnCommWinTwitter::GetTweet(char* genBuf,
-                                      const SnConfigFrame& conf,
-                                      const float thmrate,
-                                      const float evtrate) {
+                                const SnConfigFrame& conf,
+                                const float thmrate,
+                                const float evtrate) {
     const bool rok = (thmrate>0) && (evtrate>0);
     const int r = rok ? (rand() % 4) : (rand() % 3);
     char* b = genBuf;
@@ -106,41 +105,40 @@
 }
 
 void SnCommWinTwitter::GetTimeTweet(char* genBuf,
-                                          const SnConfigFrame& conf) {
+                                    const SnConfigFrame& conf) {
     time_t s = time(0);
     char* b = AppendMacId(genBuf, conf);
     b += sprintf(b, ": It's ");
     b += strftime(b, 32, "%H:%M:%S on %Y-%m-%d", localtime(&s));
-    b += sprintf(b, " and I'm buried in snow.");
+    b += sprintf(b, " in the ice.");
 }
 
 void SnCommWinTwitter::GetRunTweet(char* genBuf,
-                                         const SnConfigFrame& conf) {
+                                   const SnConfigFrame& conf) {
     char* b = GetGreeting(genBuf, conf);
-    b += sprintf(b, " I'm making run %u, sequence %hu. "
-                 "It's a little #cold.",
+    b += sprintf(b, " I'm making run %u, sequence %hu.",
                  conf.GetRun(), SnSDUtils::GetCurSeqNum());
 }
 
 void SnCommWinTwitter::GetRatesTweet(char* genBuf,
-                                           const SnConfigFrame& conf,
-                                           const float thmrate,
-                                           const float evtrate) {
+                                     const SnConfigFrame& conf,
+                                     const float thmrate,
+                                     const float evtrate) {
     char* b = GetGreeting(genBuf, conf);
-    b += sprintf(b, " I'm getting %2.2f #triggers and %2.2f "
-                 "#events per second!", thmrate, evtrate);
+    b += sprintf(b, " I'm getting %2.2f triggers and %2.2f "
+                 "events per second!", thmrate, evtrate);
 }
 
 void SnCommWinTwitter::GetBytesTweet(char* genBuf,
-                                           const SnConfigFrame& conf) {
+                                     const SnConfigFrame& conf) {
     char* b = GetGreeting(genBuf, conf);
-    b += sprintf(b, " I've got %2.2f KB of #data in %u files in my #icebox.",
-                 SnStatusFrame::GetTotKbytes(), SnStatusFrame::GetNfiles());
+    b += sprintf(b, " I've got %2.2f MB of disk space left.",
+                 SnStatusFrame::GetFreeMB());
 }
 
 char* SnCommWinTwitter::GetGreeting(char* genBuf,
-                                          const SnConfigFrame& conf) {
-    const int r = rand() % 5;
+                                    const SnConfigFrame& conf) {
+    const int r = rand() % 4;
     char* b = genBuf;
     if        (r==0) {
         b  = AppendMacId(b, conf);
@@ -151,21 +149,17 @@
         b += sprintf(b, ".");
     } else if (r==2) {
         b  = AppendMacId(b, conf);
-        b += sprintf(b, " reporting in!");
-    } else if (r==3) {
-        b += sprintf(b, "Hi, I'm ");
-        b  = AppendMacId(b, conf);
-        b += sprintf(b,". You may remember me.");
+        b += sprintf(b, " reporting in.");
     } else {
         b  = AppendMacId(b, conf);
-        b += sprintf(b, ". Again.");
+        b += sprintf(b, " again.");
     }
     
     return b;
 }
 
 char* SnCommWinTwitter::AppendMacId(char* genBuf,
-                                          const SnConfigFrame& conf) {
+                                    const SnConfigFrame& conf) {
     char* b = genBuf;
     b += sprintf(b, "%04llX", ((conf.GetMacAddress() >> 16) & 0xFFFF));
     return b;