Arianna autonomous DAQ firmware

Dependencies:   mbed SDFileSystemFilinfo AriSnProtocol NetServicesMin AriSnComm MODSERIAL PowerControlClkPatch DS1820OW

Revision:
41:d6f5e2f09e07
Parent:
40:1324da35afd4
Child:
54:ea1234a44fe8
--- a/SnCommWin.cpp	Sat Oct 05 04:45:22 2013 +0000
+++ b/SnCommWin.cpp	Tue Oct 08 23:44:00 2013 +0000
@@ -5,6 +5,7 @@
 #include "SnEventFrame.h"
 #include "SnPowerFrame.h"
 #include "SnStatusFrame.h"
+#include "SnSignalStrengthFrame.h"
 #include "SnSDUtils.h"
 #include "SnConstants.h"
 #include "SnCRCUtils.h"
@@ -657,6 +658,29 @@
     return mlen+flen;
 }
 
+SnCommWin::ECommWinResult SnCommWin::SendSignalStrength(char* const genBuf,
+                                                        SnSignalStrengthFrame& sigstr,
+                                                        const uint32_t timeout_clock) {
+    // try to get the signal strength and send it if possible
+    float ss;
+    if ( fComm->CheckSignalStrength(timeout_clock, ss) ) {
+        char* b = genBuf;
+        SnHeaderFrame::WriteTo(b, SnHeaderFrame::kSignalStrCode, sigstr.SizeOf());
+        sigstr.SetSigStr(ss, time(0));
+        sigstr.SetCommType( static_cast<uint8_t>(GetCommType()) );
+        sigstr.WriteTo(b);
+        const uint32_t bytesToBeSent = b - genBuf;
+        const int32_t mlen = fComm->SendAll(genBuf, bytesToBeSent, timeout_clock);
+        const int32_t flen = fComm->FinishSending(timeout_clock);
+        if (bytesToBeSent==(mlen+flen)) {
+            return SnCommWin::kOkMsgSent;
+        } else {
+            return SnCommWin::kFailPartSent;
+        }
+    }
+    return SnCommWin::kFailNoneSent;
+}
+
 SnCommWin::ECommWinResult SnCommWin::SendStatus(const SnConfigFrame& conf,
                                                 const SnEventFrame& evt,
                                                 const SnPowerFrame& pow,
@@ -685,8 +709,12 @@
     printf("calling SendAll (status)\r\n");
 #endif
     int32_t mlen = fComm->SendAll(genBuf, msiz, timeout_clock);
+#ifdef DEBUG
+    printf("SendAll returned %d\r\n",mlen);
+#endif
     mlen += fComm->FinishSending(timeout_clock);
 #ifdef DEBUG
+    printf("mlen=%d after FinishSending. msiz=%d\r\n",mlen,msiz);
     printf("status frame:\r\n");
     for (uint32_t i=0; i<msiz; i++) {
         printf("%02X ",genBuf[i]);