]> oss.titaniummirror.com Git - tinyos-2.x.git/commitdiff
Update the testing code so it tests for radios being
authorscipio <scipio>
Tue, 19 Feb 2008 19:49:30 +0000 (19:49 +0000)
committerscipio <scipio>
Tue, 19 Feb 2008 19:49:30 +0000 (19:49 +0000)
turned on and off.

apps/tests/TestMultihopLqi/CC2420ActiveMessageC.nc
apps/tests/TestMultihopLqi/Makefile
apps/tests/TestMultihopLqi/MultihopOscilloscope.h
apps/tests/TestMultihopLqi/MultihopOscilloscopeAppC.nc
apps/tests/TestMultihopLqi/MultihopOscilloscopeC.nc
apps/tests/TestMultihopLqi/script.py

index ad1228af940df401f65057c31105b1e0947619ab..6758006d5c5b26188f5cfb74a666cc9b9c12e2c9 100644 (file)
@@ -1,5 +1,6 @@
 #include <sim_gain.h>
 #include <sim_tossim.h>
+#include <AM.h>
 
 module CC2420ActiveMessageC {
   provides interface CC2420Packet as Packet;
@@ -7,6 +8,9 @@ module CC2420ActiveMessageC {
 }
 implementation {
 
+  typedef struct cc2420_header {
+
+  } cc2420_header_t;
   /**
    * Get transmission power setting for current packet.
    *
@@ -59,10 +63,4 @@ implementation {
     
     return (uint8_t)sig;
   }
-  async command cc2420_header_t* Packet.getHeader(message_t* msg) {
-    return NULL;
-  }  
-  async command cc2420_metadata_t* Packet.getMetadata(message_t* msg) {
-    return NULL;
-  }  
 }
index 027077c675e8241dd11bded2af0b269a0ab2f3f9..5b6ef2b17bae701fccb387ee478ac7cfe4c5adb9 100644 (file)
@@ -1,4 +1,4 @@
 COMPONENT=MultihopOscilloscopeAppC
-CFLAGS += -I$(TOSDIR)/lib/net/ -I$(TOSDIR)/lib/net/lqi 
+CFLAGS += -I$(TOSDIR)/lib/net/ -I$(TOSDIR)/lib/net/lqi -I$(TOSDIR)/chips/cc2420/interfaces
 
 include $(MAKERULES)
index 29ebb8b7eb0ffbcefa05279586b4dc6acb8675ec..5f04053921da7d7eb56ffca1fc5ad93f6029e8e6 100644 (file)
@@ -21,7 +21,7 @@ enum {
      increase the message_t size. */
   NREADINGS = 5,
   /* Default sampling period. */
-  DEFAULT_INTERVAL = 200,
+  DEFAULT_INTERVAL = 1024,
   AM_OSCILLOSCOPE = 0x93
 };
 
index d2f0e48292776ee5094bb60fb6f91dc37df479cc..1f591c9e550af7e8a067c9d170b15ed728f36e10 100644 (file)
@@ -18,8 +18,8 @@
 
 configuration MultihopOscilloscopeAppC { }
 implementation {
-  components MainC, MultihopOscilloscopeC, LedsC, new TimerMilliC(), 
-    new DemoSensorC() as Sensor;
+  components MainC, MultihopOscilloscopeC, LedsC, new TimerMilliC(),
+    new TimerMilliC() as OnOffTimer, new DemoSensorC() as Sensor;
 
   //MainC.SoftwareInit -> Sensor;
   
@@ -27,7 +27,7 @@ implementation {
   MultihopOscilloscopeC.Timer -> TimerMilliC;
   MultihopOscilloscopeC.Read -> Sensor;
   MultihopOscilloscopeC.Leds -> LedsC;
-
+  MultihopOscilloscopeC.OnOffTimer -> OnOffTimer;
   //
   // Communication components.  These are documented in TEP 113:
   // Serial Communication, and TEP 119: Collection.
@@ -37,6 +37,7 @@ implementation {
     new CollectionSenderC(AM_OSCILLOSCOPE), // Sends multihop RF
     SerialActiveMessageC,                   // Serial messaging
     new SerialAMSenderC(AM_OSCILLOSCOPE);   // Sends to the serial port
+  components RandomC;
 
   MultihopOscilloscopeC.RadioControl -> ActiveMessageC;
   MultihopOscilloscopeC.SerialControl -> SerialActiveMessageC;
@@ -47,17 +48,15 @@ implementation {
   MultihopOscilloscopeC.Snoop -> Collector.Snoop[AM_OSCILLOSCOPE];
   MultihopOscilloscopeC.Receive -> Collector.Receive[AM_OSCILLOSCOPE];
   MultihopOscilloscopeC.RootControl -> Collector;
-
+  MultihopOscilloscopeC.Random -> RandomC;
+  
   components new PoolC(message_t, 10) as UARTMessagePoolP,
     new QueueC(message_t*, 10) as UARTQueueP;
 
   MultihopOscilloscopeC.UARTMessagePool -> UARTMessagePoolP;
   MultihopOscilloscopeC.UARTQueue -> UARTQueueP;
-
-  //
-  // Components for debugging collection.
-  //
-   components new PoolC(message_t, 20) as DebugMessagePool,
+  
+  components new PoolC(message_t, 20) as DebugMessagePool,
     new QueueC(message_t*, 20) as DebugSendQueue,
     new SerialAMSenderC(AM_LQI_DEBUG) as DebugSerialSender,
     UARTDebugSenderP as DebugSender;
@@ -67,4 +66,8 @@ implementation {
   DebugSender.MessagePool -> DebugMessagePool;
   DebugSender.SendQueue -> DebugSendQueue;
   Collector.CollectionDebug -> DebugSender;
+
+  components CC2420ActiveMessageC;
+  CC2420ActiveMessageC.SubPacket -> ActiveMessageC;
+
 }
index aed5a437752e7f584b622876e5987174bd93eb2d..a13236e343cffcec095a4dd714e73f14e2352d86 100644 (file)
@@ -40,8 +40,10 @@ module MultihopOscilloscopeC {
 
     // Miscalleny:
     interface Timer<TMilli>;
+    interface Timer<TMilli> as OnOffTimer;
     interface Read<uint16_t>;
     interface Leds;
+    interface Random;
   }
 }
 
@@ -69,7 +71,7 @@ implementation {
      is a very simple form of "time" synchronization (for an abstract
      notion of time). */
   bool suppress_count_change;
-
+  bool running = FALSE;
   // 
   // On bootup, initialize radio and serial communications, and our
   // own state variables.
@@ -78,16 +80,19 @@ implementation {
     local.interval = DEFAULT_INTERVAL;
     local.id = TOS_NODE_ID;
     local.version = 0;
-    dbg("App", "Booted.");
+
     // Beginning our initialization phases:
     if (call RadioControl.start() != SUCCESS)
       fatal_problem();
 
     if (call RoutingControl.start() != SUCCESS)
       fatal_problem();
+
+    startTimer();
   }
 
   event void RadioControl.startDone(error_t error) {
+    //dbg("App", "Radio control start done.\n");
     if (error != SUCCESS)
       fatal_problem();
 
@@ -96,6 +101,9 @@ implementation {
 
     if (call SerialControl.start() != SUCCESS)
       fatal_problem();
+
+    running = TRUE;
+    call OnOffTimer.startOneShot(19 + (call Random.rand32() % 173));
   }
 
   event void SerialControl.startDone(error_t error) {
@@ -105,17 +113,33 @@ implementation {
     // This is how to set yourself as a root to the collection layer:
     if (local.id % 500 == 0)
       call RootControl.setRoot();
+    
 
-    startTimer();
   }
 
+
+  event void OnOffTimer.fired() {
+    if (running) {
+      call RadioControl.stop();
+    }
+    else {
+      call RadioControl.start();
+    }
+    
+  }
+  
   static void startTimer() {
+    dbg("App", "Starting timer.\n");
     if (call Timer.isRunning()) call Timer.stop();
     call Timer.startPeriodic(local.interval);
     reading = 0;
   }
 
-  event void RadioControl.stopDone(error_t error) { }
+  event void RadioControl.stopDone(error_t error) {
+    //dbg("App", "Radio control stop done.\n");
+    running = FALSE;
+    call OnOffTimer.startOneShot(3);
+  }
   event void SerialControl.stopDone(error_t error) { }
 
   //
@@ -127,17 +151,10 @@ implementation {
   Receive.receive(message_t* msg, void *payload, uint8_t len) {
     oscilloscope_t* in = (oscilloscope_t*)payload;
     oscilloscope_t* out;
-    dbg("App", "Received a packet.\n\t");
-    {
-      int i;
-      for (i = 0; i < len; i++) {
-        dbg_clear("App", "[%hhx] ", ((uint8_t*)payload)[i]);
-      }
-      dbg_clear("App", "\n");
-    }
     if (uartbusy == FALSE) {
       out = (oscilloscope_t*)call SerialSend.getPayload(&uartbuf, sizeof(oscilloscope_t));
-      if (out == NULL || call Packet.payloadLength(&uartbuf) != sizeof(oscilloscope_t)) {
+      if (out == NULL) {
+       fatal_problem();
        return msg;
       }
       else {
@@ -158,7 +175,8 @@ implementation {
       //Prepare message to be sent over the uart
       out = (oscilloscope_t*)call SerialSend.getPayload(newmsg, sizeof(oscilloscope_t));
       if (out == NULL) {
-       return;
+       fatal_problem();
+       return msg;
       }
       memcpy(out, in, sizeof(oscilloscope_t));
 
@@ -237,15 +255,18 @@ implementation {
       if (!sendbusy) {
        oscilloscope_t *o = (oscilloscope_t *)call Send.getPayload(&sendbuf, sizeof(oscilloscope_t));
        if (o == NULL) {
+         fatal_problem();
          return;
        }
        memcpy(o, &local, sizeof(local));
        if (call Send.send(&sendbuf, sizeof(local)) == SUCCESS) {
-          dbg("App", "Sending a packet.\n");
          sendbusy = TRUE;
-        }
-        else
+         dbg("App", "Sending data packet.\n");
+       }
+        else {
+         dbg("App", "Data packet send failed.\n");
           report_problem();
+       }
       }
       
       reading = 0;
@@ -261,6 +282,7 @@ implementation {
   }
 
   event void Send.sendDone(message_t* msg, error_t error) {
+    dbg("App", "App-level send done.\n");
     if (error == SUCCESS)
       report_sent();
     else
index 15d2e3425ac2b489efcedeb951794994119fc447..aa72201ca4768db5921c1bd47d557bdf8ef7b7bb 100644 (file)
@@ -11,11 +11,11 @@ r = t.radio()
 #t.addChannel("RadioCountToLedsC", sys.stdout)
 #t.addChannel("CpmModelC", sys.stdout)
 #t.addChannel("Gain", sys.stdout)
-t.addChannel("AM", sys.stdout)
+#t.addChannel("AM", sys.stdout)
 t.addChannel("App", sys.stdout)
-#t.addChannel("LQI", sys.stdout)
+t.addChannel("LQI", sys.stdout)
 #t.addChannel("LQIRoute", sys.stdout)
-#t.addChannel("LQIDeliver", sys.stdout)
+t.addChannel("LQIDeliver", sys.stdout)
 #t.addChannel("LQIRoute", sys.stdout)
 #t.addChannel("PointerBug", sys.stdout)
 
@@ -54,5 +54,5 @@ print "time: ", duration;
 #for i in range(0, 196607):
 #    print m1.generateNoise(i)
 
-for i in range(0, 2000):
+while ((t.time() / t.ticksPerSecond()) < 3000):
     t.runNextEvent();