]> oss.titaniummirror.com Git - tinyos-2.x.git/commitdiff
Supporting test suite for the newest CC2420 stack. Includes a low power version...
authorrincon <rincon>
Thu, 12 Apr 2007 17:14:08 +0000 (17:14 +0000)
committerrincon <rincon>
Thu, 12 Apr 2007 17:14:08 +0000 (17:14 +0000)
37 files changed:
apps/tests/cc2420/LplBroadcastCountToLeds/Makefile [new file with mode: 0644]
apps/tests/cc2420/LplBroadcastCountToLeds/README.txt [new file with mode: 0644]
apps/tests/cc2420/LplBroadcastCountToLeds/RadioCountMsg.java [new file with mode: 0644]
apps/tests/cc2420/LplBroadcastCountToLeds/RadioCountToLeds.h [new file with mode: 0644]
apps/tests/cc2420/LplBroadcastCountToLeds/RadioCountToLedsAppC.nc [new file with mode: 0644]
apps/tests/cc2420/LplBroadcastCountToLeds/RadioCountToLedsC.nc [new file with mode: 0644]
apps/tests/cc2420/LplBroadcastPeriodicDelivery/Makefile [new file with mode: 0644]
apps/tests/cc2420/LplBroadcastPeriodicDelivery/README.txt [new file with mode: 0644]
apps/tests/cc2420/LplBroadcastPeriodicDelivery/TestPeriodic.h [new file with mode: 0644]
apps/tests/cc2420/LplBroadcastPeriodicDelivery/TestPeriodicC.nc [new file with mode: 0644]
apps/tests/cc2420/LplBroadcastPeriodicDelivery/TestPeriodicP.nc [new file with mode: 0644]
apps/tests/cc2420/LplUnicastPeriodicDelivery/Makefile [new file with mode: 0644]
apps/tests/cc2420/LplUnicastPeriodicDelivery/README.txt [new file with mode: 0644]
apps/tests/cc2420/LplUnicastPeriodicDelivery/TestPeriodic.h [new file with mode: 0644]
apps/tests/cc2420/LplUnicastPeriodicDelivery/TestPeriodicC.nc [new file with mode: 0644]
apps/tests/cc2420/LplUnicastPeriodicDelivery/TestPeriodicP.nc [new file with mode: 0644]
apps/tests/cc2420/RssiToSerial/Makefile [new file with mode: 0644]
apps/tests/cc2420/RssiToSerial/RssiToSerial.h [new file with mode: 0644]
apps/tests/cc2420/RssiToSerial/RssiToSerialC.nc [new file with mode: 0644]
apps/tests/cc2420/RssiToSerial/RssiToSerialP.nc [new file with mode: 0644]
apps/tests/cc2420/RssiToSerial/SpecAnalyzer.java [new file with mode: 0644]
apps/tests/cc2420/TestAcks/Makefile [new file with mode: 0644]
apps/tests/cc2420/TestAcks/README.txt [new file with mode: 0644]
apps/tests/cc2420/TestAcks/TestAcksC.nc [new file with mode: 0644]
apps/tests/cc2420/TestAcks/TestAcksP.nc [new file with mode: 0644]
apps/tests/cc2420/TestPacketLink/Makefile [new file with mode: 0644]
apps/tests/cc2420/TestPacketLink/README.txt [new file with mode: 0644]
apps/tests/cc2420/TestPacketLink/TestPacketLink.h [new file with mode: 0644]
apps/tests/cc2420/TestPacketLink/TestPacketLink.java [new file with mode: 0644]
apps/tests/cc2420/TestPacketLink/TestPacketLinkC.nc [new file with mode: 0644]
apps/tests/cc2420/TestPacketLink/TestPacketLinkP.nc [new file with mode: 0644]
apps/tests/cc2420/TxThroughput/Makefile [new file with mode: 0644]
apps/tests/cc2420/TxThroughput/README.txt [new file with mode: 0644]
apps/tests/cc2420/TxThroughput/TxThroughput.h [new file with mode: 0644]
apps/tests/cc2420/TxThroughput/TxThroughput.java [new file with mode: 0644]
apps/tests/cc2420/TxThroughput/TxThroughputC.nc [new file with mode: 0644]
apps/tests/cc2420/TxThroughput/TxThroughputP.nc [new file with mode: 0644]

