[Tinyos-2-commits] CVS: tinyos-2.x-contrib/stanford-sing/s4-tinyos-2.x/apps/TestS4Simple Makefile, NONE, 1.1 TestS4Simple.nc, NONE, 1.1 TestS4SimpleM.nc, NONE, 1.1 batch_run.sh, NONE, 1.1 driver-test.cpp, NONE, 1.1 grid-topology.txt, NONE, 1.1 meyer-heavy.txt, NONE, 1.1

Tahir Azim genie1 at users.sourceforge.net
Thu Oct 23 15:12:52 PDT 2008


Update of /cvsroot/tinyos/tinyos-2.x-contrib/stanford-sing/s4-tinyos-2.x/apps/TestS4Simple
In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv29402

Added Files:
	Makefile TestS4Simple.nc TestS4SimpleM.nc batch_run.sh 
	driver-test.cpp grid-topology.txt meyer-heavy.txt 
Log Message:
Application files for S4 TinyOS 2.x port.


--- NEW FILE: Makefile ---
COMPONENT=TestS4Simple

#Configuration Parameters
PFLAGS += -DMAX_ROOT_BEACONS=8   #c
PFLAGS += -DTOSH_DATA_LENGTH=50  #29 for c < 8; 30 for 8 coords; 42 for 12 coord components; 54 for 16;
PFLAGS += -DBVR_APP_DATA_LENGTH=10 # TOSH_DATA_LENGTH - (12 + MAX_ROOT_BEACONS)
PFLAGS += -DLE_CACHE_SIZE=18

#Testing
#CFLAGS += -DLINK_DUMMY #uncomment to use dummy link estimator
#CFLAGS += -DFROZEN_COORDS

#Experimentation
CFLAGS += -DEXP_PROGRESS #uses the expected progress when ranking next_hops
CFLAGS += -DBEACON_ETX  -DCRROUTING -DRECEIVE_HISTORY_SIZE=4 
CFLAGS += -DETX_TOLERANCE -DLOCAL_DV  -DSHORT_INTERVAL -DFW_COORD_TABLE -DMULTIPLE_BEACON -DEXP_BACKOFF 
#CFLAGS += -I/home/Tahir/T2SerialT1

TEMP_TOSDIR=../../tos/
#Includes
PFLAGS += -I$(TEMP_TOSDIR)/lib/bvr -I$(TEMP_TOSDIR)/lib/commstack 
PFLAGS += -I$(TEMP_TOSDIR)/lib/interfaces -I$(TEMP_TOSDIR)/lib/linkestimator -I$(TEMP_TOSDIR)/lib/util -I$(TOSDIR)/chips/cc2420/interfaces -I$(TOSDIR)/chips/cc2420/packet
PFLAGS += -I$(TEMP_TOSDIR)/lib/command  -I$(TOSDIR)/types/ 


include $(MAKERULES)

--- NEW FILE: TestS4Simple.nc ---
// ex: set tabstop=2 shiftwidth=2 expandtab syn=c:
// $Id: TestS4Simple.nc,v 1.1 2008/10/23 22:12:50 genie1 Exp $

/*                                                                      
 * "Copyright (c) 2000-2003 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.
 */

/*
 * Authors:  Rodrigo Fonseca
 * Date Last Modified: 2005/05/26
 */

includes AM;
includes BVR;

includes Timer;

configuration TestS4Simple {
}

implementation {
  components MainC
           , TestS4SimpleM as TestS4SimpleM
           , S4RouterC
           , LBlinkC
           , LedsC as Leds
#if PLATFORM_MICA2 || PLATFORM_MICA2DOT
           , CC1000RadioC
#endif           
           , new TimerMilliC() as Timer3
           , RandomLfsrC as Random
           , CoordinateTableM
           , ActiveMessageC
           , RandomC
           ;
     
  TestS4SimpleM -> MainC.Boot;
  
  TestS4SimpleM.RouterControl -> S4RouterC.StdControl;
  TestS4SimpleM.Send -> S4RouterC.S4Send;
  TestS4SimpleM.Receive -> S4RouterC.S4Receive;
 
  TestS4SimpleM.LBlink -> LBlinkC;
  TestS4SimpleM.LBlinkControl -> LBlinkC; 
  TestS4SimpleM.Leds -> Leds;
  TestS4SimpleM.Boot -> MainC.Boot;
  
  TestS4SimpleM.Timer1 -> Timer3;
  
  //S4RouterC.RouteToInterface -> TestS4SimpleM;
  
  TestS4SimpleM.CoordinateTable -> CoordinateTableM;
  TestS4SimpleM.AMControl -> ActiveMessageC;
  
  TestS4SimpleM.Random -> RandomC;
  TestS4SimpleM.AMPacket -> ActiveMessageC;
}



