[Tinyos-2-commits] CVS: tinyos-2.x/apps/tests/cc2420/TestPacketLink
Makefile, NONE, 1.1 README.txt, NONE, 1.1 TestPacketLink.h,
NONE, 1.1 TestPacketLink.java, NONE, 1.1 TestPacketLinkC.nc,
NONE, 1.1 TestPacketLinkP.nc, NONE, 1.1
dmm
rincon at users.sourceforge.net
Thu Apr 12 10:14:11 PDT 2007
- Previous message: [Tinyos-2-commits] CVS: tinyos-2.x/apps/tests/cc2420/TestAcks
Makefile, NONE, 1.1 README.txt, NONE, 1.1 TestAcksC.nc, NONE,
1.1 TestAcksP.nc, NONE, 1.1
- Next message: [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
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/tinyos/tinyos-2.x/apps/tests/cc2420/TestPacketLink
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv20118/TestPacketLink
Added Files:
Makefile README.txt TestPacketLink.h TestPacketLink.java
TestPacketLinkC.nc TestPacketLinkP.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=TestPacketLinkC
CFLAGS += -DPACKET_LINK
BUILD_EXTRA_DEPS = PacketLinkMsg.java TestPacketLink.class
PacketLinkMsg.java: TestPacketLink.h
mig java -target=$(PLATFORM) $(CFLAGS) -java-classname=PacketLinkMsg TestPacketLink.h PacketLinkMsg -o $@
TestPacketLink.class: $(wildcard *.java) TestPacketLink.java
javac *.java
include $(MAKERULES)
--- NEW FILE: README.txt ---
Test the effectiveness of the PacketLink layer
INSTALL
Transmitter == 1, 2, 3, 4, or 5 (up to MAX_TRANSMITTERS)
Receiver == 0, plugged into the computer
EXPECTATIONS
Transmitter (ID not 0) -
led1 toggling on every successfully delivered message
led0 toggling on every unsuccessfully delivered message (and stay on
until the next dropped packet)
Receiver (ID 0) -
Leds represent the binary count of sets of messages that were dropped.
Ideally, if the transmitter and receiver are in range of each other,
the receiver's LEDs should never turn on. You can pull the receiver
out of range for up to two seconds before the transmission will fail.
If you aren't convinced the receiver is doing anything because its
leds aren't flashing, just turn it off and watch the transmitter's
reaction.
Java Application Usage:
Linux: java TestPacketLink.class [-comm <packetsource>]
Windows: java TestPacketLink [-comm <packetsource>]
If not specified, the <packetsource> defaults to sf at localhost:9001 or
to your MOTECOM environment variable (if defined).
--- NEW FILE: TestPacketLink.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
* RINCON RESEARCH 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
*/
#ifndef TESTPACKETLINK_H
#define TESTPACKETLINK_H
typedef nx_struct PacketLinkMsg {
nx_uint32_t count;
nx_uint16_t src;
nx_uint8_t cmd;
} PacketLinkMsg;
enum {
AM_PACKETLINKMSG = 0,
};
enum {
CMD_DROPPED_PACKET = 0,
CMD_DUPLICATE_PACKET = 1,
};
#ifndef MAX_TRANSMITTERS
#define MAX_TRANSMITTERS 5
#endif
#endif
--- NEW FILE: TestPacketLink.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
* RINCON RESEARCH 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
*/
import net.tinyos.message.Message;
import net.tinyos.message.MessageListener;
import net.tinyos.message.MoteIF;
import net.tinyos.message.SerialPacket;
import net.tinyos.packet.BuildSource;
import net.tinyos.packet.PhoenixSource;
import net.tinyos.util.PrintStreamMessenger;
/**
* Feedback on from a TestPacketLink receiver
* whether packets have been dropped or duplicated
* @author David Moss
*
*/
public class TestPacketLink implements MessageListener {
private MoteIF moteIF;
private static final short CMD_DROPPED_PACKET = 0;
private static final short CMD_DUPLICATE_PACKET = 1;
/**
* Constructor
* @param moteIF
*/
public TestPacketLink(MoteIF moteIF) {
this.moteIF = moteIF;
this.moteIF.registerListener(new PacketLinkMsg(), this);
}
public void messageReceived(int s, Message message) {
PacketLinkMsg msg = (PacketLinkMsg) message;
if(msg.get_cmd() == CMD_DROPPED_PACKET) {
System.out.println("Dropped packet from source " + msg.get_src());
} else {
System.out.println("Duplicate packet from source " + msg.get_src());
}
}
private static void usage() {
System.err.println("usage: TestSerial [-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 TestPacketLink(mif);
}
}
--- NEW FILE: TestPacketLinkC.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
* RINCON RESEARCH 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
*/
/**
* Test the effectiveness of the PacketLink layer
*
* Transmitter == 1, 2, 3, 4, or 5 (up to MAX_TRANSMITTERS)
* Receiver == 0
*
* Expect:
* Transmitter (ID not 0) -
* led1 toggling on every successfully delivered message
* led0 toggling on every unsuccessfully delivered message (and stay on
* until the next dropped packet)
*
* Receiver (ID 0) -
* Leds represent the binary count of sets of messages that were dropped
* or duplicated.
*
* Ideally, if the transmitter and receiver are in range of each other,
* the receiver's LEDs should never turn on. You can pull the receiver
* out of range for up to two seconds before the transmission will fail.
* If you aren't convinced the receiver is doing anything because its
* leds aren't flashing, just turn it off and watch the transmitter's
* reaction.
*
* @author David Moss
*/
#include "TestPacketLink.h"
configuration TestPacketLinkC {
}
implementation {
components TestPacketLinkP,
MainC,
ActiveMessageC,
CC2420ActiveMessageC,
new AMSenderC(AM_PACKETLINKMSG),
new AMReceiverC(AM_PACKETLINKMSG),
SerialActiveMessageC,
new SerialAMSenderC(AM_PACKETLINKMSG),
new TimerMilliC(),
LedsC;
TestPacketLinkP.Boot -> MainC;
TestPacketLinkP.RadioSplitControl -> ActiveMessageC;
TestPacketLinkP.SerialSplitControl -> SerialActiveMessageC;
TestPacketLinkP.SerialAMSend -> SerialAMSenderC;
TestPacketLinkP.PacketLink -> CC2420ActiveMessageC;
TestPacketLinkP.AMPacket -> ActiveMessageC;
TestPacketLinkP.AMSend -> AMSenderC;
TestPacketLinkP.Receive -> AMReceiverC;
TestPacketLinkP.Timer -> TimerMilliC;
TestPacketLinkP.Leds -> LedsC;
}
--- NEW FILE: TestPacketLinkP.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
* RINCON RESEARCH 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
*/
/**
* Test the effectiveness of the PacketLink layer
*
* Transmitter == 1, 2, 3, 4, or 5 (up to MAX_TRANSMITTERS)
* Receiver == 0
*
* Expect:
* Transmitter (ID not 0) -
* led1 toggling on every successfully delivered message
* led0 toggling on every unsuccessfully delivered message (and stay on
* until the next dropped packet)
*
* Receiver (ID 0) -
* Leds represent the binary count of sets of messages that were dropped
* or duplicated.
*
* Ideally, if the transmitter and receiver are in range of each other,
* the receiver's LEDs should never turn on. You can pull the receiver
* out of range for up to two seconds before the transmission will fail.
* If you aren't convinced the receiver is doing anything because its
* leds aren't flashing, just turn it off and watch the transmitter's
* reaction.
*
* @author David Moss
*/
#include "TestPacketLink.h"
module TestPacketLinkP {
uses {
interface Boot;
interface SplitControl as RadioSplitControl;
interface SplitControl as SerialSplitControl;
interface AMSend;
interface AMSend as SerialAMSend;
interface AMPacket;
interface Receive;
interface PacketLink;
interface Leds;
interface Timer<TMilli>;
}
}
implementation {
/** The message we'll be sending */
message_t myMsg;
/** Serial message for status */
message_t serialMsg;
/** The local count we're sending or should receive on each unique message */
uint32_t count[MAX_TRANSMITTERS];
/** The total number of packets missed by the receiver */
uint8_t missedPackets;
/** True if this mote is the transmitter mote */
bool transmitter;
enum {
MSG_DESTINATION = 0,
};
/***************** Prototypes ****************/
task void send();
task void sendSerial();
/***************** Boot Events ****************/
event void Boot.booted() {
int i;
/*
* Setup this message in advance to retry up to 50 times with 40 ms of
* delay between each message. 50 * 40 ms = 2 seconds before it quits.
* It only needs to be setup once to be stored in the msg's metadata.
*/
call PacketLink.setRetries(&myMsg, 50);
call PacketLink.setRetryDelay(&myMsg, 40);
missedPackets = 0;
for(i = 0; i < MAX_TRANSMITTERS; i++) {
count[i] = 0;
}
transmitter = (call AMPacket.address() != 0);
call RadioSplitControl.start();
if(!transmitter) {
call SerialSplitControl.start();
}
}
/***************** SplitControl Events *****************/
event void RadioSplitControl.startDone(error_t error) {
if(transmitter) {
post send();
}
}
event void RadioSplitControl.stopDone(error_t error) {
}
/***************** SerialSplitControl Events ****************/
event void SerialSplitControl.startDone(error_t error) {
}
event void SerialSplitControl.stopDone(error_t error) {
}
/***************** AMSend Events ****************/
event void AMSend.sendDone(message_t *msg, error_t error) {
if(call PacketLink.wasDelivered(msg)) {
count[0]++;
call Leds.led1Toggle();
} else {
call Leds.led0Toggle();
}
((PacketLinkMsg *) call AMSend.getPayload(&myMsg))->count = count[0];
call Timer.startOneShot(50);
}
/***************** SerialAMSend Events ****************/
event void SerialAMSend.sendDone(message_t *msg, error_t error) {
}
/***************** Receive Events ****************/
event message_t *Receive.receive(message_t *msg, void *payload, uint8_t len) {
PacketLinkMsg *linkMsg = (PacketLinkMsg *) payload;
uint16_t source = call AMPacket.source(msg);
if(transmitter || source > MAX_TRANSMITTERS - 1) {
return msg;
}
if(linkMsg->count != count[source]) {
((PacketLinkMsg *) (call SerialAMSend.getPayload(&serialMsg)))->src = source;
if(linkMsg->count > count[source]) {
((PacketLinkMsg *) (call SerialAMSend.getPayload(&serialMsg)))->cmd = CMD_DROPPED_PACKET;
} else {
((PacketLinkMsg *) (call SerialAMSend.getPayload(&serialMsg)))->cmd = CMD_DUPLICATE_PACKET;
}
post sendSerial();
if(count[source] != 0) {
missedPackets++;
call Leds.set(missedPackets);
}
}
count[source] = linkMsg->count;
count[source]++;
return msg;
}
/***************** Timer Events ***************/
event void Timer.fired() {
post send();
}
/***************** Tasks ****************/
task void send() {
if(call AMSend.send(MSG_DESTINATION, &myMsg, sizeof(PacketLinkMsg)) != SUCCESS) {
post send();
}
}
task void sendSerial() {
if(call SerialAMSend.send(0, &serialMsg, sizeof(PacketLinkMsg)) != SUCCESS) {
post sendSerial();
}
}
}
- Previous message: [Tinyos-2-commits] CVS: tinyos-2.x/apps/tests/cc2420/TestAcks
Makefile, NONE, 1.1 README.txt, NONE, 1.1 TestAcksC.nc, NONE,
1.1 TestAcksP.nc, NONE, 1.1
- Next message: [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
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Tinyos-2-commits
mailing list