[Tinyos-2-commits] CVS: tinyos-2.x/apps/tests/cc2420/TxThroughput Makefile, NONE, 1.1 README.txt, NONE, 1.1 TxThroughput.h, NONE, 1.1 TxThroughput.java, NONE, 1.1 TxThroughputC.nc, NONE, 1.1 TxThroughputP.nc, NONE, 1.1

dmm rincon at users.sourceforge.net
Thu Apr 12 10:14:11 PDT 2007


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

Added Files:
	Makefile README.txt TxThroughput.h TxThroughput.java 
	TxThroughputC.nc TxThroughputP.nc 
Log Message:
Supporting test suite for the newest CC2420 stack.  Includes a low power version of RadioCountToLeds, TxThroughput analysis, TestAck, Unicast and Broadcast deliveries, RssiToSerial channel analyzer, and the PacketLink test app.

--- NEW FILE: Makefile ---
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)


 

--- NEW FILE: README.txt ---

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


--- NEW FILE: TxThroughput.h ---
/*
 * 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


--- NEW FILE: TxThroughput.java ---

/*
 * 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);
  }

}
--- NEW FILE: TxThroughputC.nc ---
/*
 * 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;
  
}

--- NEW FILE: TxThroughputP.nc ---
/*
 * 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();
    }
  }
}





More information about the Tinyos-2-commits mailing list