[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

David Moss mossmoss at users.sourceforge.net
Sat Jul 21 22:31:45 PDT 2007


Update of /cvsroot/tinyos/tinyos-2.x-contrib/tunit/tests/tinyos-2.x/tos/chips/cc2420/TestChannel
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv19699/TestChannel

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 TestChangeFrequencyC;
      
  components TestRadioP,
      ActiveMessageC,
      new AMSenderC(4),
      new AMReceiverC(4),
      new TimerMilliC(),
      new StateC(),
      CC2420ControlC,
      LedsC;

  TestRadioP.SetUpOneTime -> TestChangeFrequencyC.SetUpOneTime;
  TestRadioP.TearDownOneTime -> TestChangeFrequencyC.TearDownOneTime;
  
  TestRadioP.TestChangeFrequency -> TestChangeFrequencyC;
  TestRadioP.SplitControl -> ActiveMessageC;
  TestRadioP.PacketAcknowledgements -> ActiveMessageC;
  TestRadioP.AMSend -> AMSenderC;
  TestRadioP.Receive -> AMReceiverC;
  TestRadioP.Timer -> TimerMilliC;
  TestRadioP.State -> StateC;
  TestRadioP.CC2420Config -> CC2420ControlC;
  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 TestChangeFrequency;
    interface SplitControl;
    interface CC2420Config;
    interface PacketAcknowledgements;
    interface AMSend;
    interface Receive;
    interface Timer<TMilli>;
    interface State;
    interface Leds;
  }
}

implementation {

  message_t myMsg;

  uint16_t misses;
  
  enum {
    S_IDLE,
    S_SETUPONETIME,
    S_TESTCHANGEFREQUENCY,
  };
  
  enum {
    MIN_CHANNEL = 11,
    MAX_CHANNEL = 26,
    MAX_MISSES = 50,
  };
  

  /***************** Prototypes ****************/
  task void changeChannel();
  task void send();
  
  /***************** SetUp Events ****************/
  event void SetUpOneTime.run() {
    call PacketAcknowledgements.requestAck(&myMsg);
    call State.forceState(S_SETUPONETIME);
    call SplitControl.start();
  }
  
  event void TearDownOneTime.run() {
    call SplitControl.stop();
  }
  
  /***************** SplitControl Events ****************/
  event void SplitControl.startDone(error_t error) {
    call CC2420Config.setChannel(MIN_CHANNEL);
    call CC2420Config.sync();
  }
  
  event void SplitControl.stopDone(error_t error) {
    call TearDownOneTime.done();
  }
  
  event void CC2420Config.syncDone(error_t error) {
    call Leds.led1Toggle();
    
    if(call State.isState(S_SETUPONETIME)) {
      call State.toIdle();
      call SetUpOneTime.done();
    }
    
    if(call State.isState(S_TESTCHANGEFREQUENCY)) {
      post send();
    }
  }
  
  
  /***************** Tests ****************/
  event void TestChangeFrequency.run() {
    call State.forceState(S_TESTCHANGEFREQUENCY);
    post send();
  }
    
  /***************** AMSend Events ****************/
  event void AMSend.sendDone(message_t *msg, error_t error) {
    call Leds.led2Toggle();
    if(!call PacketAcknowledgements.wasAcked(msg)) {
      misses++;
      if(misses > MAX_MISSES) {
        assertFail("Didn't get a response");
        call TestChangeFrequency.done();
        return;
      
      } else {
        post send();
      }
      
    } else {
      if(call CC2420Config.getChannel() < 26) {
        post changeChannel();
      } else {
        assertSuccess();
        call TestChangeFrequency.done();
      }
    }
  }
  
  /***************** Receive Events ****************/
  event message_t *Receive.receive(message_t *msg, void *payload, uint8_t len) {
    if(call CC2420Config.getChannel() < 26) {
      post changeChannel(); 
    }
    
    return msg;
  }
  
  /***************** Timer Events ****************/
  event void Timer.fired() {
  }
  
  /***************** Tasks ****************/
  task void send() {
    if(call AMSend.send(1, &myMsg, TOSH_DATA_LENGTH) != SUCCESS) {
      post send();
    }
  }
  
  task void changeChannel() {
    misses = 0;
    call CC2420Config.setChannel(call CC2420Config.getChannel() + 1);
    call CC2420Config.sync();
  }
}

--- 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 Frequency Hopping
@author David Moss
@description Move through all channels and assert acks
@exactnodes 2
@ignore mica2
@ignore mica2dot



More information about the Tinyos-2-commits mailing list