[Tinyos-2-commits] CVS: tinyos-2.x-contrib/tunit/tests/tinyos-2.x/tos/chips/cc2420/TestCancelCC2420Transmit CC2420TransmitC.nc, NONE, 1.1 Makefile, NONE, 1.1 TestCancelC.nc, NONE, 1.1 TestCancelP.nc, NONE, 1.1 suite.properties, NONE, 1.1

David Moss mossmoss at users.sourceforge.net
Fri Sep 28 10:54:53 PDT 2007


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

Added Files:
	CC2420TransmitC.nc Makefile TestCancelC.nc TestCancelP.nc 
	suite.properties 
Log Message:
Fixed CC2420Transmit.cancel(), added two unit test suites verifying functionality.  Mischa Weise discovered sendDone wasn't signaled when cancel() was called.

--- NEW FILE: CC2420TransmitC.nc ---

/**
 * Just copied the CC2420TransmitC over, and wired the CCA pin to TestCancelP.
 */
 
#include "IEEE802154.h"

configuration CC2420TransmitC {

  provides {
    interface StdControl;
    interface CC2420Transmit;
    interface RadioBackoff;
    interface RadioTimeStamping;
    interface ReceiveIndicator as EnergyIndicator;
    interface ReceiveIndicator as ByteIndicator;
  }
}

implementation {

  components CC2420TransmitP;
  components TestCancelP;
  CC2420TransmitP.CCA -> TestCancelP.CcaProvider;
   
   
  StdControl = CC2420TransmitP;
  CC2420Transmit = CC2420TransmitP;
  RadioBackoff = CC2420TransmitP;
  RadioTimeStamping = CC2420TransmitP;
  EnergyIndicator = CC2420TransmitP.EnergyIndicator;
  ByteIndicator = CC2420TransmitP.ByteIndicator;

  components MainC;
  MainC.SoftwareInit -> CC2420TransmitP;
  MainC.SoftwareInit -> Alarm;
  
  components AlarmMultiplexC as Alarm;
  CC2420TransmitP.BackoffTimer -> Alarm;

  components HplCC2420PinsC as Pins;
  CC2420TransmitP.CSN -> Pins.CSN;
  CC2420TransmitP.SFD -> Pins.SFD;

  components HplCC2420InterruptsC as Interrupts;
  CC2420TransmitP.CaptureSFD -> Interrupts.CaptureSFD;

  components new CC2420SpiC() as Spi;
  CC2420TransmitP.SpiResource -> Spi;
  CC2420TransmitP.ChipSpiResource -> Spi;
  CC2420TransmitP.SNOP        -> Spi.SNOP;
  CC2420TransmitP.STXON       -> Spi.STXON;
  CC2420TransmitP.STXONCCA    -> Spi.STXONCCA;
  CC2420TransmitP.SFLUSHTX    -> Spi.SFLUSHTX;
  CC2420TransmitP.TXCTRL      -> Spi.TXCTRL;
  CC2420TransmitP.TXFIFO      -> Spi.TXFIFO;
  CC2420TransmitP.TXFIFO_RAM  -> Spi.TXFIFO_RAM;
  CC2420TransmitP.MDMCTRL1    -> Spi.MDMCTRL1;
  
  components CC2420ReceiveC;
  CC2420TransmitP.CC2420Receive -> CC2420ReceiveC;
  
  components CC2420PacketC;
  CC2420TransmitP.CC2420Packet -> CC2420PacketC;
  CC2420TransmitP.CC2420PacketBody -> CC2420PacketC;
  
  components LedsC;
  CC2420TransmitP.Leds -> LedsC;
}

--- NEW FILE: Makefile ---
COMPONENT=TestCancelC
include $(MAKERULES)


--- NEW FILE: TestCancelC.nc ---


configuration TestCancelC {
}

