[Tinyos-2-commits]
CVS: tinyos-2.x-contrib/tunit/tests/tinyos-2.x/tos/chips/cc2420/TestConfigAddressChangeAfterStart
Makefile, NONE, 1.1 TestRadioC.nc, NONE, 1.1 TestRadioP.nc,
NONE, 1.1 suite.properties, NONE, 1.1
David Moss
mossmoss at users.sourceforge.net
Sat Jul 21 22:31:45 PDT 2007
- Previous message: [Tinyos-2-commits]
CVS: tinyos-2.x-contrib/tunit/tests/tinyos-2.x/tos/chips/cc2420/TestChannel
Makefile, NONE, 1.1 TestRadioC.nc, NONE, 1.1 TestRadioP.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/TestConfigAddressChangeAtBoot
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/TestConfigAddressChangeAfterStart
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv19699/TestConfigAddressChangeAfterStart
Added Files:
Makefile TestRadioC.nc TestRadioP.nc suite.properties
Log Message:
Moved from a flat directory structure to a project-oriented directory structure
--- NEW FILE: Makefile ---
COMPONENT=TestRadioC
include $(MAKERULES)
--- NEW FILE: TestRadioC.nc ---
#include "TestCase.h"
/**
* @author David Moss
*/
configuration TestRadioC {
}
implementation {
components
new TestCaseC() as TestActiveMessageAddressC;
components TestRadioP,
ActiveMessageC,
ActiveMessageAddressC,
CC2420ControlC,
new AMSenderC(4),
new AMReceiverC(4),
new TimerMilliC(),
new StateC(),
LedsC;
TestRadioP.SetUpOneTime -> TestActiveMessageAddressC.SetUpOneTime;
TestRadioP.TearDownOneTime -> TestActiveMessageAddressC.TearDownOneTime;
TestRadioP.TestActiveMessageAddress -> TestActiveMessageAddressC;
TestRadioP.ActiveMessageAddress -> ActiveMessageAddressC;
TestRadioP.SplitControl -> ActiveMessageC;
TestRadioP.CC2420Config -> CC2420ControlC;
TestRadioP.AMPacket -> ActiveMessageC;
TestRadioP.AMSend -> AMSenderC;
TestRadioP.Receive -> AMReceiverC;
TestRadioP.PacketAcknowledgements -> ActiveMessageC;
TestRadioP.Timer -> TimerMilliC;
TestRadioP.State -> StateC;
TestRadioP.Leds -> LedsC;
}
--- NEW FILE: TestRadioP.nc ---
#include "TestCase.h"
/**
* @author David Moss
*/
module TestRadioP {
uses {
interface TestControl as SetUpOneTime;
interface TestControl as TearDownOneTime;
interface TestCase as TestActiveMessageAddress;
interface ActiveMessageAddress;
interface SplitControl;
interface AMPacket;
interface AMSend;
interface Receive;
interface CC2420Config;
interface PacketAcknowledgements;
interface Timer<TMilli>;
interface State;
interface Leds;
}
}
implementation {
bool transmitter;
message_t myMsg;
uint8_t attempts;
uint8_t synced = 0;
enum {
S_IDLE,
S_SETUPONETIME,
S_TESTINUSEDUTYCYCLE,
S_TEARDOWNONETIME,
};
enum {
MAX_ATTEMPTS = 100,
GROUP = 50,
TRANSMIT_ID = 1000,
RECEIVE_ID = 1001,
};
/***************** Prototypes ****************/
task void sendMsg();
/***************** SetUp Events ****************/
event void SetUpOneTime.run() {
call State.forceState(S_SETUPONETIME);
transmitter = (call ActiveMessageAddress.amAddress() == 0);
attempts = 0;
call PacketAcknowledgements.requestAck(&myMsg);
if(call SplitControl.start() != SUCCESS) {
call State.toIdle();
call SetUpOneTime.done();
}
}
event void TearDownOneTime.run() {
call State.forceState(S_TEARDOWNONETIME);
if(call SplitControl.stop() != SUCCESS) {
call TearDownOneTime.done();
}
}
/***************** SplitControl Events ****************/
event void SplitControl.startDone(error_t error) {
call Leds.led2On();
call CC2420Config.setPanAddr(GROUP);
if(transmitter) {
call CC2420Config.setShortAddr(TRANSMIT_ID);
} else {
call CC2420Config.setShortAddr(RECEIVE_ID);
}
call CC2420Config.sync();
}
event void SplitControl.stopDone(error_t error) {
call Leds.led2Off();
call TearDownOneTime.done();
}
/***************** TestActiveMessageAddress Events ****************/
/**
* We just changed the node's address and group in the ActiveMessageAddress
* interface. Verify those changes got propagated to the CC2420 hardware.
*/
event void TestActiveMessageAddress.run() {
assertEquals("Wrong number of sync's", 1, synced);
assertEquals("Wrong CC2420 PAN", GROUP, call CC2420Config.getPanAddr());
assertEquals("Wrong CC2420 Tx address", TRANSMIT_ID, call CC2420Config.getShortAddr());
post sendMsg();
}
/***************** AMSend Events ****************/
event void AMSend.sendDone(message_t *msg, error_t error) {
attempts++;
if(!call PacketAcknowledgements.wasAcked(msg)) {
if(attempts > MAX_ATTEMPTS) {
assertFail("No ack! Address change failed");
call TestActiveMessageAddress.done();
return;
} else {
post sendMsg();
}
} else {
assertSuccess();
call TestActiveMessageAddress.done();
}
}
/***************** Receive Events ****************/
event message_t *Receive.receive(message_t *msg, void *payload, uint8_t len) {
return msg;
}
/***************** Don't Care Events ****************/
event void CC2420Config.syncDone( error_t error ) {
call Leds.led1On();
synced++;
call State.toIdle();
call SetUpOneTime.done();
}
async event void ActiveMessageAddress.changed() {
}
/***************** Timer Events ****************/
event void Timer.fired() {
}
/***************** Tasks ****************/
task void sendMsg() {
if(call AMSend.send(RECEIVE_ID, &myMsg, TOSH_DATA_LENGTH) != SUCCESS) {
post sendMsg();
}
}
}
--- 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 ActiveMessageAddress.changed()
@author David Moss
@description ActiveMessageAddress should change our radio's address
@exactnodes 2
@ignore mica2
@ignore mica2dot
- Previous message: [Tinyos-2-commits]
CVS: tinyos-2.x-contrib/tunit/tests/tinyos-2.x/tos/chips/cc2420/TestChannel
Makefile, NONE, 1.1 TestRadioC.nc, NONE, 1.1 TestRadioP.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/TestConfigAddressChangeAtBoot
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