[Tinyos-2-commits]
CVS: tinyos-2.x-contrib/tunit/tests/tinyos-2.x/tos/chips/cc2420/TestPacketLinkC
Makefile, NONE, 1.1 TestPacketLinkC.nc, NONE,
1.1 TestPacketLinkP.nc, NONE, 1.1 WirePacketLinkC.nc, NONE,
1.1 WirePacketLinkP.nc, NONE, 1.1 suite.properties, NONE, 1.1
David Moss
mossmoss at users.sourceforge.net
Sat Jul 21 22:31:56 PDT 2007
- Previous message: [Tinyos-2-commits]
CVS: tinyos-2.x-contrib/tunit/tests/tinyos-2.x/tos/chips/cc2420/TestNoAcks
Makefile, NONE, 1.1 TestTunitC.nc, NONE, 1.1 TestTunitP.nc,
NONE, 1.1 suite.properties, NONE, 1.1
- Next message: [Tinyos-2-commits]
CVS: tinyos-2.x-contrib/tunit/tests/tinyos-2.x/tos/chips/cc2420/TestPassiveByteIndicator
Makefile, NONE, 1.1 TestRadioC.nc, NONE, 1.1 TestRadioP.nc,
NONE, 1.1 suite.properties, NONE, 1.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/tinyos/tinyos-2.x-contrib/tunit/tests/tinyos-2.x/tos/chips/cc2420/TestPacketLinkC
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv19699/TestPacketLinkC
Added Files:
Makefile TestPacketLinkC.nc TestPacketLinkP.nc
WirePacketLinkC.nc WirePacketLinkP.nc suite.properties
Log Message:
Moved from a flat directory structure to a project-oriented directory structure
--- NEW FILE: Makefile ---
COMPONENT=TestPacketLinkC
CFLAGS += -DPACKET_LINK
CFLAGS += -DMAX_TUNIT_QUEUE=25
include $(MAKERULES)
--- 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
*/
/**
* @author David Moss
*/
configuration TestPacketLinkC {
}
implementation {
components
new TestCaseC() as TestPacketRetriesC,
new TestCaseC() as TestPacketPointersC,
new TestCaseC() as TestPacketDelayC,
new TestCaseC() as TestCancelC;
components TestPacketLinkP,
WirePacketLinkC,
PacketLinkP,
new TimerMilliC(),
new StateC(),
LedsC;
TestPacketLinkP.Send -> PacketLinkP.Send;
PacketLinkP.SubSend -> TestPacketLinkP.SubSend;
TestPacketLinkP.TestPacketRetries -> TestPacketRetriesC;
TestPacketLinkP.TestPacketPointers -> TestPacketPointersC;
TestPacketLinkP.TestPacketDelay -> TestPacketDelayC;
TestPacketLinkP.TestCancel -> TestCancelC;
TestPacketLinkP.Timer -> TimerMilliC;
TestPacketLinkP.State -> StateC;
TestPacketLinkP.PacketLink -> PacketLinkP;
TestPacketLinkP.PacketLinkState -> WirePacketLinkC;
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
*/
#include "TestCase.h"
/**
* @author David Moss
*/
module TestPacketLinkP {
provides {
interface Send as SubSend;
}
uses {
interface Send;
interface PacketLink;
interface TestCase as TestPacketRetries;
interface TestCase as TestPacketPointers;
interface TestCase as TestPacketDelay;
interface TestCase as TestCancel;
interface Timer<TMilli>;
interface State;
interface Leds;
interface State as PacketLinkState;
}
}
implementation {
enum {
S_IDLE,
S_TESTPACKETRETRIES,
S_TESTPACKETPOINTERS,
S_TESTPACKETDELAY,
S_TESTCANCEL,
};
message_t myMsg[5];
uint32_t numSends;
bool cancelled;
bool timerFired;
bool sendDone;
message_t *messageSending;
uint8_t msgIndex;
/** TRUE if the test failed for the TestPointers test case */
bool testFailed;
message_t *subsendMsg;
uint8_t subsendLen;
/***************** Prototypes ****************/
task void sendPointerTestMsg();
task void subsendDone();
/***************** Test Events ****************/
event void TestPacketRetries.run() {
call State.forceState(S_TESTPACKETRETRIES);
numSends = 0;
call PacketLink.setRetries(&myMsg[0], 1000);
call PacketLink.setRetryDelay(&myMsg[0], 0);
if(call Send.send(&myMsg[0], 0) != SUCCESS) {
assertFail("myMsg[0] couldn't be sent");
call TestPacketRetries.done();
call State.toIdle();
}
}
event void TestPacketPointers.run() {
call State.forceState(S_TESTPACKETPOINTERS);
msgIndex = 0;
testFailed = FALSE;
post sendPointerTestMsg();
}
event void TestPacketDelay.run() {
call State.forceState(S_TESTPACKETDELAY);
call PacketLink.setRetries(&myMsg[0], 100);
call PacketLink.setRetryDelay(&myMsg[0], 5);
timerFired = FALSE;
if(call Send.send(&myMsg[0], 10) != SUCCESS) {
assertFail("Could not send message");
call State.toIdle();
call TestPacketDelay.done();
} else {
// Timer should fire before the sendDone event is signaled.
// It's a lower bounds
call Timer.startOneShot(450);
}
}
event void TestCancel.run() {
call State.forceState(S_TESTCANCEL);
numSends = 0;
cancelled = FALSE;
call PacketLink.setRetries(&myMsg[4], 10);
call PacketLink.setRetryDelay(&myMsg[4], 0);
if(call Send.send(&myMsg[4], 10) != SUCCESS) {
assertFail("Could not send message");
call State.toIdle();
call TestCancel.done();
}
}
/***************** Timer Events ****************/
event void Timer.fired() {
timerFired = TRUE;
}
/***************** Send Events ****************/
/**
* Send is connected above PacketLink
*/
event void Send.sendDone(message_t* msg, error_t error) {
sendDone = TRUE;
if(call State.getState() == S_TESTPACKETRETRIES) {
assertTrue("SendState != IDLE", call PacketLinkState.isIdle());
assertFalse("Too few messages", numSends < 1000);
assertFalse("Too many messages", numSends > 1000);
assertFalse("sendDone(ERROR)", error);
call TestPacketRetries.done();
} else if (call State.getState() == S_TESTPACKETPOINTERS) {
assertEquals("Send returned incorrect ptr", (message_t *) &myMsg[msgIndex], msg);
msgIndex++;
post sendPointerTestMsg();
} else if (call State.getState() == S_TESTPACKETDELAY) {
if(timerFired) {
// Timer fired, our packet was sent long enough.
assertSuccess();
} else {
assertFail("SendDone occured too early");
}
call State.toIdle();
call Timer.stop();
call TestPacketDelay.done();
} else if (call State.getState() == S_TESTCANCEL) {
if(msg != &myMsg[4]) {
assertFail("Send returned the incorrect ptr");
}
assertFalse("Too many packets after cancel", numSends > 3);
call TestCancel.done();
}
}
/***************** SubSend Commands ****************/
/**
* SubSend is connected below PacketLink - it will potentiallyy get called
* multiple times for each call to Send.send(..) into PacketLink.
*/
command error_t SubSend.send(message_t *msg, uint8_t len) {
numSends++;
if(call State.getState() == S_TESTPACKETRETRIES) {
if(msg != &myMsg[0]) {
assertFail("SubSend saw an incorrect pointer");
}
} else if (call State.getState() == S_TESTPACKETPOINTERS) {
if(msg != &myMsg[msgIndex]) {
assertFail("SubSend got incorrect pointer");
} else if(len != 10) {
assertFail("SubSend got incorrect length (expected 10)");
}
} else if (call State.getState() == S_TESTPACKETDELAY) {
// Just let it signal sendDone()
} else if (call State.getState() == S_TESTCANCEL) {
if(call Send.cancel(&myMsg[4]) != SUCCESS) {
assertFail("Could not cancel message");
}
}
subsendMsg = msg;
subsendLen = len;
post subsendDone();
return SUCCESS;
}
command error_t SubSend.cancel(message_t *msg) {
cancelled = TRUE;
if(msg != &myMsg[4]) {
assertFail("SubSend.cancel(wrong pointer)");
}
return SUCCESS;
}
command uint8_t SubSend.maxPayloadLength() {
return TOSH_DATA_LENGTH;
}
command void *SubSend.getPayload(message_t* msg) {
return msg->data;
}
/***************** Tasks ***************/
task void sendPointerTestMsg() {
if(msgIndex < 5) {
call PacketLink.setRetries(&myMsg[msgIndex], 5);
if(call Send.send((message_t *) &myMsg[msgIndex], 10) != SUCCESS) {
assertFail("Couldn't send msg");
call TestPacketPointers.done();
call State.toIdle();
}
} else {
call State.toIdle();
call TestPacketPointers.done();
}
}
task void subsendDone() {
signal SubSend.sendDone(subsendMsg, SUCCESS);
}
}
--- NEW FILE: WirePacketLinkC.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
*/
/**
* We don't want PacketLinkC to call ActiveMessageC which would re-wire
* everything and use the whole radio stack.
*/
configuration WirePacketLinkC {
provides {
interface State as PacketLinkState;
}
}
implementation {
components WirePacketLinkP,
PacketLinkP,
new StateC(),
new TimerMilliC(),
CC2420PacketC,
ActiveMessageAddressC;
PacketLinkState = StateC;
PacketLinkP.SendState -> StateC;
PacketLinkP.PacketAcknowledgements -> CC2420PacketC;
PacketLinkP.CC2420PacketBody -> CC2420PacketC;
PacketLinkP.DelayTimer -> TimerMilliC;
PacketLinkP.AMPacket -> WirePacketLinkP;
WirePacketLinkP.CC2420PacketBody -> CC2420PacketC;
WirePacketLinkP.amAddress -> ActiveMessageAddressC;
}
--- NEW FILE: WirePacketLinkP.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
*/
module WirePacketLinkP {
provides {
interface AMPacket;
}
uses {
interface CC2420PacketBody;
command am_addr_t amAddress();
}
}
implementation {
command am_addr_t AMPacket.address() {
return call amAddress();
}
command am_addr_t AMPacket.destination(message_t* amsg) {
cc2420_header_t* header = call CC2420PacketBody.getHeader(amsg);
return header->dest;
}
command am_addr_t AMPacket.source(message_t* amsg) {
cc2420_header_t* header = call CC2420PacketBody.getHeader(amsg);
return header->src;
}
command void AMPacket.setDestination(message_t* amsg, am_addr_t addr) {
cc2420_header_t* header = call CC2420PacketBody.getHeader(amsg);
header->dest = addr;
}
command void AMPacket.setSource(message_t* amsg, am_addr_t addr) {
cc2420_header_t* header = call CC2420PacketBody.getHeader(amsg);
header->src = addr;
}
command bool AMPacket.isForMe(message_t* amsg) {
return (call AMPacket.destination(amsg) == call AMPacket.address() ||
call AMPacket.destination(amsg) == AM_BROADCAST_ADDR);
}
command am_id_t AMPacket.type(message_t* amsg) {
cc2420_header_t* header = call CC2420PacketBody.getHeader(amsg);
return header->type;
}
command void AMPacket.setType(message_t* amsg, am_id_t type) {
cc2420_header_t* header = call CC2420PacketBody.getHeader(amsg);
header->type = type;
}
command am_group_t AMPacket.group(message_t* amsg) {
return TOS_AM_GROUP;
}
command void AMPacket.setGroup(message_t* amsg, am_group_t grp) {
}
command am_group_t AMPacket.localGroup() {
return TOS_AM_GROUP;
}
}
--- NEW FILE: suite.properties ---
/**
* Valid keywords are:
* @author <optional author(s)> (multiple)
* @testname <optional testname> (once)
* @description <optional, multiline description> (once)
* @extra <any build/install extras> (multiple)
* @ignore <single target> (multiple)
* @only <single target> (multiple)
* @minnodes <# nodes> (once)
* @maxnodes <# nodes> (once)
* @exactnodes <# of exact nodes> (once)
* @mintargets <# of minimum targets for heterogeneous network testing> (once)
* @timeout <timeout duration of the test in minutes, default is 1 min.>
* @skip (once)
*/
@testname Test PacketLinkC
@author David Moss
@description Isolates PacketLinkC/PacketLinkP
@exactnodes 1
@ignore mica2
@ignore mica2dot
- Previous message: [Tinyos-2-commits]
CVS: tinyos-2.x-contrib/tunit/tests/tinyos-2.x/tos/chips/cc2420/TestNoAcks
Makefile, NONE, 1.1 TestTunitC.nc, NONE, 1.1 TestTunitP.nc,
NONE, 1.1 suite.properties, NONE, 1.1
- Next message: [Tinyos-2-commits]
CVS: tinyos-2.x-contrib/tunit/tests/tinyos-2.x/tos/chips/cc2420/TestPassiveByteIndicator
Makefile, NONE, 1.1 TestRadioC.nc, NONE, 1.1 TestRadioP.nc,
NONE, 1.1 suite.properties, NONE, 1.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Tinyos-2-commits
mailing list