diff --git a/apps/tests/cc2420/LplBroadcastCountToLeds/Makefile b/apps/tests/cc2420/LplBroadcastCountToLeds/Makefile
new file mode 100644 (file)
index 0000000..6e62a37
--- /dev/null
@@ -0,0 +1,19 @@
+COMPONENT=RadioCountToLedsAppC
+
+CFLAGS += -DACK_LOW_POWER_LISTENING
+#CFLAGS += -DNOACK_LOW_POWER_LISTENING
+
+BUILD_EXTRA_DEPS = RadioCountMsg.py RadioCountMsg.class
+
+RadioCountMsg.py: RadioCountToLeds.h
+       mig python -target=$(PLATFORM) $(CFLAGS) -python-classname=RadioCountMsg RadioCountToLeds.h radio_count_msg -o $@
+
+RadioCountMsg.class: RadioCountMsg.java
+       javac RadioCountMsg.java
+
+RadioCountMsg.java: RadioCountToLeds.h
+       mig java -target=$(PLATFORM) $(CFLAGS) -java-classname=RadioCountMsg RadioCountToLeds.h radio_count_msg -o $@
+
+
+include $(MAKERULES)
+
diff --git a/apps/tests/cc2420/LplBroadcastCountToLeds/README.txt b/apps/tests/cc2420/LplBroadcastCountToLeds/README.txt
new file mode 100644 (file)
index 0000000..5aad6f0
--- /dev/null
@@ -0,0 +1,31 @@
+README for RadioCountToLeds
+Author/Contact: tinyos-help@millennium.berkeley.edu
+
+Description:
+
+This is a low power listening version of RadioCountToLeds,
+using the broadcast address to delivery packets.  That means even in
+an ack'ing LPL scheme, the delivery will remain on for the full 
+duration of the receiver's LPL check to ensure all listeners get the message.
+
+Try it with ACK_LOW_POWER_LISTENING and NOACK_LOW_POWER_LISTENING by editing
+the Makefile
+
+RadioCountToLeds maintains a 4Hz counter, broadcasting its value in 
+an AM packet every time it gets updated. A RadioCountToLeds node that 
+hears a counter displays the bottom three bits on its LEDs. This 
+application is a useful test to show that basic AM communication and 
+timers work.
+
+Tools:
+
+RadioCountMsg.java is a Java class representing the message that
+this application sends.  RadioCountMsg.py is a Python class representing
+the message that this application sends.
+
+Known bugs/limitations:
+
+None.
+
+
+$Id$
diff --git a/apps/tests/cc2420/LplBroadcastCountToLeds/RadioCountMsg.java b/apps/tests/cc2420/LplBroadcastCountToLeds/RadioCountMsg.java
new file mode 100644 (file)
index 0000000..47c935d
--- /dev/null
@@ -0,0 +1,158 @@
+/**
+ * This class is automatically generated by mig. DO NOT EDIT THIS FILE.
+ * This class implements a Java interface to the 'RadioCountMsg'
+ * message type.
+ */
+
+public class RadioCountMsg extends net.tinyos.message.Message {
+
+    /** The default size of this message type in bytes. */
+    public static final int DEFAULT_MESSAGE_SIZE = 2;
+
+    /** The Active Message type associated with this message. */
+    public static final int AM_TYPE = 6;
+
+    /** Create a new RadioCountMsg of size 2. */
+    public RadioCountMsg() {
+        super(DEFAULT_MESSAGE_SIZE);
+        amTypeSet(AM_TYPE);
+    }
+
+    /** Create a new RadioCountMsg of the given data_length. */
+    public RadioCountMsg(int data_length) {
+        super(data_length);
+        amTypeSet(AM_TYPE);
+    }
+
+    /**
+     * Create a new RadioCountMsg with the given data_length
+     * and base offset.
+     */
+    public RadioCountMsg(int data_length, int base_offset) {
+        super(data_length, base_offset);
+        amTypeSet(AM_TYPE);
+    }
+
+    /**
+     * Create a new RadioCountMsg using the given byte array
+     * as backing store.
+     */
+    public RadioCountMsg(byte[] data) {
+        super(data);
+        amTypeSet(AM_TYPE);
+    }
+
+    /**
+     * Create a new RadioCountMsg using the given byte array
+     * as backing store, with the given base offset.
+     */
+    public RadioCountMsg(byte[] data, int base_offset) {
+        super(data, base_offset);
+        amTypeSet(AM_TYPE);
+    }
+
+    /**
+     * Create a new RadioCountMsg using the given byte array
+     * as backing store, with the given base offset and data length.
+     */
+    public RadioCountMsg(byte[] data, int base_offset, int data_length) {
+        super(data, base_offset, data_length);
+        amTypeSet(AM_TYPE);
+    }
+
+    /**
+     * Create a new RadioCountMsg embedded in the given message
+     * at the given base offset.
+     */
+    public RadioCountMsg(net.tinyos.message.Message msg, int base_offset) {
+        super(msg, base_offset, DEFAULT_MESSAGE_SIZE);
+        amTypeSet(AM_TYPE);
+    }
+
+    /**
+     * Create a new RadioCountMsg embedded in the given message
+     * at the given base offset and length.
+     */
+    public RadioCountMsg(net.tinyos.message.Message msg, int base_offset, int data_length) {
+        super(msg, base_offset, data_length);
+        amTypeSet(AM_TYPE);
+    }
+
+    /**
+    /* Return a String representation of this message. Includes the
+     * message type name and the non-indexed field values.
+     */
+    public String toString() {
+      String s = "Message <RadioCountMsg> \n";
+      try {
+        s += "  [counter=0x"+Long.toHexString(get_counter())+"]\n";
+      } catch (ArrayIndexOutOfBoundsException aioobe) { /* Skip field */ }
+      return s;
+    }
+
+    // Message-type-specific access methods appear below.
+
+    /////////////////////////////////////////////////////////
+    // Accessor methods for field: counter
+    //   Field type: int, unsigned
+    //   Offset (bits): 0
+    //   Size (bits): 16
+    /////////////////////////////////////////////////////////
+
+    /**
+     * Return whether the field 'counter' is signed (false).
+     */
+    public static boolean isSigned_counter() {
+        return false;
+    }
+
+    /**
+     * Return whether the field 'counter' is an array (false).
+     */
+    public static boolean isArray_counter() {
+        return false;
+    }
+
+    /**
+     * Return the offset (in bytes) of the field 'counter'
+     */
+    public static int offset_counter() {
+        return (0 / 8);
+    }
+
+    /**
+     * Return the offset (in bits) of the field 'counter'
+     */
+    public static int offsetBits_counter() {
+        return 0;
+    }
+
+    /**
+     * Return the value (as a int) of the field 'counter'
+     */
+    public int get_counter() {
+        return (int)getUIntBEElement(offsetBits_counter(), 16);
+    }
+
+    /**
+     * Set the value of the field 'counter'
+     */
+    public void set_counter(int value) {
+        setUIntBEElement(offsetBits_counter(), 16, value);
+    }
+
+    /**
+     * Return the size, in bytes, of the field 'counter'
+     */
+    public static int size_counter() {
+        return (16 / 8);
+    }
+
+    /**
+     * Return the size, in bits, of the field 'counter'
+     */
+    public static int sizeBits_counter() {
+        return 16;
+    }
+
+}
diff --git a/apps/tests/cc2420/LplBroadcastCountToLeds/RadioCountToLeds.h b/apps/tests/cc2420/LplBroadcastCountToLeds/RadioCountToLeds.h
new file mode 100644 (file)
index 0000000..deed967
--- /dev/null
@@ -0,0 +1,12 @@
+#ifndef RADIO_COUNT_TO_LEDS_H
+#define RADIO_COUNT_TO_LEDS_H
+
+typedef nx_struct radio_count_msg {
+  nx_uint16_t counter;
+} radio_count_msg_t;
+
+enum {
+  AM_RADIO_COUNT_MSG = 6,
+};
+
+#endif
diff --git a/apps/tests/cc2420/LplBroadcastCountToLeds/RadioCountToLedsAppC.nc b/apps/tests/cc2420/LplBroadcastCountToLeds/RadioCountToLedsAppC.nc
new file mode 100644 (file)
index 0000000..0414f07
--- /dev/null
@@ -0,0 +1,74 @@
+// $Id$
+
+/*                                                                     tab:4
+ * "Copyright (c) 2000-2005 The Regents of the University  of California.  
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose, without fee, and without written agreement is
+ * hereby granted, provided that the above copyright notice, the following
+ * two paragraphs and the author appear in all copies of this software.
+ * 
+ * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
+ * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
+ * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
+ * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * 
+ * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
+ * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
+ * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
+ *
+ * Copyright (c) 2002-2003 Intel Corporation
+ * All rights reserved.
+ *
+ * This file is distributed under the terms in the attached INTEL-LICENSE     
+ * file. If you do not find these files, copies can be found by writing to
+ * Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA, 
+ * 94704.  Attention:  Intel License Inquiry.
+ */
+#include "RadioCountToLeds.h"
+
+/**
+ * Configuration for the RadioCountToLeds application. RadioCountToLeds 
+ * maintains a 4Hz counter, broadcasting its value in an AM packet 
+ * every time it gets updated. A RadioCountToLeds node that hears a counter 
+ * displays the bottom three bits on its LEDs. This application is a useful 
+ * test to show that basic AM communication and timers work.
+ *
+ * @author Philip Levis
+ * @date   June 6 2005
+ */
+
+configuration RadioCountToLedsAppC {}
+implementation {
+
+#if defined(PLATFORM_MICA2) || defined(PLATFORM_MICA2DOT)
+  components CC1000ActiveMessageC as LplC;
+#elif defined(PLATFORM_MICAZ) || defined(PLATFORM_TELOSB)
+  components CC2420ActiveMessageC as LplC;
+#else
+#error "LPL testing not supported on this platform"
+#endif
+
+
+  components MainC, RadioCountToLedsC as App, LedsC;
+  components new AMSenderC(AM_RADIO_COUNT_MSG);
+  components new AMReceiverC(AM_RADIO_COUNT_MSG);
+  components new TimerMilliC();
+  components ActiveMessageC;
+  
+  App.Boot -> MainC.Boot;
+  
+  App.LowPowerListening -> LplC;
+  App.Receive -> AMReceiverC;
+  App.AMSend -> AMSenderC;
+  App.AMControl -> ActiveMessageC;
+  App.Leds -> LedsC;
+  App.MilliTimer -> TimerMilliC;
+  App.Packet -> AMSenderC;
+}
+
+
diff --git a/apps/tests/cc2420/LplBroadcastCountToLeds/RadioCountToLedsC.nc b/apps/tests/cc2420/LplBroadcastCountToLeds/RadioCountToLedsC.nc
new file mode 100644 (file)
index 0000000..0032148
--- /dev/null
@@ -0,0 +1,127 @@
+// $Id$
+
+/*                                                                        tab:4
+ * "Copyright (c) 2000-2005 The Regents of the University  of California.  
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose, without fee, and without written agreement is
+ * hereby granted, provided that the above copyright notice, the following
+ * two paragraphs and the author appear in all copies of this software.
+ * 
+ * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
+ * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
+ * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
+ * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * 
+ * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
+ * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
+ * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
+ *
+ * Copyright (c) 2002-2003 Intel Corporation
+ * All rights reserved.
+ *
+ * This file is distributed under the terms in the attached INTEL-LICENSE     
+ * file. If you do not find these files, copies can be found by writing to
+ * Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA, 
+ * 94704.  Attention:  Intel License Inquiry.
+ */
+#include "Timer.h"
+#include "RadioCountToLeds.h"
+/**
+ * Implementation of the RadioCountToLeds application. RadioCountToLeds 
+ * maintains a 4Hz counter, broadcasting its value in an AM packet 
+ * every time it gets updated. A RadioCountToLeds node that hears a counter 
+ * displays the bottom three bits on its LEDs. This application is a useful 
+ * test to show that basic AM communication and timers work.
+ *
+ * @author Philip Levis
+ * @date   June 6 2005
+ */
+
+module RadioCountToLedsC {
+  uses {
+    interface Leds;
+    interface Boot;
+    interface Receive;
+    interface AMSend;
+    interface Timer<TMilli> as MilliTimer;
+    interface SplitControl as AMControl;
+    interface Packet;
+    interface LowPowerListening;
+  }
+}
+implementation {
+
+  message_t packet;
+
+  bool locked;
+  uint16_t counter = 0;
+  
+  event void Boot.booted() {
+    call AMControl.start();
+  }
+
+  event void AMControl.startDone(error_t err) {
+    if (err == SUCCESS) {
+      // Note we can setup LPL before or after the radio turns on
+      call LowPowerListening.setLocalSleepInterval(1000);
+      call MilliTimer.startOneShot(1500);
+    }
+    else {
+      call AMControl.start();
+    }
+  }
+
+  event void AMControl.stopDone(error_t err) {
+    // do nothing
+  }
+  
+  event void MilliTimer.fired() {
+    counter++;
+    dbg("RadioCountToLedsC", "RadioCountToLedsC: timer fired, counter is %hu.\n", counter);
+    if (locked) {
+      return;
+    }
+    else {
+      radio_count_msg_t* rcm = (radio_count_msg_t*)call Packet.getPayload(&packet, NULL);
+      if (call Packet.maxPayloadLength() < sizeof(radio_count_msg_t)) {
+        return;
+      }
+
+      rcm->counter = counter;
+      call LowPowerListening.setRxSleepInterval(&packet, 1000);
+      if (call AMSend.send(AM_BROADCAST_ADDR, &packet, sizeof(radio_count_msg_t)) == SUCCESS) {
+        dbg("RadioCountToLedsC", "RadioCountToLedsC: packet sent.\n", counter);        
+        locked = TRUE;
+      }
+    }
+  }
+
+  event message_t* Receive.receive(message_t* bufPtr, 
+                                   void* payload, uint8_t len) {
+    dbg("RadioCountToLedsC", "Received packet of length %hhu.\n", len);
+    if (len != sizeof(radio_count_msg_t)) {
+      return bufPtr;
+    } else {
+      call Leds.set(((radio_count_msg_t*) payload)->counter);
+      return bufPtr;
+    }
+  }
+
+  event void AMSend.sendDone(message_t* bufPtr, error_t error) {
+    call MilliTimer.startOneShot(1500);
+    if (&packet == bufPtr) {
+      locked = FALSE;
+    }
+  }
+
+}
+
+
+
+
diff --git a/apps/tests/cc2420/LplBroadcastPeriodicDelivery/Makefile b/apps/tests/cc2420/LplBroadcastPeriodicDelivery/Makefile
new file mode 100644 (file)
index 0000000..f2b9556
--- /dev/null
@@ -0,0 +1,8 @@
+COMPONENT=TestPeriodicC
+CFLAGS += -DACK_LOW_POWER_LISTENING
+#CFLAGS += -DNOACK_LOW_POWER_LISTENING
+
+include $(MAKERULES)
+
+
diff --git a/apps/tests/cc2420/LplBroadcastPeriodicDelivery/README.txt b/apps/tests/cc2420/LplBroadcastPeriodicDelivery/README.txt
new file mode 100644 (file)
index 0000000..e59d430
--- /dev/null
@@ -0,0 +1,22 @@
+Tx != 0
+Rx == 0
+
+This app sends a message from Tx to AM_BROADCAST_ADDR and waits 1000 ms between each delivery
+so the Rx mote's radio shuts back off and has to redetect to receive the next
+message.
+
+
+
+EXPECTATIONS
+Transmitter - always ID 1
+  * Transmitting for 1000 ms, and then pause for 1000 ms.  
+  * Broadcast address will not cut transmission short under any circumstances
+  * Led0 indicates transmission
+  * Transmitter receive check interval once every 1000 ms
+  
+Receiver - any other ID than 1
+  * Receive check interval once every 1000 ms
+  * Led1 indicates final reception
+
+Led2 is left up to DutyCycleP to toggle when the radio is on.
+
diff --git a/apps/tests/cc2420/LplBroadcastPeriodicDelivery/TestPeriodic.h b/apps/tests/cc2420/LplBroadcastPeriodicDelivery/TestPeriodic.h
new file mode 100644 (file)
index 0000000..7183641
--- /dev/null
@@ -0,0 +1,14 @@
+
+#ifndef TESTPERIODIC_H
+#define TESTPERIODIC_H
+
+typedef nx_struct TestPeriodicMsg {
+  nx_uint8_t count;
+} TestPeriodicMsg;
+
+enum {
+  AM_TESTPERIODICMSG = 0x5,
+};
+
+#endif
+
diff --git a/apps/tests/cc2420/LplBroadcastPeriodicDelivery/TestPeriodicC.nc b/apps/tests/cc2420/LplBroadcastPeriodicDelivery/TestPeriodicC.nc
new file mode 100644 (file)
index 0000000..45808e0
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2005-2006 Rincon Research Corporation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the
+ *   distribution.
+ * - Neither the name of the Rincon Research Corporation nor the names of
+ *   its contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
+ * ARCHED ROCK OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE
+ */
+
+/**
+ * @author David Moss
+ */
+#include "TestPeriodic.h"
+
+configuration TestPeriodicC {
+}
+
+implementation {
+
+#if defined(PLATFORM_MICA2) || defined(PLATFORM_MICA2DOT)
+  components CC1000ActiveMessageC as Lpl;
+#elif defined(PLATFORM_MICAZ) || defined(PLATFORM_TELOSB)
+  components CC2420ActiveMessageC as Lpl;
+#else
+#error "LPL testing not supported on this platform"
+#endif
+
+  components TestPeriodicP,
+      MainC,
+      ActiveMessageC,
+      new TimerMilliC(),
+      new AMSenderC(AM_TESTPERIODICMSG),
+      new AMReceiverC(AM_TESTPERIODICMSG),
+      LedsC;
+      
+  TestPeriodicP.Boot -> MainC;
+  TestPeriodicP.SplitControl -> ActiveMessageC;
+  TestPeriodicP.LowPowerListening -> Lpl;
+  TestPeriodicP.AMPacket -> ActiveMessageC;
+  TestPeriodicP.AMSend -> AMSenderC;
+  TestPeriodicP.Receive -> AMReceiverC;
+  TestPeriodicP.Packet -> ActiveMessageC;
+  TestPeriodicP.Timer -> TimerMilliC;
+  TestPeriodicP.Leds -> LedsC;
+
+}
+
diff --git a/apps/tests/cc2420/LplBroadcastPeriodicDelivery/TestPeriodicP.nc b/apps/tests/cc2420/LplBroadcastPeriodicDelivery/TestPeriodicP.nc
new file mode 100644 (file)
index 0000000..d572ac0
--- /dev/null
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2005-2006 Rincon Research Corporation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the
+ *   distribution.
+ * - Neither the name of the Rincon Research Corporation nor the names of
+ *   its contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
+ * ARCHED ROCK OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE
+ */
+
+/**
+ * @author David Moss
+ * Rx != 1
+ * Tx == 1
+ */
+
+#include "TestPeriodic.h"
+
+module TestPeriodicP {
+  uses {
+    interface Boot;
+    interface SplitControl;
+    interface LowPowerListening;
+    interface AMSend;
+    interface Receive;
+    interface AMPacket;
+    interface Packet;
+    interface Leds;
+    interface Timer<TMilli>;
+  }
+}
+
+implementation {
+  uint8_t count;
+  message_t fullMsg;
+  bool transmitter;
+  
+  /**************** Prototypes ****************/
+  task void send();
+  
+  /**************** Boot Events ****************/
+  event void Boot.booted() {
+    transmitter = (call AMPacket.address() == 1);
+    count = 0;
+    
+    call LowPowerListening.setLocalSleepInterval(1000);
+    call SplitControl.start();
+  }
+  
+  event void SplitControl.startDone(error_t error) {
+    if(transmitter) {
+      post send();
+    }
+  }
+  
+  event void SplitControl.stopDone(error_t error) {
+  }
+  
+  
+  /**************** Send Receive Events *****************/
+  event void AMSend.sendDone(message_t *msg, error_t error) {
+    if(transmitter) {
+      count++; 
+      call Timer.startOneShot(1000);
+      call Leds.led0Off();
+    }
+  }
+  
+  event message_t *Receive.receive(message_t *msg, void *payload, uint8_t len) {
+    if(!transmitter) {
+      call Leds.led1Toggle();
+    }
+    return msg;
+  }
+  
+  /**************** Timer Events ****************/
+  event void Timer.fired() {
+    if(transmitter) {
+      post send();
+    }
+  }
+  
+  /**************** Tasks ****************/
+  task void send() {
+    TestPeriodicMsg *periodicMsg = (TestPeriodicMsg *) call Packet.getPayload(&fullMsg, NULL);
+    periodicMsg->count = count;
+    call LowPowerListening.setRxSleepInterval(&fullMsg, 1000);
+    if(call AMSend.send(AM_BROADCAST_ADDR, &fullMsg, sizeof(TestPeriodicMsg)) != SUCCESS) {
+      post send();
+    } else {
+      call Leds.led0On();
+    }
+  }
+}
+
diff --git a/apps/tests/cc2420/LplUnicastPeriodicDelivery/Makefile b/apps/tests/cc2420/LplUnicastPeriodicDelivery/Makefile
new file mode 100644 (file)
index 0000000..f2b9556
--- /dev/null
@@ -0,0 +1,8 @@
+COMPONENT=TestPeriodicC
+CFLAGS += -DACK_LOW_POWER_LISTENING
+#CFLAGS += -DNOACK_LOW_POWER_LISTENING
+
+include $(MAKERULES)
+
+
diff --git a/apps/tests/cc2420/LplUnicastPeriodicDelivery/README.txt b/apps/tests/cc2420/LplUnicastPeriodicDelivery/README.txt
new file mode 100644 (file)
index 0000000..4508306
--- /dev/null
@@ -0,0 +1,22 @@
+Tx != 0
+Rx == 0
+
+This app sends a message from Tx to 0 and waits 1000 ms between each delivery
+so the Rx mote's radio shuts back off and has to redetect to receive the next
+message.
+
+
+
+EXPECTATIONS
+Transmitter #1
+  * Transmitting for 1000 ms, and then pause for 1000 ms.  
+  * Will cut transmission short if using Ack LPL and the receiver gets the msg
+  * Led0 indicates transmission
+  * Transmitter receive check interval once every 1000 ms
+  
+Receiver #0
+  * Receive check interval once every 1000 ms
+  * Led1 indicates final reception
+
+Led2 is left up to DutyCycleP to toggle when the radio is on.
+
diff --git a/apps/tests/cc2420/LplUnicastPeriodicDelivery/TestPeriodic.h b/apps/tests/cc2420/LplUnicastPeriodicDelivery/TestPeriodic.h
new file mode 100644 (file)
index 0000000..7183641
--- /dev/null
@@ -0,0 +1,14 @@
+
+#ifndef TESTPERIODIC_H
+#define TESTPERIODIC_H
+
+typedef nx_struct TestPeriodicMsg {
+  nx_uint8_t count;
+} TestPeriodicMsg;
+
+enum {
+  AM_TESTPERIODICMSG = 0x5,
+};
+
+#endif
+
diff --git a/apps/tests/cc2420/LplUnicastPeriodicDelivery/TestPeriodicC.nc b/apps/tests/cc2420/LplUnicastPeriodicDelivery/TestPeriodicC.nc
new file mode 100644 (file)
index 0000000..45808e0
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2005-2006 Rincon Research Corporation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the
+ *   distribution.
+ * - Neither the name of the Rincon Research Corporation nor the names of
+ *   its contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
+ * ARCHED ROCK OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE
+ */
+
+/**
+ * @author David Moss
+ */
+#include "TestPeriodic.h"
+
+configuration TestPeriodicC {
+}
+
+implementation {
+
+#if defined(PLATFORM_MICA2) || defined(PLATFORM_MICA2DOT)
+  components CC1000ActiveMessageC as Lpl;
+#elif defined(PLATFORM_MICAZ) || defined(PLATFORM_TELOSB)
+  components CC2420ActiveMessageC as Lpl;
+#else
+#error "LPL testing not supported on this platform"
+#endif
+
+  components TestPeriodicP,
+      MainC,
+      ActiveMessageC,
+      new TimerMilliC(),
+      new AMSenderC(AM_TESTPERIODICMSG),
+      new AMReceiverC(AM_TESTPERIODICMSG),
+      LedsC;
+      
+  TestPeriodicP.Boot -> MainC;
+  TestPeriodicP.SplitControl -> ActiveMessageC;
+  TestPeriodicP.LowPowerListening -> Lpl;
+  TestPeriodicP.AMPacket -> ActiveMessageC;
+  TestPeriodicP.AMSend -> AMSenderC;
+  TestPeriodicP.Receive -> AMReceiverC;
+  TestPeriodicP.Packet -> ActiveMessageC;
+  TestPeriodicP.Timer -> TimerMilliC;
+  TestPeriodicP.Leds -> LedsC;
+
+}
+
diff --git a/apps/tests/cc2420/LplUnicastPeriodicDelivery/TestPeriodicP.nc b/apps/tests/cc2420/LplUnicastPeriodicDelivery/TestPeriodicP.nc
new file mode 100644 (file)
index 0000000..ddb17ab
--- /dev/null
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2005-2006 Rincon Research Corporation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the
+ *   distribution.
+ * - Neither the name of the Rincon Research Corporation nor the names of
+ *   its contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
+ * ARCHED ROCK OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE
+ */
+
+/**
+ * @author David Moss
+ * Rx == 0
+ * Tx != 0
+ */
+
+#include "TestPeriodic.h"
+
+module TestPeriodicP {
+  uses {
+    interface Boot;
+    interface SplitControl;
+    interface LowPowerListening;
+    interface AMSend;
+    interface Receive;
+    interface AMPacket;
+    interface Packet;
+    interface Leds;
+    interface Timer<TMilli>;
+  }
+}
+
+implementation {
+  uint8_t count;
+  message_t fullMsg;
+  bool transmitter;
+  
+  /**************** Prototypes ****************/
+  task void send();
+  
+  /**************** Boot Events ****************/
+  event void Boot.booted() {
+    transmitter = (call AMPacket.address() != 0);
+    count = 0;
+    
+    call LowPowerListening.setLocalSleepInterval(1000);
+    call SplitControl.start();
+  }
+  
+  event void SplitControl.startDone(error_t error) {
+    if(transmitter) {
+      post send();
+    }
+  }
+  
+  event void SplitControl.stopDone(error_t error) {
+  }
+  
+  
+  /**************** Send Receive Events *****************/
+  event void AMSend.sendDone(message_t *msg, error_t error) {
+    if(transmitter) {
+      count++; 
+      call Timer.startOneShot(1000);
+      call Leds.led0Off();
+    }
+  }
+  
+  event message_t *Receive.receive(message_t *msg, void *payload, uint8_t len) {
+    if(!transmitter) {
+      call Leds.led1Toggle();
+    }
+    return msg;
+  }
+  
+  /**************** Timer Events ****************/
+  event void Timer.fired() {
+    if(transmitter) {
+      post send();
+    }
+  }
+  
+  /**************** Tasks ****************/
+  task void send() {
+    TestPeriodicMsg *periodicMsg = (TestPeriodicMsg *) call Packet.getPayload(&fullMsg, NULL);
+    periodicMsg->count = count;
+    call LowPowerListening.setRxSleepInterval(&fullMsg, 1000);
+    if(call AMSend.send(0, &fullMsg, sizeof(TestPeriodicMsg)) != SUCCESS) {
+      post send();
+    } else {
+      call Leds.led0On();
+    }
+  }
+}
+
diff --git a/apps/tests/cc2420/RssiToSerial/Makefile b/apps/tests/cc2420/RssiToSerial/Makefile
new file mode 100644 (file)
index 0000000..887e5f9
--- /dev/null
@@ -0,0 +1,12 @@
+COMPONENT=RssiToSerialC
+
+BUILD_EXTRA_DEPS = RssiSerialMsg.java SpecAnalyzer.class
+
+RssiSerialMsg.java: RssiToSerial.h
+       mig java -target=$(PLATFORM) $(CFLAGS) -java-classname=RssiSerialMsg RssiToSerial.h rssi_serial_msg -o $@
+
+SpecAnalyzer.class: $(wildcard *.java) SpecAnalyzer.java
+       javac *.java
+
+include $(MAKERULES)
+
diff --git a/apps/tests/cc2420/RssiToSerial/RssiToSerial.h b/apps/tests/cc2420/RssiToSerial/RssiToSerial.h
new file mode 100644 (file)
index 0000000..ffe364d
--- /dev/null
@@ -0,0 +1,61 @@
+
+/*
+ * Copyright (c) 2005-2006 Rincon Research Corporation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the
+ *   distribution.
+ * - Neither the name of the Rincon Research Corporation nor the names of
+ *   its contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
+ * RINCON RESEARCH OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE
+ */
+ /**
+  * @author Jared Hill
+  */
+  
+#ifndef RSSI_TO_SERIAL_H
+#define RSSI_TO_SERIAL_H
+
+typedef nx_struct rssi_serial_msg {
+  nx_uint16_t rssiAvgValue;
+  nx_uint16_t rssiLargestValue;
+  nx_uint8_t channel;
+} rssi_serial_msg_t;
+
+enum {
+  AM_RSSI_SERIAL_MSG = 6,
+  WAIT_TIME = 256,
+  //* Using log2 samples to avoid a divide. Sending a packet every 1 second will allow
+  //* allow about 5000 samples. A packet every half second allows for 2500 samples, and
+  //* a packet every quarter second allows for 1250 samples. 
+    
+  // When to send a packet is based upon how many samples have been taken, not a 
+  // predetermined amount of time. Rough estimates of time can be found using the 
+  // conversion stated above. 
+  LOG2SAMPLES = 7,
+};
+
+
+
+#endif
diff --git a/apps/tests/cc2420/RssiToSerial/RssiToSerialC.nc b/apps/tests/cc2420/RssiToSerial/RssiToSerialC.nc
new file mode 100644 (file)
index 0000000..bc16c77
--- /dev/null
@@ -0,0 +1,65 @@
+
+/*
+ * Copyright (c) 2005-2006 Rincon Research Corporation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the
+ *   distribution.
+ * - Neither the name of the Rincon Research Corporation nor the names of
+ *   its contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
+ * RINCON RESEARCH OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE
+ */
+ /**
+  * @author Jared Hill
+  */
+#include "RssiToSerial.h"
+
+/**
+ * 
+ *
+ * @author Jared Hill
+ * @date   23 March 2007
+ */
+
+configuration RssiToSerialC {}
+implementation {
+  components MainC, RssiToSerialP as App, LedsC;
+  components new TimerMilliC();
+  components SerialActiveMessageC as AM;
+  components ActiveMessageC;
+  components CC2420ControlC;
+  
+  App.Boot -> MainC.Boot;
+  App.SerialControl -> AM;
+  App.AMSend -> AM.AMSend[AM_RSSI_SERIAL_MSG];
+  App.AMControl -> ActiveMessageC;
+  App.Leds -> LedsC;
+  App.Packet -> AM;
+  App.ReadRssi -> CC2420ControlC.ReadRssi;
+  App.Config -> CC2420ControlC.CC2420Config;
+}
+
+
diff --git a/apps/tests/cc2420/RssiToSerial/RssiToSerialP.nc b/apps/tests/cc2420/RssiToSerial/RssiToSerialP.nc
new file mode 100644 (file)
index 0000000..0b662ff
--- /dev/null
@@ -0,0 +1,180 @@
+/*
+ * Copyright (c) 2005-2006 Rincon Research Corporation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the
+ *   distribution.
+ * - Neither the name of the Rincon Research Corporation nor the names of
+ *   its contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
+ * RINCON RESEARCH OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE
+ */
+ /**
+  * @author Jared Hill
+  */
+#include "Timer.h"
+#include "RssiToSerial.h"
+/**
+ * 
+ *
+ * @author Jared Hill
+ * @date   23 March 2007
+ */
+
+module RssiToSerialP {
+  uses {
+    interface Leds;
+    interface Boot;
+    interface AMSend;
+    interface SplitControl as AMControl;
+    interface SplitControl as SerialControl;
+    interface Packet;
+    interface Read<uint16_t> as ReadRssi;
+    interface CC2420Config as Config;
+  }
+}
+implementation {
+
+  /******* Global Variables ****************/
+  message_t packet;
+  bool locked;
+  uint32_t total;
+  uint16_t largest;
+  uint16_t reads;
+  
+  /******** Declare Tasks *******************/
+  task void readRssi();
+  task void sendSerialMsg();
+  
+  /************ Boot Events *****************/
+  event void Boot.booted() {
+    call AMControl.start();
+    total = 0;
+    largest = 0;
+    reads = 0;
+    locked = FALSE;
+  }
+
+  /************ AMControl Events ******************/
+  event void AMControl.startDone(error_t err) {
+    if (err == SUCCESS) {
+      call SerialControl.start();
+    }
+    else {
+      call AMControl.start();
+    }
+  }
+
+  event void AMControl.stopDone(error_t err) {
+    // do nothing
+  }
+  
+  /***************SerialControl Events*****************/
+  event void SerialControl.startDone(error_t error){
+    if (error == SUCCESS) {
+      post readRssi();
+    }
+    else {
+      call AMControl.start();
+    }
+  }
+  
+  event void SerialControl.stopDone(error_t error){
+    //do nothing
+  }
+  
+  /***************** AMSend Events ****************************/
+  event void AMSend.sendDone(message_t* bufPtr, error_t error) {
+    
+    if (&packet == bufPtr) {
+      locked = FALSE;
+    }
+    //post readRssi();
+  }
+  
+  /**************** ReadRssi Events *************************/
+  event void ReadRssi.readDone(error_t result, uint16_t val ){
+    
+    if(result != SUCCESS){
+      post readRssi();
+      return;
+    }
+    atomic{
+      total += val;
+      reads ++;
+      if(largest < val){
+        largest = val;
+      }
+    } 
+    if(reads == (1<<LOG2SAMPLES)){
+      post sendSerialMsg();
+    }
+    
+    post readRssi();
+    
+  }
+  
+  /********************* Config Events *************************/
+  event void Config.syncDone(error_t error){
+  
+  }
+
+  /***************** TASKS *****************************/  
+  task void readRssi(){
+   
+    if(call ReadRssi.read() != SUCCESS){
+      post readRssi();
+    }
+  }
+  
+  task void sendSerialMsg(){
+    if(locked){
+      return;
+    }
+    else {
+      rssi_serial_msg_t* rsm = (rssi_serial_msg_t*)call Packet.getPayload(&packet, NULL);
+      
+      if (call Packet.maxPayloadLength() < sizeof(rssi_serial_msg_t)) {
+           return;
+      }
+         atomic{
+           rsm->rssiAvgValue = (total >> (LOG2SAMPLES));
+           rsm->rssiLargestValue = largest;
+           total = 0;
+           largest = 0;
+           reads = 0;
+         }
+         rsm->channel = call Config.getChannel();
+      if (call AMSend.send(AM_BROADCAST_ADDR, &packet, sizeof(rssi_serial_msg_t)) == SUCCESS) {
+           locked = TRUE;
+      }
+    }
+  }
+
+}
+
+
+
+
diff --git a/apps/tests/cc2420/RssiToSerial/SpecAnalyzer.java b/apps/tests/cc2420/RssiToSerial/SpecAnalyzer.java
new file mode 100644 (file)
index 0000000..d03c6b0
--- /dev/null
@@ -0,0 +1,161 @@
+
+/*
+ * Copyright (c) 2005-2006 Rincon Research Corporation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the
+ *   distribution.
+ * - Neither the name of the Rincon Research Corporation nor the names of
+ *   its contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
+ * RINCON RESEARCH OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE
+ */
+
+/**
+ * 
+ * @author Jared Hill
+ */
+
+import net.tinyos.message.Message;
+import net.tinyos.message.MessageListener;
+import net.tinyos.message.MoteIF;
+import net.tinyos.message.SerialPacket;
+import net.tinyos.packet.BuildSource;
+import net.tinyos.packet.PhoenixSource;
+import net.tinyos.util.PrintStreamMessenger;
+
+public class SpecAnalyzer implements MessageListener {
+
+  /** Communication with the mote */
+  private MoteIF mote;
+
+  /** Broadcast Address */
+  public static final short TOS_BCAST_ADDR = (short) 0xffff;
+
+  /** The message from the mote */
+  private RssiSerialMsg rssiMsg;
+
+  /** The total number of characters written last time */
+  private int lastCharsWritten = 0;
+  
+  /** The maximum size of the bar on the command line, in characters */
+  private static final int MAX_CHARACTERS = 50;
+  
+  /**
+   * Constructor
+   * 
+   * @param argv
+   */
+  public SpecAnalyzer(MoteIF mif) {
+
+    try {
+      System.out.println("Connecting to serial forwarder...");
+      mote = mif;
+      mote.registerListener(new RssiSerialMsg(), this);
+    } catch (Exception e) {
+      System.err.println("Couldn't contact serial forwarder");
+    }
+
+  }
+
+  /**
+   * Received a message from the mote
+   */
+  synchronized public void messageReceived(int dest,
+      Message m) {
+    rssiMsg = (RssiSerialMsg) m;
+    updateSpectrum(rssiMsg.get_rssiLargestValue(), rssiMsg.get_rssiAvgValue());
+
+  }
+
+  /**
+   * Overwrites the current command line prompt with blank space
+   * 
+   */
+  void clearSpectrum() {
+    for(int i = 0; i < lastCharsWritten; i++) {
+      System.out.print('\b');
+    }
+  }
+
+  /**
+   * Prints the magnitude of the spectrum to stdout. Specifically, it prints
+   * (largest - average) "+" signs to stdout.
+   * 
+   * @param largest
+   *          the largest rssi value taken during the sample period
+   * @param avg
+   *          the average rssi value taken during the sample period
+   */
+  void updateSpectrum(int largest, int avg) {
+    clearSpectrum();
+    String bar = "[";
+    int size = (int) ((float) largest * (float) ((float) MAX_CHARACTERS / (float) (255)));
+    
+    for(int i = 0; i < size && i < MAX_CHARACTERS; i++) {
+      bar += "+";
+    }
+    
+    for(int i = 0; i < (MAX_CHARACTERS - size); i++) {
+      bar += " ";
+    }
+    
+    bar += "]";
+    
+    lastCharsWritten = bar.length();
+    System.out.print(bar);
+  }
+  
+  private static void usage() {
+    System.err.println("usage: SpecAnalyzer [-comm <source>]");
+  }
+
+  /**
+   * Main Method
+   * 
+   * @param argv
+   */
+  public static void main(String[] args) {
+    String source = null;
+    if (args.length == 2) {
+      if (!args[0].equals("-comm")) {
+        usage();
+        System.exit(1);
+      }
+      source = args[1];
+    } else if (args.length != 0) {
+      usage();
+      System.exit(1);
+    }
+
+    PhoenixSource phoenix;
+
+    if (source == null) {
+      phoenix = BuildSource.makePhoenix(PrintStreamMessenger.err);
+    } else {
+      phoenix = BuildSource.makePhoenix(source, PrintStreamMessenger.err);
+    }
+
+    MoteIF mif = new MoteIF(phoenix);
+    new SpecAnalyzer(mif);
+  }
+}
diff --git a/apps/tests/cc2420/TestAcks/Makefile b/apps/tests/cc2420/TestAcks/Makefile
new file mode 100644 (file)
index 0000000..4a55f07
--- /dev/null
@@ -0,0 +1,6 @@
+COMPONENT=TestAcksC
+
+include $(MAKERULES)
+
+
diff --git a/apps/tests/cc2420/TestAcks/README.txt b/apps/tests/cc2420/TestAcks/README.txt
new file mode 100644 (file)
index 0000000..bc07f80
--- /dev/null
@@ -0,0 +1,12 @@
+
+Installing:
+Compile and install this application to two motes, both using ID 1
+
+Expectations:
+Led0 Toggles on a dropped ack
+Led1 Toggles on a received ack
+Led2 Toggles when a message is received
+
+In short, Led1 should be toggling the majority of the time, until the other receiver
+stops receiving packets by turning off or moving out of range.
+
diff --git a/apps/tests/cc2420/TestAcks/TestAcksC.nc b/apps/tests/cc2420/TestAcks/TestAcksC.nc
new file mode 100644 (file)
index 0000000..2267e43
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2005-2006 Rincon Research Corporation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the
+ *   distribution.
+ * - Neither the name of the Rincon Research Corporation nor the names of
+ *   its contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
+ * ARCHED ROCK OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE
+ */
+/**
+ * Test for radio acknowledgements
+ * Program all motes up with ID 1
+ *   Led0 = Received a message
+ *   Led1 = Got an ack
+ *   Led2 = Missed an ack
+ * @author David Moss
+ */
+
+configuration TestAcksC {
+}
+
+implementation {
+  components TestAcksP,
+      MainC,
+      ActiveMessageC,
+      new AMSenderC(0),
+      new AMReceiverC(0),
+      new TimerMilliC(),
+      LedsC;
+      
+  TestAcksP.Boot -> MainC;
+  TestAcksP.SplitControl -> ActiveMessageC;
+  TestAcksP.Leds -> LedsC;
+  TestAcksP.AMSend -> AMSenderC;
+  TestAcksP.Receive -> AMReceiverC;
+  TestAcksP.PacketAcknowledgements -> ActiveMessageC;
+  TestAcksP.Timer -> TimerMilliC;
+  
+}
diff --git a/apps/tests/cc2420/TestAcks/TestAcksP.nc b/apps/tests/cc2420/TestAcks/TestAcksP.nc
new file mode 100644 (file)
index 0000000..1963080
--- /dev/null
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2005-2006 Rincon Research Corporation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the
+ *   distribution.
+ * - Neither the name of the Rincon Research Corporation nor the names of
+ *   its contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
+ * ARCHED ROCK OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE
+ */
+/**
+ * Test for radio acknowledgements
+ * Program all motes up with ID 1
+ *   Led0 = Missed an ack
+ *   Led1 = Got an ack
+ *   Led2 = Sent a message
+ * @author David Moss
+ */
+module TestAcksP {
+  uses {
+    interface Boot;
+    interface SplitControl;
+    interface AMSend;
+    interface Receive;
+    interface Leds;
+    interface PacketAcknowledgements;
+    interface Timer<TMilli>;
+  }
+}
+
+implementation {
+  
+  /** Message to transmit */
+  message_t myMsg;
+  
+  enum {  
+    DELAY_BETWEEN_MESSAGES = 50,
+  };
+  
+  
+  /***************** Prototypes ****************/
+  task void send();
+  
+  /***************** Boot Events ****************/
+  event void Boot.booted() {
+    call SplitControl.start();
+  }
+  
+  /***************** SplitControl Events ****************/
+  event void SplitControl.startDone(error_t error) {
+    post send();
+  }
+  
+  event void SplitControl.stopDone(error_t error) {
+  }
+  
+  /***************** Receive Events ****************/
+  event message_t *Receive.receive(message_t *msg, void *payload, uint8_t len) {
+    call Leds.led2Toggle();
+    return msg;
+  }
+  
+  /***************** AMSend Events ****************/
+  event void AMSend.sendDone(message_t *msg, error_t error) {
+    if(call PacketAcknowledgements.wasAcked(msg)) {
+      call Leds.led1Toggle();
+      call Leds.led0Off();
+    } else {
+      call Leds.led0Toggle();
+      call Leds.led1Off();
+    }
+    
+    if(DELAY_BETWEEN_MESSAGES > 0) {
+      call Timer.startOneShot(DELAY_BETWEEN_MESSAGES);
+    } else {
+      post send();
+    }
+  }
+  
+  /***************** Timer Events ****************/
+  event void Timer.fired() {
+    post send();
+  }
+  
+  /***************** Tasks ****************/
+  task void send() {
+    call PacketAcknowledgements.requestAck(&myMsg);
+    if(call AMSend.send(1, &myMsg, 0) != SUCCESS) {
+      post send();
+    }
+  }
+}
diff --git a/apps/tests/cc2420/TestPacketLink/Makefile b/apps/tests/cc2420/TestPacketLink/Makefile
new file mode 100644 (file)
index 0000000..fdf318a
--- /dev/null
@@ -0,0 +1,13 @@
+COMPONENT=TestPacketLinkC
+
+CFLAGS += -DPACKET_LINK
+
+BUILD_EXTRA_DEPS = PacketLinkMsg.java TestPacketLink.class
+
+PacketLinkMsg.java: TestPacketLink.h
+       mig java -target=$(PLATFORM) $(CFLAGS) -java-classname=PacketLinkMsg TestPacketLink.h PacketLinkMsg -o $@
+
+TestPacketLink.class: $(wildcard *.java) TestPacketLink.java
+       javac *.java
+
+include $(MAKERULES)
diff --git a/apps/tests/cc2420/TestPacketLink/README.txt b/apps/tests/cc2420/TestPacketLink/README.txt
new file mode 100644 (file)
index 0000000..51ab853
--- /dev/null
@@ -0,0 +1,29 @@
+
+Test the effectiveness of the PacketLink layer
+
+INSTALL
+  Transmitter == 1, 2, 3, 4, or 5 (up to MAX_TRANSMITTERS)
+  Receiver == 0, plugged into the computer
+
+EXPECTATIONS
+   Transmitter (ID not 0) -
+     led1 toggling on every successfully delivered message
+     led0 toggling on every unsuccessfully delivered message (and stay on
+       until the next dropped packet)
+   
+   Receiver (ID 0) -
+     Leds represent the binary count of sets of messages that were dropped.
+     Ideally, if the transmitter and receiver are in range of each other, 
+     the receiver's LEDs should never turn on.  You can pull the receiver
+     out of range for up to two seconds before the transmission will fail.
+     If you aren't convinced the receiver is doing anything because its 
+     leds aren't flashing, just turn it off and watch the transmitter's
+     reaction.
+
+
+Java Application Usage:
+  Linux: java TestPacketLink.class [-comm <packetsource>]
+  Windows: java TestPacketLink [-comm <packetsource>]
+
+  If not specified, the <packetsource> defaults to sf@localhost:9001 or
+  to your MOTECOM environment variable (if defined).
diff --git a/apps/tests/cc2420/TestPacketLink/TestPacketLink.h b/apps/tests/cc2420/TestPacketLink/TestPacketLink.h
new file mode 100644 (file)
index 0000000..aeb8463
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2005-2006 Rincon Research Corporation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the
+ *   distribution.
+ * - Neither the name of the Rincon Research Corporation nor the names of
+ *   its contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
+ * RINCON RESEARCH OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE
+ */
+
+
+#ifndef TESTPACKETLINK_H
+#define TESTPACKETLINK_H
+
+typedef nx_struct PacketLinkMsg {
+  nx_uint32_t count;
+  nx_uint16_t src;
+  nx_uint8_t cmd;
+} PacketLinkMsg;
+
+enum {
+  AM_PACKETLINKMSG = 0,
+};
+
+enum {
+  CMD_DROPPED_PACKET = 0,
+  CMD_DUPLICATE_PACKET = 1,
+};
+
+#ifndef MAX_TRANSMITTERS
+#define MAX_TRANSMITTERS 5
+#endif
+
+#endif
+
diff --git a/apps/tests/cc2420/TestPacketLink/TestPacketLink.java b/apps/tests/cc2420/TestPacketLink/TestPacketLink.java
new file mode 100644 (file)
index 0000000..7280d32
--- /dev/null
@@ -0,0 +1,105 @@
+
+/*
+ * Copyright (c) 2005-2006 Rincon Research Corporation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the
+ *   distribution.
+ * - Neither the name of the Rincon Research Corporation nor the names of
+ *   its contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
+ * RINCON RESEARCH OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE
+ */
+
+import net.tinyos.message.Message;
+import net.tinyos.message.MessageListener;
+import net.tinyos.message.MoteIF;
+import net.tinyos.message.SerialPacket;
+import net.tinyos.packet.BuildSource;
+import net.tinyos.packet.PhoenixSource;
+import net.tinyos.util.PrintStreamMessenger;
+
+/**
+ * Feedback on from a TestPacketLink receiver
+ * whether packets have been dropped or duplicated
+ * @author David Moss
+ *
+ */
+public class TestPacketLink implements MessageListener {
+
+  private MoteIF moteIF;
+  
+  private static final short CMD_DROPPED_PACKET = 0;
+  
+  private static final short CMD_DUPLICATE_PACKET = 1;
+  
+  /**
+   * Constructor
+   * @param moteIF
+   */
+  public TestPacketLink(MoteIF moteIF) {
+    this.moteIF = moteIF;
+    this.moteIF.registerListener(new PacketLinkMsg(), this);
+  }
+
+  public void messageReceived(int s, Message message) {
+    PacketLinkMsg msg = (PacketLinkMsg) message;
+    if(msg.get_cmd() == CMD_DROPPED_PACKET) {
+      System.out.println("Dropped packet from source " + msg.get_src());
+    } else {
+      System.out.println("Duplicate packet from source " + msg.get_src());
+    }
+  }
+  
+  private static void usage() {
+    System.err.println("usage: TestSerial [-comm <source>]");
+  }
+  
+  public static void main(String[] args) throws Exception {
+    String source = null;
+    if (args.length == 2) {
+      if (!args[0].equals("-comm")) {
+       usage();
+       System.exit(1);
+      }
+      source = args[1];
+    }
+    else if (args.length != 0) {
+      usage();
+      System.exit(1);
+    }
+    
+    PhoenixSource phoenix;
+    
+    if (source == null) {
+      phoenix = BuildSource.makePhoenix(PrintStreamMessenger.err);
+    }
+    else {
+      phoenix = BuildSource.makePhoenix(source, PrintStreamMessenger.err);
+    }
+
+    MoteIF mif = new MoteIF(phoenix);
+    new TestPacketLink(mif);
+  }
+
+
+}
diff --git a/apps/tests/cc2420/TestPacketLink/TestPacketLinkC.nc b/apps/tests/cc2420/TestPacketLink/TestPacketLinkC.nc
new file mode 100644 (file)
index 0000000..d26add8
--- /dev/null
@@ -0,0 +1,89 @@
+
+/*
+ * Copyright (c) 2005-2006 Rincon Research Corporation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the
+ *   distribution.
+ * - Neither the name of the Rincon Research Corporation nor the names of
+ *   its contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
+ * RINCON RESEARCH OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE
+ */
+
+/**
+ * Test the effectiveness of the PacketLink layer
+ *
+ * Transmitter == 1, 2, 3, 4, or 5 (up to MAX_TRANSMITTERS)
+ * Receiver == 0
+ *
+ * Expect:
+ *   Transmitter (ID not 0) -
+ *     led1 toggling on every successfully delivered message
+ *     led0 toggling on every unsuccessfully delivered message (and stay on
+ *       until the next dropped packet)
+ *   
+ *   Receiver (ID 0) -
+ *     Leds represent the binary count of sets of messages that were dropped
+ *     or duplicated.
+ * 
+ *     Ideally, if the transmitter and receiver are in range of each other, 
+ *     the receiver's LEDs should never turn on.  You can pull the receiver
+ *     out of range for up to two seconds before the transmission will fail.
+ *     If you aren't convinced the receiver is doing anything because its 
+ *     leds aren't flashing, just turn it off and watch the transmitter's
+ *     reaction.
+ *
+ * @author David Moss
+ */
+#include "TestPacketLink.h"
+
+configuration TestPacketLinkC {
+}
+
+implementation {
+
+  components TestPacketLinkP,
+      MainC,
+      ActiveMessageC,
+      CC2420ActiveMessageC,
+      new AMSenderC(AM_PACKETLINKMSG),
+      new AMReceiverC(AM_PACKETLINKMSG),
+      SerialActiveMessageC,
+      new SerialAMSenderC(AM_PACKETLINKMSG),
+      new TimerMilliC(),
+      LedsC;
+      
+  TestPacketLinkP.Boot -> MainC;
+  TestPacketLinkP.RadioSplitControl -> ActiveMessageC;
+  TestPacketLinkP.SerialSplitControl -> SerialActiveMessageC;
+  TestPacketLinkP.SerialAMSend -> SerialAMSenderC;
+  TestPacketLinkP.PacketLink -> CC2420ActiveMessageC;
+  TestPacketLinkP.AMPacket -> ActiveMessageC;
+  TestPacketLinkP.AMSend -> AMSenderC;
+  TestPacketLinkP.Receive -> AMReceiverC;
+  TestPacketLinkP.Timer -> TimerMilliC;
+  TestPacketLinkP.Leds -> LedsC;
+  
+}
+
diff --git a/apps/tests/cc2420/TestPacketLink/TestPacketLinkP.nc b/apps/tests/cc2420/TestPacketLink/TestPacketLinkP.nc
new file mode 100644 (file)
index 0000000..8c60492
--- /dev/null
@@ -0,0 +1,206 @@
+/*
+ * Copyright (c) 2005-2006 Rincon Research Corporation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the
+ *   distribution.
+ * - Neither the name of the Rincon Research Corporation nor the names of
+ *   its contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
+ * RINCON RESEARCH OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE
+ */
+/**
+ * Test the effectiveness of the PacketLink layer
+ *
+ * Transmitter == 1, 2, 3, 4, or 5 (up to MAX_TRANSMITTERS)
+ * Receiver == 0
+ *
+ * Expect:
+ *   Transmitter (ID not 0) -
+ *     led1 toggling on every successfully delivered message
+ *     led0 toggling on every unsuccessfully delivered message (and stay on
+ *       until the next dropped packet)
+ *   
+ *   Receiver (ID 0) -
+ *     Leds represent the binary count of sets of messages that were dropped
+ *     or duplicated.
+ * 
+ *     Ideally, if the transmitter and receiver are in range of each other, 
+ *     the receiver's LEDs should never turn on.  You can pull the receiver
+ *     out of range for up to two seconds before the transmission will fail.
+ *     If you aren't convinced the receiver is doing anything because its 
+ *     leds aren't flashing, just turn it off and watch the transmitter's
+ *     reaction.
+ *
+ * @author David Moss
+ */
+  
+#include "TestPacketLink.h"
+
+module TestPacketLinkP {
+  uses {
+    interface Boot;
+    interface SplitControl as RadioSplitControl;
+    interface SplitControl as SerialSplitControl;
+    interface AMSend;
+    interface AMSend as SerialAMSend;
+    interface AMPacket;
+    interface Receive;
+    interface PacketLink;
+    interface Leds;
+    interface Timer<TMilli>;
+  }
+}
+
+implementation {
+
+  /** The message we'll be sending */
+  message_t myMsg;
+  
+  /** Serial message for status */
+  message_t serialMsg;
+  
+  /** The local count we're sending or should receive on each unique message */
+  uint32_t count[MAX_TRANSMITTERS];
+  
+  /** The total number of packets missed by the receiver */
+  uint8_t missedPackets;
+  
+  /** True if this mote is the transmitter mote */
+  bool transmitter;
+  
+  enum {
+    MSG_DESTINATION = 0,
+  };
+  
+  /***************** Prototypes ****************/
+  task void send();
+  task void sendSerial();
+  
+  /***************** Boot Events ****************/
+  event void Boot.booted() {
+    int i;
+    
+    /*
+     * Setup this message in advance to retry up to 50 times with 40 ms of
+     * delay between each message.  50 * 40 ms = 2 seconds before it quits.
+     * It only needs to be setup once to be stored in the msg's metadata.
+     */
+    call PacketLink.setRetries(&myMsg, 50);
+    call PacketLink.setRetryDelay(&myMsg, 40);
+    missedPackets = 0;
+    
+    for(i = 0; i < MAX_TRANSMITTERS; i++) {
+      count[i] = 0;
+    }
+    
+    transmitter = (call AMPacket.address() != 0);
+    call RadioSplitControl.start();
+    
+    if(!transmitter) {
+      call SerialSplitControl.start();
+    }
+  }
+  
+  /***************** SplitControl Events *****************/
+  event void RadioSplitControl.startDone(error_t error) {
+    if(transmitter) {
+      post send();
+    }
+  }
+  
+  event void RadioSplitControl.stopDone(error_t error) {
+  }
+
+  /***************** SerialSplitControl Events ****************/
+  event void SerialSplitControl.startDone(error_t error) {
+  }
+  
+  event void SerialSplitControl.stopDone(error_t error) {
+  }
+  
+  /***************** AMSend Events ****************/
+  event void AMSend.sendDone(message_t *msg, error_t error) {
+    if(call PacketLink.wasDelivered(msg)) {
+      count[0]++;
+      call Leds.led1Toggle();
+    } else {
+      call Leds.led0Toggle();
+    }
+    
+    ((PacketLinkMsg *) call AMSend.getPayload(&myMsg))->count = count[0];
+    call Timer.startOneShot(50);
+  }
+  
+  /***************** SerialAMSend Events ****************/
+  event void SerialAMSend.sendDone(message_t *msg, error_t error) {
+  }
+  
+  /***************** Receive Events ****************/
+  event message_t *Receive.receive(message_t *msg, void *payload, uint8_t len) {
+    PacketLinkMsg *linkMsg = (PacketLinkMsg *) payload;
+    uint16_t source = call AMPacket.source(msg);
+    
+    if(transmitter || source > MAX_TRANSMITTERS - 1) {
+      return msg;
+    }
+    
+    if(linkMsg->count != count[source]) {
+      ((PacketLinkMsg *) (call SerialAMSend.getPayload(&serialMsg)))->src = source;
+      if(linkMsg->count > count[source]) {
+        ((PacketLinkMsg *) (call SerialAMSend.getPayload(&serialMsg)))->cmd = CMD_DROPPED_PACKET;
+      } else {
+        ((PacketLinkMsg *) (call SerialAMSend.getPayload(&serialMsg)))->cmd = CMD_DUPLICATE_PACKET;
+      }
+      post sendSerial();
+      
+      if(count[source] != 0) {
+        missedPackets++;
+        call Leds.set(missedPackets);
+      }
+    }
+    
+    count[source] = linkMsg->count;
+    count[source]++;
+    return msg;
+  }
+  
+  /***************** Timer Events ***************/
+  event void Timer.fired() {
+    post send();
+  }
+  
+  /***************** Tasks ****************/
+  task void send() {
+    if(call AMSend.send(MSG_DESTINATION, &myMsg, sizeof(PacketLinkMsg)) != SUCCESS) {
+      post send();
+    }
+  }
+  
+  task void sendSerial() {
+    if(call SerialAMSend.send(0, &serialMsg, sizeof(PacketLinkMsg)) != SUCCESS) {
+      post sendSerial();
+    }
+  }
+}
+
diff --git a/apps/tests/cc2420/TxThroughput/Makefile b/apps/tests/cc2420/TxThroughput/Makefile
new file mode 100644 (file)
index 0000000..cf72257
--- /dev/null
@@ -0,0 +1,18 @@
+COMPONENT=TxThroughputC
+
+
+BUILD_EXTRA_DEPS = ThroughputMsg.py ThroughputMsg.java ThroughputMsg.class
+
+ThroughputMsg.py: TxThroughput.h
+       mig python -target=$(PLATFORM) $(CFLAGS) -python-classname=ThroughputMsg TxThroughput.h ThroughputMsg -o $@
+
+ThroughputMsg.java: TxThroughput.h
+       mig java -target=$(PLATFORM) $(CFLAGS) -java-classname=ThroughputMsg TxThroughput.h ThroughputMsg -o $@
+
+ThroughputMsg.class: $(wildcard *.java) ThroughputMsg.java
+       javac *.java
+
+include $(MAKERULES)
+
+
diff --git a/apps/tests/cc2420/TxThroughput/README.txt b/apps/tests/cc2420/TxThroughput/README.txt
new file mode 100644 (file)
index 0000000..e2dedab
--- /dev/null
@@ -0,0 +1,21 @@
+
+Install:
+Compile and install this application to one mote. Leave the mote connected
+to the computer.
+
+Expectations:
+Led1 will toggle as each message is transmitted.  Once a second, the mote
+will send a packet through the serial port to the computer.  Run the
+TxThroughput java application:
+
+  Linux: java TxThroughput.class [-comm <packetsource>]
+  Windows: java TxThroughput [-comm <packetsource>]
+
+The TxThroughput Java application will display the number of packets per
+second and the number of bytes sent in the payload per second:
+
+[Packets/s]: 124;  [(Payload Bytes)/s]: 3472
+[Packets/s]: 126;  [(Payload Bytes)/s]: 3528
+[Packets/s]: 115;  [(Payload Bytes)/s]: 3220
+[Packets/s]: 124;  [(Payload Bytes)/s]: 3472
+
diff --git a/apps/tests/cc2420/TxThroughput/TxThroughput.h b/apps/tests/cc2420/TxThroughput/TxThroughput.h
new file mode 100644 (file)
index 0000000..2d0627c
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2005-2006 Rincon Research Corporation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the
+ *   distribution.
+ * - Neither the name of the Rincon Research Corporation nor the names of
+ *   its contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
+ * ARCHED ROCK OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE
+ */
+/**
+ * @author David Moss
+ */
+#ifndef TXTHROUGHPUT_H
+#define TXTHROUGHPUT_H
+
+/**
+ * Optionally override the default payload length with our own to see how it
+ * affects throughput.  Be sure to re-mig your messages.
+ */
+#ifndef TOSH_DATA_LENGTH
+#define TOSH_DATA_LENGTH 28 
+#endif
+
+#include "message.h"
+
+typedef nx_struct ThroughputMsg {
+  nx_uint16_t packetsPerSecond;
+  nx_uint8_t fillBytes[TOSH_DATA_LENGTH - 2];
+} ThroughputMsg;
+
+enum {
+  AM_THROUGHPUTMSG = 5,
+};
+
+/**
+ * Set this to 1 if you want to see how acknowledgements affects throughput
+ */
+#ifndef USE_ACKNOWLEDGEMENTS
+#define USE_ACKNOWLEDGEMENTS 0
+#endif
+
+
+#endif
+
diff --git a/apps/tests/cc2420/TxThroughput/TxThroughput.java b/apps/tests/cc2420/TxThroughput/TxThroughput.java
new file mode 100644 (file)
index 0000000..a935b3c
--- /dev/null
@@ -0,0 +1,88 @@
+
+/*
+ * Copyright (c) 2005-2006 Rincon Research Corporation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the
+ *   distribution.
+ * - Neither the name of the Rincon Research Corporation nor the names of
+ *   its contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
+ * ARCHED ROCK OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE
+ */
+/**
+ * Java-side application for examining the radio Tx throughput
+ * 
+ * @author David Moss
+ */
+
+import java.io.IOException;
+
+import net.tinyos.message.*;
+import net.tinyos.packet.*;
+import net.tinyos.util.*;
+
+public class TxThroughput implements MessageListener {
+
+  private MoteIF moteIF;
+
+  public TxThroughput(MoteIF moteIF) {
+    this.moteIF = moteIF;
+    this.moteIF.registerListener(new ThroughputMsg(), this);
+  }
+
+  public void messageReceived(int dest, Message message) {
+    System.out.println("[Packets/s]: " + ((ThroughputMsg) message).get_packetsPerSecond() 
+        + ";  [(Payload Bytes)/s]: " + ((((ThroughputMsg) message).numElements_fillBytes() + 2) * ((ThroughputMsg) message).get_packetsPerSecond()));
+  }
+
+  private static void usage() {
+    System.err.println("usage: TxThroughput [-comm <source>]");
+  }
+
+  public static void main(String[] args) throws Exception {
+    String source = null;
+    if (args.length == 2) {
+      if (!args[0].equals("-comm")) {
+        usage();
+        System.exit(1);
+      }
+      source = args[1];
+    } else if (args.length != 0) {
+      usage();
+      System.exit(1);
+    }
+
+    PhoenixSource phoenix;
+
+    if (source == null) {
+      phoenix = BuildSource.makePhoenix(PrintStreamMessenger.err);
+    } else {
+      phoenix = BuildSource.makePhoenix(source, PrintStreamMessenger.err);
+    }
+
+    MoteIF mif = new MoteIF(phoenix);
+    new TxThroughput(mif);
+  }
+
+}
\ No newline at end of file
diff --git a/apps/tests/cc2420/TxThroughput/TxThroughputC.nc b/apps/tests/cc2420/TxThroughput/TxThroughputC.nc
new file mode 100644 (file)
index 0000000..dbeb733
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2005-2006 Rincon Research Corporation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the
+ *   distribution.
+ * - Neither the name of the Rincon Research Corporation nor the names of
+ *   its contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
+ * ARCHED ROCK OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE
+ */
+/**
+ * @author David Moss
+ */
+#include "TxThroughput.h"
+
+configuration TxThroughputC {
+}
+
+implementation {
+
+  components TxThroughputP,
+      MainC,
+      SerialActiveMessageC,
+      new SerialAMSenderC(AM_THROUGHPUTMSG),
+      ActiveMessageC,
+      new AMSenderC(AM_THROUGHPUTMSG),
+      new TimerMilliC(),
+      LedsC;
+  
+  TxThroughputP.Boot -> MainC;
+  TxThroughputP.SerialSplitControl -> SerialActiveMessageC;
+  TxThroughputP.RadioSplitControl -> ActiveMessageC;
+  TxThroughputP.SerialAMSend -> SerialAMSenderC;
+  TxThroughputP.RadioAMSend -> AMSenderC;
+  TxThroughputP.PacketAcknowledgements -> ActiveMessageC;
+  TxThroughputP.Timer -> TimerMilliC;
+  TxThroughputP.Leds -> LedsC;
+  
+}
diff --git a/apps/tests/cc2420/TxThroughput/TxThroughputP.nc b/apps/tests/cc2420/TxThroughput/TxThroughputP.nc
new file mode 100644 (file)
index 0000000..31580cd
--- /dev/null
@@ -0,0 +1,129 @@
+/*
+ * Copyright (c) 2005-2006 Rincon Research Corporation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the
+ *   distribution.
+ * - Neither the name of the Rincon Research Corporation nor the names of
+ *   its contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
+ * ARCHED ROCK OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE
+ */
+/**
+ * @author David Moss
+ */
+#include "TxThroughput.h"
+module TxThroughputP {
+  uses {
+    interface Boot;
+    interface SplitControl as SerialSplitControl;
+    interface SplitControl as RadioSplitControl;
+    interface AMSend as SerialAMSend;
+    interface AMSend as RadioAMSend;
+    interface PacketAcknowledgements;
+    interface Timer<TMilli>;
+    interface Leds;
+  }
+}
+
+implementation {
+
+  message_t radioMsg;
+  
+  message_t serialMsg;
+  
+  uint16_t packetsPerSecond;
+  
+  enum {
+    MSG_DESTINATION = 1,
+  };
+  
+  /***************** Prototypes ****************/
+  task void sendRadio();
+  task void sendSerial();
+  
+  /***************** Boot Events ****************/
+  event void Boot.booted() {
+    if(USE_ACKNOWLEDGEMENTS) {
+      call PacketAcknowledgements.requestAck(&radioMsg);
+    } else {
+      call PacketAcknowledgements.noAck(&radioMsg);
+    }
+    
+    call RadioSplitControl.start();
+    call SerialSplitControl.start();
+  }
+  
+  /***************** RadioSplitControl Events ****************/
+  event void RadioSplitControl.startDone(error_t error) {
+    packetsPerSecond = 0;
+    post sendRadio();
+  }
+  
+  event void RadioSplitControl.stopDone(error_t error) {
+  }
+  
+  /***************** SerialSplitControl Events ****************/
+  event void SerialSplitControl.startDone(error_t error) {
+    call Timer.startPeriodic(1024);
+  }
+  
+  event void SerialSplitControl.stopDone(error_t error) {
+  }
+  
+  /***************** AMSend Events ****************/
+  event void RadioAMSend.sendDone(message_t *msg, error_t error) {
+    packetsPerSecond++;
+    call Leds.led1Toggle();
+    post sendRadio();
+  }
+  
+  event void SerialAMSend.sendDone(message_t *msg, error_t error) {
+  }
+  
+  /***************** Timer Events ***************/
+  event void Timer.fired() {
+    ((ThroughputMsg *) call SerialAMSend.getPayload(&serialMsg))->packetsPerSecond = packetsPerSecond;
+    packetsPerSecond = 0;
+    post sendSerial();
+  }
+  
+  /****************** Tasks ****************/
+  task void sendRadio() {
+    if(call RadioAMSend.send(MSG_DESTINATION, &radioMsg, sizeof(ThroughputMsg)) 
+        != SUCCESS) {
+      post sendRadio();
+    }
+  }
+  
+  task void sendSerial() {
+    if(call SerialAMSend.send(0, &serialMsg, sizeof(ThroughputMsg)) 
+        != SUCCESS) {
+      post sendSerial();
+    }
+  }
+}
+
+