--- NEW FILE: TestS4SimpleM.nc ---
// ex: set tabstop=2 shiftwidth=2 expandtab syn=c:
// $Id: TestS4SimpleM.nc,v 1.1 2008/10/23 22:12:50 genie1 Exp $

/*                                                                      
 * "Copyright (c) 2000-2003 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.
 */

/*
 * Authors:  Rodrigo Fonseca
 * Date Last Modified: 2005/05/26
 */

includes message;

includes AM;

includes Timer;

module TestS4SimpleM {
  provides {
    interface StdControl;
  }
  uses {
    interface S4Send as Send;
    interface S4Receive as Receive;
    interface StdControl as RouterControl;
    interface Boot;

    interface LBlink;
    interface StdControl as LBlinkControl;
    interface Leds;
    
    interface Timer<TMilli> as Timer1;
    interface CoordinateTable;
    interface SplitControl as AMControl;
    interface Random;
    
    interface AMPacket;
  }
  
}

implementation {


  message_t send_buffer;
  uint8_t *pAppMsg;
  uint16_t payloadLength;
  Coordinates dest;
  bool busy_sending;

  uint16_t d; //used to store the data that is passed around

  uint16_t mode;
  uint16_t dest_id;

  uint16_t msg_id;
   
  task void sendAnother();

  event void Boot.booted() { 
    call AMControl.start();
  
    if (call AMPacket.address()==82)
      call Timer1.startOneShot(900000u);
    
    pAppMsg = (uint8_t*) call Send.getBuffer(&send_buffer,&payloadLength);    
    dbg("TestBVR"," init ended\n", mode);
        
    msg_id = call AMPacket.address();
    busy_sending = 0;
     
    mode = 0;    
  }
  
  event void Timer1.fired() {
    CoordinateTableEntry* cte = NULL;
    CoordinateTableEntry* selectedCte=NULL;
    int i=0;
  
#ifdef TOSSIM
      sim_add_channel("BVR-debug", stdout);
#endif

    dbg("TestBVR", "Timer1.fired at %s\n", sim_time_string());
    
    for (i=0; i<200; i++) {
      cte = call CoordinateTable.getEntry(i);
    
      if ( cte!=NULL ){
        selectedCte = cte;
        coordinates_print(&cte->coords);        
      }
    }

    dbg("TestBVR", "cte=%x, dest=%x\n", cte, &dest);

    if (cte== NULL)
        call Timer1.startOneShot(900000u);

    cte = selectedCte;
    if (!busy_sending /*&& cte!=NULL*/ && call AMPacket.address()==82) {

      //coordinates_copy(&cte->coords, &dest);
      
      dest.comps[0] = 255;
      dest.comps[1] = 255;
      dest.comps[2] = 255;
      dest.comps[3] = 255;
      dest.comps[4] = 255;
      dest.comps[5] = 255;
      dest.comps[6] = 0;
      dest.comps[7] = 255;
      dest_id = 203;
      
      coordinates_print(&dest);
      *((uint16_t*)pAppMsg) = msg_id;
      
      if ( post sendAnother() == SUCCESS ) {
        busy_sending = TRUE;            
      }
      else {
        dbg("TestBVR", "132 routeTo failed\n ");
      }
    }
    else {
      dbg("TestBVR", "135 busy_sending was set!\n ");
    }
    
    dbg("TestBVR", "Timer1.fired ended\n");
  }

  command error_t StdControl.start() {  
    call RouterControl.start();
    call LBlinkControl.start();
    call LBlink.setRate(100);
    call LBlink.yellowBlink(3);
    call LBlink.greenBlink(2);
    call LBlink.redBlink(1);
		
    return SUCCESS;
  }
  
  command error_t StdControl.stop() {
    call RouterControl.stop();
    call LBlinkControl.stop();
    return SUCCESS;
  }

  task void sendAnother() {
    uint8_t beacon=6;
    if (busy_sending) {
#ifdef TOSSIM      
      sim_add_channel("BVR", stdout);
#endif      
      dbg("TestBVR","TestBVR %d sendAnother: mode:%d, dest_id=%d!!\n", call AMPacket.address(), mode, dest_id);  
      if (call Send.send(&send_buffer, 2,  dest_id, beacon) != SUCCESS) {
        dbg("TestBVR","sendAnother: send failed\n");
        busy_sending = FALSE;
      }
    } else 
      dbg("TestBVR","sendAnother ERROR: called without busy_sending set\n");
  }

  event error_t Send.sendDone(message_t* msg, error_t success) {
    //finished sending
    if (msg == &send_buffer) {
      busy_sending = FALSE;
    } else {
      dbg("TestBVR","App Send$sendDone: msg (%p)!=&send_buffer(%p)!\n",msg,&send_buffer);
    }
    return SUCCESS;
  }

  event message_t* Receive.receive(message_t* msg, void* payload, uint16_t payloadLen) {
    //final hop, received message
    d = *(uint16_t*)payload;
    dbg("TestBVR","ReceiveApp: %d; len=%d!!\n", d, payloadLen);  
    
    return msg; //we are done with the buffer
  }
	

  
  event void AMControl.stopDone(error_t err) {
  
  }
  
  event void AMControl.startDone(error_t err){
    if (err == SUCCESS) {
      dbg("BVR", "Radio started; now starting the rest");
      call RouterControl.start();
    
      call LBlinkControl.start();
    
    
      pAppMsg = (uint8_t*) call Send.getBuffer(&send_buffer,&payloadLength);    
      dbg("TestBVR"," init ended\n", mode);
        
      msg_id = call AMPacket.address();
      busy_sending = 0;
     
      mode = 0;
        
      
        
      return ;   
    }
  }
  
}

