[Tinyos-2-commits] CVS: tinyos-2.x/apps/tests/TestDissemination Makefile, NONE, 1.1.4.2 TestDisseminationAppC.nc, NONE, 1.1.4.2 TestDisseminationC.nc, NONE, 1.1.4.2 test.py, NONE, 1.1.4.2 topo.txt, NONE, 1.1.4.2

Kevin Klues klueska at users.sourceforge.net
Mon May 15 11:35:26 PDT 2006


Update of /cvsroot/tinyos/tinyos-2.x/apps/tests/TestDissemination
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv18756/apps/tests/TestDissemination

Added Files:
      Tag: tos-2-resource-pm-eval-cand
	Makefile TestDisseminationAppC.nc TestDisseminationC.nc 
	test.py topo.txt 
Log Message:
Merging the development branch with the resource/power management evaluation branch.  After this merge all files except those already commited should be identical.

--- NEW FILE: Makefile ---
COMPONENT=TestDisseminationAppC
CFLAGS += -I$(TOSDIR)/lib/net

include $(MAKERULES)


--- NEW FILE: TestDisseminationAppC.nc ---
/*
 * Copyright (c) 2006 Arched Rock 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 Arched Rock 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
 *
 */

/**
 * TestDisseminationAppC exercises the dissemination layer, by causing
 * the node with ID 1 to inject 2 new values into the network every 4
 * seconds. For the 32-bit object with key 0x1234, node 1 toggles LED
 * 0 when it sends, and every other node toggles LED 0 when it
 * receives the correct value. For the 16-bit object with key 0x2345,
 * node 1 toggles LED 1 when it sends, and every other node toggles
 * LED 1 when it receives the correct value.
 *
 * See TEP118 - Dissemination for details.
 * 
 * @author Gilman Tolle <gtolle at archedrock.com>
 * @version $Revision: 1.1.4.2 $ $Date: 2006/05/15 18:35:24 $
 */

configuration TestDisseminationAppC {}
implementation {
  components TestDisseminationC;

  components MainC;
  TestDisseminationC.Boot -> MainC;

  components new DisseminatorC(uint32_t, 0x1234) as Object32C;
  TestDisseminationC.Value32 -> Object32C;
  TestDisseminationC.Update32 -> Object32C;

  components new DisseminatorC(uint16_t, 0x2345) as Object16C;
  TestDisseminationC.Value16 -> Object16C;
  TestDisseminationC.Update16 -> Object16C;

  components LedsC;
  TestDisseminationC.Leds -> LedsC;

  components new TimerMilliC();
  TestDisseminationC.Timer -> TimerMilliC;
}


--- NEW FILE: TestDisseminationC.nc ---
#include <Timer.h>

/*
 * Copyright (c) 2006 Arched Rock 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 Arched Rock 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
 *
 */

/**
 * TestDisseminationC exercises the dissemination layer, by causing
 * the node with ID 1 to inject 2 new values into the network every 4
 * seconds. For the 32-bit object with key 0x1234, node 1 toggles LED
 * 0 when it sends, and every other node toggles LED 0 when it
 * receives the correct value. For the 16-bit object with key 0x2345,
 * node 1 toggles LED 1 when it sends, and every other node toggles
 * LED 1 when it receives the correct value.
 *
 * See TEP118 - Dissemination for details.
 * 
 * @author Gilman Tolle <gtolle at archedrock.com>
 * @version $Revision: 1.1.4.2 $ $Date: 2006/05/15 18:35:24 $
 */

module TestDisseminationC {
  uses interface Boot;

  uses interface DisseminationValue<uint32_t> as Value32;
  uses interface DisseminationUpdate<uint32_t> as Update32;

  uses interface DisseminationValue<uint16_t> as Value16;
  uses interface DisseminationUpdate<uint16_t> as Update16;

  uses interface Leds;

