improved sigstr, more robust to different telnets
authordrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Tue, 7 Dec 2010 22:08:27 +0000 (22:08 +0000)
committerdrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Tue, 7 Dec 2010 22:08:27 +0000 (22:08 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@262 01035d8c-6547-0410-b346-abe4f91aad63

dilimesh/cgi-bin/getsig.cgi
dilimesh/dilimesh/dilimesh.html
dilimesh/scripts/sigstr.sh

index 24374443b265f96fdb61c51762313dd92c35f85d..1850fccf008f4db4a0ac4f51a21ab8be5db5824a 100755 (executable)
@@ -18,8 +18,8 @@ Content-type: text/html
 EOF
 
 ip=`echo "$QUERY_STRING" | sed -n "s/.*ip=//p" | sed "s/,/ /g"`
+nc $ip 4950
 echo $ip
-nc $ip 4950 | sed -e "1d"
 
 cat <<EOF
 </body>
index 393d834bcea808329f91044f27e10e99480b9780..9f1bcb847a0515b14313e73db69908febaef88aa 100644 (file)
     }    
                                                  
     if (ips != "") {
-      downloadUrl("/cgi-bin/fpingnodes.cgi?" + ips, processFping);                                               
+      downloadUrl("/cgi-bin/fpingnodes.cgi?" + ips, processFping);
 
       // set up HTML for ping tests of all nodes
     
     var nodes_poor_packet_loss = 0;
     for (var j=0; j<nodes.length; j++) {
       if (doc.indexOf(nodes[j].ip) == -1) {
         // no ping from node
         nodes[j].marker.setIcon("node_dead.png");
         // update IIR averaging filter
         nodes[j].packet_loss = 0.875*nodes[j].packet_loss + 0.125;
-        //log("  no ping, packet_loss = " + nodes[j].packet_loss);
       }
       else {
 
 
         nodes[j].packet_loss = 0.875*nodes[j].packet_loss;
         nodes_reachable++;
-        //log("  ping, packet_loss = " + nodes[j].packet_loss);
-
       }
 
       // Change icon based on packet loss
   function processgetSig(doc, status) {
     log("processgetSig");
    
-    // extract our lines from the HTML
-
+    // extract our lines from the HTML using state machine
+   
     var lines = doc.split("\n");
     var ip;
     var neighour_ips;
     var neighour_sigs
-    var text_line = 0;
+    var state = "start";
+    var next_state;
     for (var j=0; j<lines.length; j++) {
 
-      // look for the three lines we want, these don't have '<' on them
-      // must a better way to grok html....
-
-      if ((lines[j].indexOf('<') == -1) && (lines[j] != "")) {
-        if (text_line == 0)
-          ip = lines[j];
-        if (text_line == 1)
-          neighbour_ips = lines[j].split(" ");
-        if (text_line == 2)
-          neighbour_sigs = trim(lines[j]).split(" ");
-        text_line++;
+      next_state = state;
+      if (state == "start") {
+        if (lines[j].indexOf('sigstr') != -1)
+          next_state = "read ips";
+      }
+      if (state == "read ips") {
+        neighbour_ips = lines[j].split(" ");
+        next_state = "read sigs";
       }
+      if (state == "read sigs") {
+        neighbour_sigs = trim(lines[j]).split(" ");
+        next_state = "read ip";
+      }
+      if (state == "read ip") {
+        ip =lines[j];
+        next_state = "finished";
+      }
+      state = next_state;
     }
 
-    if (text_line == 3) {
+    if (state == "finished") {
  
      // walk nodes list to match ip
 
           var html="<table>";
           for(var i=0; i<neighbour_ips.length; i++) {
             html += '<tr><td>' + trim(neighbour_ips[i]) + '</td><td>' + trim(neighbour_sigs[i]) + ' dBm</td></tr>';
-         }
+          }
           html += '</table>';
          document.getElementById('sigstr_last_node').innerHTML = ip;
          document.getElementById('sigstr_results').innerHTML = html;
index fd787d3d1571be827665c8733b0c5633cfbea19b..726458a4d7069720f1575f50db3f1fd87450c4d0 100755 (executable)
@@ -2,18 +2,20 @@
 # node_tune.sh
 # David Rowe 13 April 2010
 #
-# Prints the IPs and signal strengths of nodes we can see.
+# Prints information useful for tuning a mesh node
 #
-# Run as a telnet login, e.g. on node 10.130.1.100
-#   telnetd -l /usr/sbin/sigstr.sh -p 4950
-# Test:
-#  "telnet 10.130.1.100 4950"
+# Useful to run as a telnet login, e.g.
+#   telnetd -l /usr/sbin/node_tune.sh -p 4950
+# will let you plug a laptop into eth0 and "telnet 192.168.1.20 4950"
+# to run this script
 
   # list of nodes this node can see in IP and MAC order
   
   IP=`cat /proc/net/arp | grep "10.130.1" | awk '{ print $1 }'`
   MAC=`cat /proc/net/arp | grep "10.130.1" | awk '{ print $4 }'`
   
+  echo
+  echo "sigstr"
   echo $IP
   for m in $MAC
   do