[Tinyos-2-commits] CVS: tinyos-2.x/apps/tests/TestRadioPM/apps/TestUPMA/GatewayNode Makefile, NONE, 1.1.2.1 MsgCountMsg.h, NONE, 1.1.2.1 PrintMsgCountMsgs.java, NONE, 1.1.2.1 RadioPmProtocolManagerC.nc, NONE, 1.1.2.1 TestGatewayNodeAppC.nc, NONE, 1.1.2.1 TestGatewayNodeC.nc, NONE, 1.1.2.1

Kevin Klues klueska at users.sourceforge.net
Mon May 15 12:36:10 PDT 2006


Update of /cvsroot/tinyos/tinyos-2.x/apps/tests/TestRadioPM/apps/TestUPMA/GatewayNode
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv9561/apps/tests/TestRadioPM/apps/TestUPMA/GatewayNode

Added Files:
      Tag: tos-2-resource-pm-eval-cand
	Makefile MsgCountMsg.h PrintMsgCountMsgs.java 
	RadioPmProtocolManagerC.nc TestGatewayNodeAppC.nc 
	TestGatewayNodeC.nc 
Log Message:
Radio Power Management protocol architecture

--- NEW FILE: Makefile ---
BASE_DIR = $(TOSROOT)/apps/tests/TestRadioPM/apps

COMPONENT=TestGatewayNodeAppC

CFLAGS += -I$(BASE_DIR)/../apps/TestUPMA
include $(BASE_DIR)/TestUPMA/MakeIncludes

BUILD_EXTRA_DEPS += MsgCountMsg.class PrintMsgCountMsgs.class

%.class: %.java
	javac $<

MsgCountMsg.java: MsgCountMsg.h
	mig java -target=$(PLATFORM) $(CFLAGS) -java-classname=MsgCountMsg MsgCountMsg.h MsgCountMsg -o $@


include $(MAKERULES)


--- NEW FILE: MsgCountMsg.h ---
/*
 * "Copyright (c) 2005 Washington University in St. Louis.
 * 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 WASHINGTON UNIVERSITY IN ST. LOUIS 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 WASHINGTON 
 * UNIVERSITY IN ST. LOUIS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * WASHINGTON UNIVERSITY IN ST. LOUIS 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 WASHINGTON UNIVERSITY IN ST. LOUIS HAS NO 
 * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
 * MODIFICATIONS."
 */

/**
 *
 * @author Kevin Klues (klueska at cs.wustl.edu)
 * @version $Revision: 1.1.2.1 $
 * @date $Date: 2006/05/15 19:36:08 $
 */

typedef nx_struct MsgCountMsg {
  nx_uint8_t nodeId;
  nx_uint8_t appId;
  nx_uint32_t numMsgs;
} MsgCountMsg;

enum {
  AM_MSGCOUNTMSG = 128,
};


--- NEW FILE: PrintMsgCountMsgs.java ---
/*									tab:4
 * "Copyright (c) 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."
 *
 */

/**
 * Java-side application for testing serial port communication.
 * Modified to just receive packets of type NumSenderMsgs and
 * print them out
 * 
 *
 * @author Phil Levis <pal at cs.berkeley.edu>
 * @author Kevin Klues <klueska at cs.wustl.edu>
 * @date August 12 2005
 */

import java.io.IOException;

import net.tinyos.message.*;
import net.tinyos.packet.*;
import net.tinyos.util.*;

public class PrintMsgCountMsgs implements MessageListener {

  private MoteIF moteIF;
  public long counter = 0;
  public int last = 1;
  
  public PrintMsgCountMsgs(MoteIF moteIF) {
    this.moteIF = moteIF;
    this.moteIF.registerListener(new MsgCountMsg(), this);
  }

  public void messageReceived(int to, Message message) {
    MsgCountMsg msg = (MsgCountMsg)message;
    if(last == 1)
      System.out.println("Begin: " + counter);
    if(msg.get_nodeId() == 0xFF) {
      last = 1;
      counter = msg.get_numMsgs();
    }
    else {
      System.out.println("\tNode: " + msg.get_nodeId() + "\tApp: " + msg.get_appId() + "\tNumMsgs: " + msg.get_numMsgs());
      last = 0;
    }
  }
  