  uses interface Timer<TMilli>;
}
implementation {
  event void Boot.booted() {
    if ( TOS_NODE_ID % 4 == 1 ) {
      call Timer.startPeriodic(20000);
    }
  }

  event void Timer.fired() {
    uint32_t newVal32 = 0xDEADBEEF;
    uint16_t newVal16 = 0xABCD;
    call Leds.led0Toggle();
    call Leds.led1Toggle();
    call Update32.change( &newVal32 );
    call Update16.change( &newVal16 );
    dbg("TestDisseminationC", "TestDisseminationC: Timer fired.\n");
  }

  event void Value32.changed() {
    const uint32_t* newVal = call Value32.get();
    if ( *newVal == 0xDEADBEEF ) {
      call Leds.led0Toggle();
      dbg("TestDisseminationC", "Received new correct 32-bit value @ %s.\n", sim_time_string());
    }
    else {
      dbg("TestDisseminationC", "Received new incorrect 32-bit value.\n");
    }
  }

  event void Value16.changed() {
    const uint16_t* newVal = call Value16.get();
    if ( *newVal == 0xABCD ) {
      call Leds.led1Toggle();
      dbg("TestDisseminationC", "Received new correct 16-bit value @ %s.\n", sim_time_string());
    }
    else {
      dbg("TestDisseminationC", "Received new incorrect 16-bit value: 0x%hx\n", *newVal);
    }
  }
}

--- NEW FILE: test.py ---
# This script is a simple TOSSIM test of dissemination.
# It builds a 15x15 grid of nodes and has nodes start
# disseminating two values (based on the TinyOS app).
# It prints out when nodes receive new values, including
# the dissemination key and sequence number. You should
# be able to see how the implementation can resolve
# multiple concurrent changes within the network as
# well as more than one value being updated at a time.

import TOSSIM
import sys

t = TOSSIM.Tossim([])
m = t.mac();
r = t.radio();
t.init()

#t.addChannel("LedsC", sys.stdout);
#t.addChannel("AM", sys.stdout);
#t.addChannel("TestDisseminationC", sys.stdout);
t.addChannel("Dissemination", sys.stdout);
#t.addChannel("Gain", sys.stdout);
#t.addChannel("TossimPacketModelC", sys.stdout);

print (dir(TOSSIM.Tossim))

f = open("topo.txt", "r")
lines = f.readlines()
for line in lines:
  s = line.split()
  if (len(s) > 0):
    if (s[0] == "gain"):
      r.add(int(s[1]), int(s[2]), float(s[3]))
    elif (s[0] == "noise"):
      r.setNoise(int(s[1]), float(s[2]), float(s[3]))

for i in range(0, 225):
  m = t.getNode(i);
  m.bootAtTime((t.ticksPerSecond() / 50) * i + 43);
 
while (t.time() / t.ticksPerSecond() < 600):
  t.runNextEvent()

--- NEW FILE: topo.txt ---
gain	0	1	-64.71
gain	1	0	-66.06
gain	0	2	-73.89
gain	2	0	-76.19
gain	0	3	-76.00
gain	3	0	-77.08
gain	0	4	-78.29
gain	4	0	-80.34
gain	0	5	-78.62
gain	5	0	-78.56
gain	0	6	-85.98
gain	6	0	-87.32
gain	0	7	-89.50
gain	7	0	-90.94
gain	0	8	-87.98
gain	8	0	-91.27
gain	0	9	-87.39
gain	9	0	-95.08
gain	0	10	-91.14
[...50586 lines suppressed...]
noise	205	-107.32	4.00
noise	206	-103.93	4.00
noise	207	-103.67	4.00
noise	208	-104.88	4.00
noise	209	-103.33	4.00
noise	210	-103.77	4.00
noise	211	-107.35	4.00
noise	212	-104.40	4.00
noise	213	-102.55	4.00
noise	214	-99.68	4.00
noise	215	-102.74	4.00
noise	216	-102.16	4.00
noise	217	-102.66	4.00
noise	218	-107.37	4.00
noise	219	-105.53	4.00
noise	220	-109.69	4.00
noise	221	-104.91	4.00
noise	222	-107.83	4.00
noise	223	-103.71	4.00
noise	224	-102.76	4.00



More information about the Tinyos-2-commits mailing list