--- NEW FILE: batch_run.sh ---
make micaz sim

i="440"
date

g++ -g -o a.exe driver-test.cpp  build/micaz/sim.o  build/micaz/tossim.o build/micaz/c-support.o  -I$TOSDIR/lib/tossim

./a.exe > output.txt 




date
exit


--- NEW FILE: driver-test.cpp ---
#include <tossim.h>
#include <stdio.h>
#include <fstream.h>
#include <iostream>

#include <vector>

int main() {
 srand(time(NULL));

 Tossim* t = new Tossim(NULL);
 Radio* r = t->radio();
 t->addChannel("TestBVR", stdout);
// t->addChannel("BVR-debug", stdout);
// t->addChannel("S4-debug", stdout);
// t->addChannel("BVR", stdout);
// t->addChannel("S4UserRouter", stdout);
 t->addChannel("S4Router", stdout);
//  t->addChannel("S4-beacon", stdout);
// t->addChannel("S4-state-func", stdout); 
 fstream filestr;
 char nextLine[1024];
 std::vector<int> v;

 fstream filestr_noise;
 filestr_noise.open("meyer-heavy.txt", fstream::in);
   
 while (!filestr_noise.eof()) {
         filestr_noise.getline(nextLine, 1024);
         v.push_back(atoi(nextLine));
 }

 filestr_noise.close();

 fstream filestr2;
 filestr2.open ("grid-topology.txt", fstream::in );


 while (!filestr2.eof()) {
	 filestr2.getline(nextLine, 1024);
     char* s0 = strtok(nextLine, "\t");
     char* s1 = strtok( NULL, "\t");
     char* s2 = strtok( NULL, "\t");
     char* s3 = strtok( NULL, "\t");

     if (s0 == NULL)
       break;

	 if (!strncmp(s0, "gain", strlen(s0))) {
	    if ( atof(s3) > -104.0){
	       r->add(atoi(s1), atoi(s2), atof(s3));
	       std::cout << "Adding connection: "<< s1<< " "<< s2<< " "<< s3<<std::endl;
	     }
     }
	 else if (! strncmp(s0 , "noise", strlen(s0))){
	       t->getNode(atoi(s1))->bootAtTime(rand() % 1234567890);

	       std::cout << "Adding node: "<< s1<< " "<< s2<< " "<< s3<<std::endl;
              Mote* m = t->getNode(atoi(s1));
              for (int j = 0; j < v.size(); j++) {
                int noiseReading = v[j]; 
                m->addNoiseTraceReading(noiseReading);
                
              }
              m->createNoiseModel();

     }
  }

  std::cout << "Starting the simulation\n";
  int i = 0;
  while (t->time()/ t->ticksPerSecond() < 1500) {
      t->runNextEvent();
      //std::cout << t->time()/ t->ticksPerSecond() << std::endl;
  }

  printf("Ended\n");
}