implementation {
  components new TestCaseC() as TestCancelAtCongestionBackoffC;
  
  
  components CC2420TransmitC,
      CC2420ActiveMessageC,
      CC2420PacketC,
      TestCancelP;
      
  TestCancelP.RadioBackoff -> CC2420TransmitC;
  TestCancelP.CC2420Transmit -> CC2420TransmitC;
  TestCancelP.CC2420PacketBody -> CC2420PacketC;
  TestCancelP.SplitControl -> CC2420ActiveMessageC;

  TestCancelP.SetUpOneTime -> TestCancelAtCongestionBackoffC.SetUpOneTime;
  TestCancelP.TearDownOneTime -> TestCancelAtCongestionBackoffC.TearDownOneTime;
  
  TestCancelP.TestCancelAtCongestionBackoff -> TestCancelAtCongestionBackoffC;
}


--- NEW FILE: TestCancelP.nc ---

#include "TestCase.h"
#include "AM.h"
#include "message.h"

/**
 * Test one basic case of cancel.  This doesn't cover all the cases, but 
 * does cover Mischa Weise's bug discovery.
 * @author David Moss
 */
 
module TestCancelP {
  provides {
    interface GeneralIO as CcaProvider;
  }
  
  uses {
    interface TestControl as SetUpOneTime;
    interface TestControl as TearDownOneTime;
    
    interface TestCase as TestCancelAtCongestionBackoff;
    
    interface SplitControl;
    interface CC2420Transmit;
    interface CC2420PacketBody;
    interface RadioBackoff;
  }
}

implementation {

  message_t myMsg;
  
  /***************** Test Control ****************/
  event void SetUpOneTime.run() {
    call SplitControl.start();
  }
  
  event void TearDownOneTime.run() {
    call SplitControl.stop();
  }
  
  event void SplitControl.startDone(error_t error) {
    call SetUpOneTime.done();
  }
  
  event void SplitControl.stopDone(error_t error) {
    call TearDownOneTime.done();
  }
  
  /***************** Tests ****************/
  event void TestCancelAtCongestionBackoff.run() {
    (call CC2420PacketBody.getHeader(&myMsg))->length = 20;
    call CC2420Transmit.send(&myMsg, TRUE);
    // Execution continues at requestCongestionBackoff
  }
  
  
  /***************** RadioBackoff Events ****************/
  async event void RadioBackoff.requestInitialBackoff(message_t *msg) {
  }

  async event void RadioBackoff.requestCongestionBackoff(message_t *msg) {
    assertEquals("Cancel ERROR", SUCCESS, call CC2420Transmit.cancel());
    // Execution continues at sendDone
  }

  async event void RadioBackoff.requestCca(message_t *msg) {
  }
  
  /***************** CC2420Transmit Events ****************/
  async event void CC2420Transmit.sendDone( message_t* p_msg, error_t error ) {
    assertEquals("sendDone wasn't ECANCEL", ECANCEL, error);
    if(p_msg != &myMsg) {
      assertFail("sendDone(*msg) != &myMsg");
    }
    
    call TestCancelAtCongestionBackoff.done();
  }
  
  
  /***************** CcaProvider Commands ****************/
  /**
   * Our line is always low, i.e. there's always a transmitter nearby
   */
  async command void CcaProvider.set() {
  }
  
  async command void CcaProvider.clr() {
  }
  
  async command void CcaProvider.toggle() {
  }
  
  async command bool CcaProvider.get() {
    return FALSE;
  }
  
  async command void CcaProvider.makeInput() {
  }
  
  async command bool CcaProvider.isInput() {
    return TRUE;
  }
  
  async command void CcaProvider.makeOutput() {
  }
  
  async command bool CcaProvider.isOutput() {
    return FALSE;
  }
}


--- 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 the ability to cancel
@author David Moss
@description Verify we can cancel and get a sendDone event when the radio 
    requests a congestion backoff.  We force the congestion backoff to happen.
@exactnodes 1
@ignore mica2
@ignore mica2dot



More information about the Tinyos-2-commits mailing list