  private static void usage() {
    System.err.println("usage: PrintMsgCountMsgs [-comm <source>]");
  }
  
  public static void main(String[] args) throws Exception {
    String source = "";
    if (args.length == 2) {
      if (!args[0].equals("-comm")) {
	       usage();
	       System.exit(1);
      }
      source = args[1];
    }
    else {
      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);
    PrintMsgCountMsgs serial = new PrintMsgCountMsgs(mif);
  }


}

--- NEW FILE: RadioPmProtocolManagerC.nc ---
/*
 * "Copyright (c) 2005 Washington University in St. Louis.
 * 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 WASHINGTON UNIVERSITY IN ST. LOUIS 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 WASHINGTON
 * UNIVERSITY IN ST. LOUIS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * WASHINGTON UNIVERSITY IN ST. LOUIS 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 WASHINGTON UNIVERSITY IN ST. LOUIS HAS NO
 * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
 * MODIFICATIONS."
 */

/**
 *
 * @author Kevin Klues (klueska at cs.wustl.edu)
 * @version $Revision: 1.1.2.1 $
 * @date $Date: 2006/05/15 19:36:08 $
 */

#include "PEAS.h"
#include "AppDutyCycles.h"

configuration RadioPmProtocolManagerC {}
implementation {
  components ActiveMessageC;
  components new PeasC(PEAS_ON_TIME, PEAS_OFF_TIME, AM_PEAS_PROBE, AM_PEAS_REPLY);
//   components new ReceivingAppC(APP0_ON_TIME, APP0_OFF_TIME, AM_APP_0) as ReceivingApp0;
//   components new ReceivingAppC(APP1_ON_TIME, APP1_OFF_TIME, AM_APP_1) as ReceivingApp1;
//   components new ReceivingAppC(APP2_ON_TIME, APP2_OFF_TIME, AM_APP_2) as ReceivingApp2;
//   components new ReceivingAppC(APP3_ON_TIME, APP3_OFF_TIME, AM_APP_3) as ReceivingApp3;
//   components new ReceivingAppC(APP4_ON_TIME, APP4_OFF_TIME, AM_APP_4) as ReceivingApp4;
  components new ReceivingAppC(APP5_ON_TIME, APP5_OFF_TIME, AM_APP_5) as ReceivingApp5;
}


--- NEW FILE: TestGatewayNodeAppC.nc ---
/*
 * "Copyright (c) 2005 Washington University in St. Louis.
 * 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 WASHINGTON UNIVERSITY IN ST. LOUIS 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 WASHINGTON
 * UNIVERSITY IN ST. LOUIS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * WASHINGTON UNIVERSITY IN ST. LOUIS 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 WASHINGTON UNIVERSITY IN ST. LOUIS HAS NO
 * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
 * MODIFICATIONS."
 */

/**
 *
 * @author Kevin Klues (klueska at cs.wustl.edu)
 * @version $Revision: 1.1.2.1 $
 * @date $Date: 2006/05/15 19:36:08 $
 */

#include "AppDutyCycles.h"
#include "MsgCountMsg.h"

configuration TestGatewayNodeAppC {}
implementation {
  components MainC, LedsC;
  components TestGatewayNodeC as App;
  components ActiveMessageC as AMRadio;
  components RadioPmProtocolManagerC;
  components new TimerMilliC();
//   components new AMReceiverC(AM_APP_0) as Snooper0;
//   components new AMReceiverC(AM_APP_1) as Snooper1;
//   components new AMReceiverC(AM_APP_2) as Snooper2;
//   components new AMReceiverC(AM_APP_3) as Snooper3;
//   components new AMReceiverC(AM_APP_4) as Snooper4;
  components new AMReceiverC(AM_APP_5) as Snooper5;
  components SerialDebugC;

  //MainC.SoftwareInit -> AMSerial;

  App.Boot -> MainC;
  App.Leds -> LedsC;
  App.Timer ->  TimerMilliC;

//   App.Snooper[AM_APP_0] -> Snooper0;
//   App.Snooper[AM_APP_1] -> Snooper1;
//   App.Snooper[AM_APP_2] -> Snooper2;
//   App.Snooper[AM_APP_3] -> Snooper3;
//   App.Snooper[AM_APP_4] -> Snooper4;
  App.Snooper[AM_APP_5] -> Snooper5;

  //App.AMSerialSend -> AMSerial.AMSend[AM_MSGCOUNTMSG];
  //App.SerialPacket -> AMSerial;
  App.SerialDebug -> SerialDebugC;
  App.RadioPacket -> AMRadio;
}


