[Tinyos-2-commits] CVS: tinyos-2.x/apps/tests/TestSimComm Makefile, NONE, 1.1 TestCommAppC.nc, NONE, 1.1 TestCommC.nc, NONE, 1.1 meyer-short.txt, NONE, 1.1 test-equal.py, NONE, 1.1 test-unequal.py, NONE, 1.1

Phil Levis scipio at users.sourceforge.net
Thu May 17 15:06:12 PDT 2007


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

Added Files:
	Makefile TestCommAppC.nc TestCommC.nc meyer-short.txt 
	test-equal.py test-unequal.py 
Log Message:
Add test for capture effect.


--- NEW FILE: Makefile ---
COMPONENT=TestCommAppC

include $(MAKERULES)


--- NEW FILE: TestCommAppC.nc ---
// $Id: TestCommAppC.nc,v 1.1 2007/05/17 22:06:10 scipio Exp $

/*									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-2005 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.
 */

/**
 * This application sends a single active message broadcast if it has
 * address 0, and then starts a timer at 1Hz.  If it has any address 
 * other than 0, it starts a timer at 1 Hz upon receiving a broadcast 
 * message.  The idea is to have one base station with address 0 send 
 * out a broadacst message to synchronize itself with all receivers.  
 * All Leds from the base station and any receivers of the broadcast 
 * should blink together.
 
 * It uses the radio HIL component
 * <tt>ActiveMessageC</tt>, and its packets are AM type 240.
 *
 * @author Phil Levis
 * @author Kevin Klues
 * @date   Nov 7 2005
 */

configuration TestCommAppC {}
implementation {
  enum {
    AM_TEST  = 5
  };
  
  components MainC, TestCommC as App, RandomC, ActiveMessageC;
  components new TimerMilliC(), new AMSenderC(AM_TEST), new AMReceiverC(AM_TEST);
  
  App.Boot -> MainC.Boot;
  App.SplitControl -> ActiveMessageC;
  App.Timer -> TimerMilliC;
  App.AMSend -> AMSenderC;
  App.Receive -> AMReceiverC;
  App.Random -> RandomC;
  App.AMPacket -> AMSenderC;
  App.PacketAcknowledgements -> AMSenderC;
}



--- NEW FILE: TestCommC.nc ---
// $Id: TestCommC.nc,v 1.1 2007/05/17 22:06:10 scipio Exp $

/*									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.
 */

/**
 *  Implementation of the TestTimer application.
 *
 *  @author Phil Levis
 *  @date   April 7 2007
 *
 **/

module TestCommC {
  uses {
    interface Boot;
    interface Timer<TMilli> as Timer;
    interface Receive;
    interface AMSend;
    interface Random;
    interface SplitControl;
    interface AMPacket;
    interface PacketAcknowledgements;
  }
}
implementation {

  message_t packet;
  uint8_t busy;
  
  event void Boot.booted() {
    call SplitControl.start();
  }

  event void SplitControl.startDone(error_t e) {
    if (TOS_NODE_ID == 1 ||
	TOS_NODE_ID == 3) {
      call Timer.startPeriodic(128);
    }
  }
  
  event void SplitControl.stopDone(error_t e) {

  }
    
  event void Timer.fired() {
    if (!busy) {
      call PacketAcknowledgements.requestAck(&packet);
      if (call AMSend.send(2, &packet, call AMSend.maxPayloadLength()) == SUCCESS) {
	dbg("TestComm", "Send succeeded @ %s\n", sim_time_string());
	busy = TRUE;
      }
      else {
	dbg("TestComm", "Send failed at @ %s\n", sim_time_string());
      }
    }
    else {
      dbg("TestComm", "Send when busy at @ %s\n", sim_time_string());
    }
  }

  event void AMSend.sendDone(message_t* m, error_t s) {
    dbg("TestComm", "Send completed with %s @ %s\n", call PacketAcknowledgements.wasAcked(m)? "ACK":"NOACK", sim_time_string());
    busy = FALSE;
  }


  event message_t* Receive.receive(message_t* msg, void* p, uint8_t l) {
    dbg("TestComm", "Received message from %hu @ %s\n", call AMPacket.source(msg), sim_time_string());
    return msg;
  }
}





--- NEW FILE: meyer-short.txt ---
-41
-41
-41
-41
-41
-41
-41
-91
-41
-41
-41
-41
-41
-48
-41
-41
-41
-83
-98
[...961 lines suppressed...]
-80
-80
-80
-80
-80
-96
-98
-98
-99
-71
-98
-98
-99
-98
-98
-98
-98
-98 



--- NEW FILE: test-equal.py ---
from TOSSIM import *
import sys
import time

t = Tossim([])
r = t.radio();

t.addChannel("TestComm", sys.stdout)
t.addChannel("SNRLoss", sys.stdout)

#t.addChannel("Acks", sys.stdout)
#t.addChannel("Gain", sys.stdout)
#t.addChannel("CpmModelC", sys.stdout)
#t.addChannel("AM", sys.stdout)


start = time.time();
m1 = t.getNode(1)
m2 = t.getNode(2)
m3 = t.getNode(3)

# Set up a hidden terminal problem, where 1 and 3
# are closely synchronized, but cannot hear each other.
m1.bootAtTime(345321);
m2.bootAtTime(82123411);
m3.bootAtTime(345325);
r.add(1, 2, -60.0);
r.add(2, 1, -60.0);
r.add(2, 3, -60.0);
r.add(3, 2, -60.0);

noise = open("meyer-short.txt", "r")
lines = noise.readlines()
for line in lines:
  str = line.strip()
  if (str != ""):
    val = int(str)
    m1.addNoiseTraceReading(val)
    m2.addNoiseTraceReading(val)
    m3.addNoiseTraceReading(val)

m1.createNoiseModel()
m2.createNoiseModel()
m3.createNoiseModel()

for i in range(0, 1000000):
    t.runNextEvent();

    

--- NEW FILE: test-unequal.py ---
from TOSSIM import *
import sys
import time

t = Tossim([])
r = t.radio();

t.addChannel("TestComm", sys.stdout)
t.addChannel("SNRLoss", sys.stdout)
#t.addChannel("Acks", sys.stdout)
#t.addChannel("Gain", sys.stdout)
#t.addChannel("CpmModelC", sys.stdout)
#t.addChannel("AM", sys.stdout)


start = time.time();
m1 = t.getNode(1)
m2 = t.getNode(2)
m3 = t.getNode(3)

# Set up a hidden terminal problem, where 1 and 3
# are closely synchronized, but cannot hear each other.
m1.bootAtTime(345321);
m2.bootAtTime(82123411);
m3.bootAtTime(345325);
r.add(1, 2, -50.0);
r.add(2, 1, -50.0);
r.add(2, 3, -60.0);
r.add(3, 2, -60.0);

noise = open("meyer-short.txt", "r")
lines = noise.readlines()
for line in lines:
  str = line.strip()
  if (str != ""):
    val = int(str)
    m1.addNoiseTraceReading(val)
    m2.addNoiseTraceReading(val)
    m3.addNoiseTraceReading(val)

m1.createNoiseModel()
m2.createNoiseModel()
m3.createNoiseModel()

for i in range(0, 1000000):
    t.runNextEvent();

    



More information about the Tinyos-2-commits mailing list