]> oss.titaniummirror.com Git - tinyos-2.x.git/commitdiff
Initial TestTymo commit
authorstrabest <strabest>
Mon, 18 Feb 2008 21:52:44 +0000 (21:52 +0000)
committerstrabest <strabest>
Mon, 18 Feb 2008 21:52:44 +0000 (21:52 +0000)
apps/tests/TestTymo/Makefile [new file with mode: 0644]
apps/tests/TestTymo/TestC.nc [new file with mode: 0644]
apps/tests/TestTymo/TestM.nc [new file with mode: 0644]
apps/tests/TestTymo/meyer-light.txt [new file with mode: 0644]
apps/tests/TestTymo/test.py [new file with mode: 0644]
apps/tests/TestTymo/topo.txt [new file with mode: 0644]
apps/tests/TestTymo/volumes-stm25p.xml [new file with mode: 0644]

diff --git a/apps/tests/TestTymo/Makefile b/apps/tests/TestTymo/Makefile
new file mode 100644 (file)
index 0000000..7812a6c
--- /dev/null
@@ -0,0 +1,5 @@
+COMPONENT=TestC
+PFLAGS += -I../../../tos/lib/net/tymo -I../../../tos/lib/net/tymo/dymo -I../../../tos/lib/net/tymo/mh
+DOCDIR=~/tymo/web/html-doc/
+
+include $(MAKERULES)
\ No newline at end of file
diff --git a/apps/tests/TestTymo/TestC.nc b/apps/tests/TestTymo/TestC.nc
new file mode 100644 (file)
index 0000000..0e80be8
--- /dev/null
@@ -0,0 +1,27 @@
+
+#define CC2420_DEF_RFPOWER 1
+#define MAX_TABLE_SIZE 10
+//#define DYMO_MONITORING
+
+configuration TestC {
+
+}
+
+implementation {
+  components TestM, DymoNetworkC;
+  components MainC, LedsC, new TimerMilliC();
+
+  TestM.Boot  -> MainC;
+  TestM.Leds  -> LedsC;
+  TestM.Timer -> TimerMilliC;
+  TestM.SplitControl -> DymoNetworkC;
+  TestM.Packet       -> DymoNetworkC;
+  TestM.MHPacket     -> DymoNetworkC;
+  TestM.Receive      -> DymoNetworkC.Receive[1];
+  TestM.Intercept    -> DymoNetworkC.Intercept[1];
+  TestM.MHSend       -> DymoNetworkC.MHSend[1];
+
+#ifdef DYMO_MONITORING
+  TestM.DymoMonitor -> DymoNetworkC;
+#endif
+}
diff --git a/apps/tests/TestTymo/TestM.nc b/apps/tests/TestTymo/TestM.nc
new file mode 100644 (file)
index 0000000..2903fbd
--- /dev/null
@@ -0,0 +1,121 @@
+#include "routing_table.h"
+
+module TestM {
+  
+  uses {
+    interface Boot;
+    interface Leds;
+    interface SplitControl;
+    interface AMPacket as MHPacket;
+    interface Packet;
+    interface Receive;
+    interface Intercept;
+    interface AMSend as MHSend;
+    interface Timer<TMilli>;
+  }
+#ifdef DYMO_MONITORING
+  uses interface DymoMonitor;
+#endif
+}
+
+implementation {
+
+  message_t packet;
+
+  enum {
+    ORIGIN = 1,
+    TARGET = 3,
+  };
+
+  void display(message_t * msg){
+    uint8_t * payload = NULL;
+    uint8_t size;
+    int8_t i;
+    dbg("messages", "message content:\n");
+    for(i=0; i<size; i+=4, payload+=4){
+      dbg("messages", "\t%hhu\t%hhu\t%hhu\t%hhu\n", *payload, *(payload+1), *(payload+2), *(payload+3));
+    }
+  }
+
+  void setLeds(uint16_t val) {
+    if (val & 0x01)
+      call Leds.led0Toggle();
+    if (val & 0x02)
+      call Leds.led1Toggle();
+    if (val & 0x04)
+      call Leds.led2Toggle();
+  }
+
+  task void stop(){
+    call SplitControl.stop();
+  }
+
+  event void Boot.booted(){
+    call SplitControl.start();
+  }
+
+  event void SplitControl.startDone(error_t e){
+    if(call MHPacket.address() == ORIGIN){
+      call Timer.startPeriodic(2048);
+    }
+  }
+
+  event void Timer.fired(){
+    nx_uint16_t * payload = call Packet.getPayload(&packet, 2);
+    error_t error;
+    *payload = 1664;
+    error = call MHSend.send(TARGET, &packet, sizeof(*payload));
+    if(error == SUCCESS){
+      dbg("messages", "Sending a beer...\n");
+    } else {
+      dbg("messages", "Unable to send the beer! - %hhu\n", error);
+    }
+  }
+
+  event void MHSend.sendDone(message_t * msg, error_t e){
+    if((e == SUCCESS) && (msg == &packet) && (call MHPacket.address() == ORIGIN)){
+      dbg("messages", "Beer successfully sent.\n");
+      setLeds(1);
+    } else if (e == FAIL) {
+      dbg("messages", "Sending the beer didn't succeed!\n");
+      setLeds(2);
+    } else {
+      dbg("messages", "What the hell is going on!?");
+    }
+  }
+  
+  event message_t * Receive.receive(message_t * msg, void * payload, uint8_t len){
+    if(call MHPacket.address() == TARGET){
+      dbg("messages", "I have received a message from %u\n", call MHPacket.source(msg));
+      dbg("messages", "It is a %u french beer, great! :o)\n", *(nx_uint16_t *)payload);
+      setLeds(4);
+    } else {
+      dbg("messages", "What is this message?\n");
+    }
+    return msg;
+  }
+
+  event bool Intercept.forward(message_t * msg, void * payload, uint8_t len){
+    setLeds(2);
+    return TRUE;
+  }
+
+  event void SplitControl.stopDone(error_t e){}
+
+#ifdef DYMO_MONITORING
+
+  event void DymoMonitor.msgReceived(message_t * msg){
+    dbg("messages", "Dymo msg received.\n");
+  }
+
+  event void DymoMonitor.msgSent(message_t * msg){
+    dbg("messages", "Dymo msg sent.\n");
+  }
+
+  event void DymoMonitor.routeDiscovered(uint32_t delay, addr_t target){
+    dbg("messages", "Route for %u discovered in %lu milliseconds.\n", target, delay);
+  }
+
+#endif
+
+}
diff --git a/apps/tests/TestTymo/meyer-light.txt b/apps/tests/TestTymo/meyer-light.txt
new file mode 100644 (file)
index 0000000..37bbafd
--- /dev/null
@@ -0,0 +1,100 @@
+-39
+-98
+-98
+-98
+-99
+-98
+-94
+-98
+-98
+-98
+-98
+-98
+-99
+-98
+-98
+-98
+-98
+-98
+-98
+-98
+-97
+-98
+-97
+-98
+-98
+-98
+-98
+-91
+-98
+-96
+-96
+-98
+-98
+-98
+-98
+-98
+-99
+-86
+-97
+-98
+-98
+-86
+-90
+-91
+-87
+-87
+-98
+-98
+-98
+-98
+-98
+-98
+-78
+-94
+-90
+-96
+-98
+-98
+-98
+-86
+-98
+-98
+-98
+-99
+-98
+-98
+-98
+-97
+-99
+-98
+-98
+-99
+-98
+-93
+-98
+-98
+-82
+-82
+-81
+-82
+-82
+-49
+-98
+-81
+-82
+-64
+-81
+-81
+-98
+-98
+-98
+-98
+-98
+-98
+-98
+-98
+-98
+-98
+-98
+-98
diff --git a/apps/tests/TestTymo/test.py b/apps/tests/TestTymo/test.py
new file mode 100644 (file)
index 0000000..078f353
--- /dev/null
@@ -0,0 +1,47 @@
+from TOSSIM import *
+import sys
+import time
+
+t = Tossim([])
+r = t.radio()
+f = open("topo.txt", "r")
+n = 0
+
+lines = f.readlines()
+for line in lines:
+  s = line.split()
+  if (len(s) > 0):
+#    print " ", s[0], " ", s[1], " ", s[2]
+    r.add(int(s[0]), int(s[1]), float(s[2]))
+
+
+t.addChannel("messages", sys.stdout)
+#t.addChannel("fwe", sys.stdout)
+#t.addChannel("mhe", sys.stdout)
+#t.addChannel("de", sys.stdout)
+t.addChannel("dt", sys.stdout)
+
+noise = open("meyer-light.txt", "r")
+lines = noise.readlines()
+for line in lines:
+  str = line.strip()
+  if (str != ""):
+    val = int(str)
+    for i in range(1, 4):
+      t.getNode(i).addNoiseTraceReading(val)
+
+for i in range(1, 4):
+#  print "Creating noise model for ",i
+  t.getNode(i).createNoiseModel()
+
+t.getNode(1).bootAtTime(100001);
+t.getNode(2).bootAtTime(200022);
+t.getNode(3).bootAtTime(300033);
+
+t.runNextEvent();
+time = t.time()
+while (time + 700000000000 > t.time()):
+  print t.time()
+  t.runNextEvent()
+
+sys.stderr.write("Finished!\n")
diff --git a/apps/tests/TestTymo/topo.txt b/apps/tests/TestTymo/topo.txt
new file mode 100644 (file)
index 0000000..9547d71
--- /dev/null
@@ -0,0 +1,6 @@
+1 2 -60.0
+
+2 1 -60.0
+2 3 -60.0
+
+3 2 -60.0
diff --git a/apps/tests/TestTymo/volumes-stm25p.xml b/apps/tests/TestTymo/volumes-stm25p.xml
new file mode 100644 (file)
index 0000000..a7b89c1
--- /dev/null
@@ -0,0 +1,3 @@
+<volume_table>
+  <volume name="DYMODATA" size="131072" />
+</volume_table>