--- NEW FILE: TestGatewayNodeC.nc ---
/*
 * "Copyright (c) 2005 Washington University in St. Louis.
 * 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 WASHINGTON UNIVERSITY IN ST. LOUIS 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 WASHINGTON 
 * UNIVERSITY IN ST. LOUIS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * WASHINGTON UNIVERSITY IN ST. LOUIS 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 WASHINGTON UNIVERSITY IN ST. LOUIS HAS NO 
 * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
 * MODIFICATIONS."
 */

/**
 *
 * @author Kevin Klues (klueska at cs.wustl.edu)
 * @version $Revision: 1.1.2.1 $
 * @date $Date: 2006/05/15 19:36:08 $ 
 */

#include "Timer.h"

module TestGatewayNodeC {
  uses {
    interface Boot;
    interface Leds;
    interface Timer<TMilli> as Timer;
    //interface SplitControl as AMSerialControl;
    //interface AMSend as AMSerialSend;
    //interface Packet as SerialPacket;
    interface Packet as RadioPacket;
    interface Receive as Snooper[uint8_t];
	 interface SerialDebug;
  }
}
implementation {

#define SAMPLING_PERIOD 20000//(15*60*1000)
  
  uint32_t numMsgsFromApp[NUM_NODES][NUM_APPS];
  uint32_t counter;
  uint32_t numPkts=0;
  int i, j;
  bool last;

  void setupMsg() {
    //MsgCountMsg* m = (MsgCountMsg*)call SerialPacket.getPayload(&serialMsg, NULL);
    while(numMsgsFromApp[i][j] == 0 && i < NUM_NODES) {
      j++;
      if(j == NUM_APPS) {j = 0; i++;}
    }
    if(i < NUM_NODES) {
	  call SerialDebug.print("Id",i);
      call SerialDebug.print("App",j);
      call SerialDebug.print("NumMsg",numMsgsFromApp[i][j]);
	  call SerialDebug.flush();
	  numPkts+=numMsgsFromApp[i][j];
      j++;
      if(j == NUM_APPS) {j = 0; i++;}

    }
    else {
      call SerialDebug.print("SAMPLE",++counter);
	  call SerialDebug.print("Total",numPkts);
      last = TRUE;	  
	  //call SerialDebug.print("******","0);
	  call SerialDebug.flush();

    }
  }

  event void Boot.booted() {
    counter = 0;
    memset(numMsgsFromApp, 0, NUM_NODES*NUM_APPS);
    //call AMSerialControl.start();
	call Timer.startOneShot(SAMPLING_PERIOD);
  }

  /*event void AMSerialControl.startDone(error_t error) {
    call Timer.startOneShot(SAMPLING_PERIOD);
  }

  event void AMSerialControl.stopDone(error_t error) {
  }*/

  event void SerialDebug.flushDone(error_t error){  
	
    if(last == FALSE) {
      setupMsg();      
    }else{numPkts = 0;
	}
  }

  event void Timer.fired() {
    i = j = 0;
    last = FALSE;
    setupMsg();    
    call Timer.startOneShot(SAMPLING_PERIOD);
  }

  event message_t* Snooper.receive[uint8_t n](message_t* bufPtr, void* payload, uint8_t len) {
    uint8_t* id = (uint8_t*)call RadioPacket.getPayload(bufPtr, NULL);
    numMsgsFromApp[*id][n - AM_APP_0]++;
    call Leds.led0Toggle();
    return bufPtr;
  }
}



More information about the Tinyos-2-commits mailing list