[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

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


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

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 ---

configuration TestRadioC {
}

implementation {
  components new TestCaseC() as TestIndicatorC;
  
  components TestRadioP,
      ActiveMessageC,
      new AMSenderC(4),
      new AMReceiverC(4),
      new TimerMilliC(),
      ActiveMessageAddressC,
      CC2420TransmitC,
      LedsC;
  
  TestRadioP.SetUpOneTime -> TestIndicatorC.SetUpOneTime;
  TestRadioP.TestIndicator -> TestIndicatorC;
  TestRadioP.TearDownOneTime -> TestIndicatorC.TearDownOneTime;
  
  TestRadioP.SplitControl -> ActiveMessageC;
  TestRadioP.AMSend -> AMSenderC;
  TestRadioP.Receive -> AMReceiverC;
  TestRadioP.ByteIndicator -> CC2420TransmitC.ByteIndicator;
  TestRadioP.ActiveMessageAddress -> ActiveMessageAddressC;
  TestRadioP.Timer -> TimerMilliC;
  TestRadioP.Leds -> LedsC;
  
}

--- NEW FILE: TestRadioP.nc ---

#include "TestCase.h"

module TestRadioP {
  uses {
    interface TestControl as SetUpOneTime;
    interface TestControl as TearDownOneTime;
    
    interface TestCase as TestIndicator;
    
    interface SplitControl;
    interface AMSend;
    interface Receive;
    interface ActiveMessageAddress;
    interface ReceiveIndicator as ByteIndicator;
    interface Timer<TMilli>;
    interface Leds;
  }
}

implementation {

  uint32_t detects;
  uint32_t misses;
  bool sending;
  bool detecting;
  bool transmitter;
  message_t myMsg;
  
  /***************** Prototypes ****************/
  task void send();
  task void detect();
  
  /***************** SetUpOneTime ****************/
  event void SetUpOneTime.run() {
    detects = 0;
    misses = 0;
    detecting = FALSE;
    transmitter = FALSE;
    call SplitControl.start();
  }
  
  /***************** TearDownOneTime ***************/
  event void TearDownOneTime.run() {
    sending = FALSE;
    call SplitControl.stop();
  }
  
  /***************** SplitControl Events ****************/
  event void SplitControl.startDone(error_t error) {
    call SetUpOneTime.done();
  }
  
  event void SplitControl.stopDone(error_t error) {
    call TearDownOneTime.done();
  }
  
  /***************** Tests *****************/
  event void TestIndicator.run() {
    detecting = TRUE;
    call Timer.startOneShot(10240);
    post detect();
  }
  
  /***************** Timer Events ****************/
  event void Timer.fired() {
    if(transmitter) {
      post send();
      
    } else {
      detecting = FALSE;
      call Leds.led1Off();
      assertEquals("Too many byte detects", 0, detects);
      assertResultIsAbove("Too few byte gaps", 10000, misses);
      call TestIndicator.done();
    }
  }
  
  
  /***************** Send/Receive ****************/
  event void AMSend.sendDone(message_t *msg, error_t error) {
    call Leds.led0Off();
    call Timer.startOneShot(128);
  }
  
  event message_t *Receive.receive(message_t *msg, void *payload, uint8_t len) {
    return msg;
  }
  
  /***************** ActiveMessageAddress Events ****************/
  async event void ActiveMessageAddress.changed() {
  }
  
  /***************** Tasks ****************/
  task void send() {
    if(sending) {
      call Leds.led0On();
      if(call AMSend.send(0, &myMsg, TOSH_DATA_LENGTH) != SUCCESS) {
        post send();
      }
    }
  }
  
  task void detect() {
    call Leds.led0Toggle();
    if(call ByteIndicator.isReceiving()) {
      detects++;
      call Leds.led1On();
    } else {
      misses++;
      call Leds.led1Off();
    }
    
    if(detecting) {
      post detect(); 
    }
  }
  
}

--- 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 Energy Indicator while transmitting packets
@author David Moss
@description Verify the indicator toggles on and off as messages are sent
@exactnodes 1
@ignore mica2
@ignore mica2dot



More information about the Tinyos-2-commits mailing list