Arianna autonomous DAQ firmware

Dependencies:   mbed SDFileSystemFilinfo AriSnProtocol NetServicesMin AriSnComm MODSERIAL PowerControlClkPatch DS1820OW

Revision:
28:484943132bb0
Parent:
21:ce51bb0ba4a5
Child:
30:f869ed4bcc08
--- a/SnConfigFrame.h	Thu Nov 01 07:00:17 2012 +0000
+++ b/SnConfigFrame.h	Sat Nov 24 06:38:43 2012 +0000
@@ -17,6 +17,7 @@
     static const uint8_t     kIPLen=16;            // length of IP string. matches MBED's Socket class (so no ipv6)
     
     static const char* const kDefConfFile;  // default configuration file
+    static const char* const kDefIPflag;    // flag to use IP default
 
     static const uint32_t   kMaxSizeOfV1 = 
             + (9u*sizeof(uint32_t)) + (6u*sizeof(uint16_t))
@@ -149,7 +150,15 @@
         }
         return sz;
     }
-   
+
+    void SetDefaultIPs();
+    void SetDefaultRemoteServ();
+    void SetDefaultRemotePort();
+    void SetDefaultMbedIP();
+    void SetDefaultMaskIP();
+    void SetDefaultGateIP();
+    void ApplySafetyNets();
+
  public:
     SnConfigFrame() : fIsLowPower(false) { Reset(); }
     virtual ~SnConfigFrame() {}
@@ -385,22 +394,37 @@
 #endif
             if (Rv>2) {
                 b       = SnBitUtils::ReadFrom(b, fRemoteServer, kIPLen);
+                if (strncmp(fRemoteServer, kDefIPflag,kIPLen)==0) {
+                    SetDefaultRemoteServ();
+                }
 #ifdef DEBUG
                 printf("rserv=%s\r\n",fRemoteServer);
 #endif
                 b       = SnBitUtils::ReadFrom(b, fRemotePort);
+                if (fRemotePort==0) {
+                    SetDefaultRemotePort();
+                }
 #ifdef DEBUG
                 printf("rport=%hu\r\n",fRemotePort);
 #endif
                 b       = SnBitUtils::ReadFrom(b, fMbedIP, kIPLen);
+                if (strncmp(fMbedIP, kDefIPflag,kIPLen)==0) {
+                    SetDefaultMbedIP();
+                }
 #ifdef DEBUG
                 printf("mbedip=%s\r\n",fMbedIP);
 #endif
                 b       = SnBitUtils::ReadFrom(b, fMbedMask, kIPLen);
+                if (strncmp(fMbedMask, kDefIPflag,kIPLen)==0) {
+                    SetDefaultMaskIP();
+                }
 #ifdef DEBUG
                 printf("mbedmask=%s\r\n",fMbedMask);
 #endif
                 b       = SnBitUtils::ReadFrom(b, fMbedGate, kIPLen);
+                if (strncmp(fMbedGate, kDefIPflag,kIPLen)==0) {
+                    SetDefaultGateIP();
+                }
 #ifdef DEBUG
                 printf("mbedgate=%s\r\n",fMbedGate);
 #endif
@@ -424,6 +448,9 @@
                 }
             }
         }
+        
+        ApplySafetyNets();
+        
 #ifdef DEBUG
         printf("read from done\r\n");
 #endif