--- NEW FILE: grid-topology.txt ---
gain	0	1	-87.04
gain	1	0	-88.02
gain	0	2	-89.58
gain	2	0	-90.40
gain	0	3	-96.56
gain	3	0	-98.69
gain	0	4	-108.45
gain	4	0	-112.72
gain	0	5	-99.72
gain	5	0	-104.43
gain	0	6	-107.02
gain	6	0	-108.16
gain	0	7	-112.03
gain	7	0	-110.56
gain	0	8	-106.75
gain	8	0	-111.25
gain	0	9	-107.25
gain	9	0	-107.24
gain	0	10	-115.74
[...50586 lines suppressed...]
noise	205	-104.23	4.00
noise	206	-106.02	4.00
noise	207	-104.12	4.00
noise	208	-104.44	4.00
noise	209	-105.64	4.00
noise	210	-101.45	4.00
noise	211	-105.37	4.00
noise	212	-105.30	4.00
noise	213	-104.10	4.00
noise	214	-105.43	4.00
noise	215	-105.24	4.00
noise	216	-104.04	4.00
noise	217	-102.31	4.00
noise	218	-110.75	4.00
noise	219	-106.03	4.00
noise	220	-106.45	4.00
noise	221	-104.91	4.00
noise	222	-102.56	4.00
noise	223	-104.23	4.00
noise	224	-102.95	4.00

--- NEW FILE: meyer-heavy.txt ---
-39
-98
-98
-98
-99
-98
-94
-98
-98
-98
-98
-98
-99
-98
-98
-98
-98
-98
-98
-98
-97
-98
-97
-98
-98
-98
-98
-91
-98
-96
-96
-98
-98
-98
-98
-98
-99
-86
-97
-98
-98
-86
-90
-91
-87
-87
-98
-98
-98
-98
-98
-98
-78
-94
-90
-96
-98
-98
-98
-86
-98
-98
-98
-99
-98
-98
-98
-97
-99
-98
-98
-99
-98
-93
-98
-98
-82
-82
-81
-82
-82
-49
-98
-81
-82
-64
-81
-81
-98
-98
-98
-98
-98
-98
-98
-98
-98
-98
-98
-98
-98
-98
-98
-99
-98
-94
-98
-98
-98
-98
-98
-98
-98
-98
-94
-96
-99
-98
-98
-98
-98
-98
-98
-98
-99
-98
-98
-98
-93
-95
-99
-98
-96
-98
-99
-98
-98
-98
-98
-81
-80
-81
-81
-96
-84
-85
-98
-85
-84
-84
-78
-84
-83
-90
-90
-94
-98
-81
-81
-81
-85
-81
-81
-98
-81
-81
-98
-98
-82
-81
-82
-81
-81
-98
-82
-98
-98
-98
-98
-98
-98
-98
-98
-98
-98
-92
-98
-98
-87
-98
-99
-99
-98
-98
-98
-98
-98
-93
-98



More information about the Tinyos-2-commits mailing list