[Tinyos-beta-commits] CVS: tinyos-1.x/beta/TOSSIM-CC2420/apps/TestPC2420 TestPC2420.nc, 1.1, 1.2 TestPC2420M.nc, 1.1, 1.2

Yang overbored at users.sourceforge.net
Mon May 16 00:00:59 PDT 2005


Update of /cvsroot/tinyos/tinyos-1.x/beta/TOSSIM-CC2420/apps/TestPC2420
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv668/apps/TestPC2420

Modified Files:
	TestPC2420.nc TestPC2420M.nc 
Log Message:
Lots of bug fixes/minor enhancements; used in SP; basic power measurement.


Index: TestPC2420.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/TOSSIM-CC2420/apps/TestPC2420/TestPC2420.nc,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** TestPC2420.nc	13 Mar 2005 07:23:07 -0000	1.1
--- TestPC2420.nc	16 May 2005 07:00:52 -0000	1.2
***************
*** 28,33 ****
   */
  
- includes CC2420Const;
- 
  /**
   * TestPC2420 verifies the functionality of the CC2420 HPL.
--- 28,31 ----
***************
*** 45,49 ****
    Main.StdControl -> CC2420RadioC.StdControl;
  
!   TestPC2420M.Timer -> TimerC.Timer[unique("Timer")];
    TestPC2420M.Send -> CC2420RadioC.Send;
    TestPC2420M.Receive -> CC2420RadioC.Receive;
--- 43,48 ----
    Main.StdControl -> CC2420RadioC.StdControl;
  
!   TestPC2420M.SendTimer -> TimerC.Timer[unique("Timer")];
!   TestPC2420M.ResponseTimer -> TimerC.Timer[unique("Timer")];
    TestPC2420M.Send -> CC2420RadioC.Send;
    TestPC2420M.Receive -> CC2420RadioC.Receive;

Index: TestPC2420M.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/TOSSIM-CC2420/apps/TestPC2420/TestPC2420M.nc,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** TestPC2420M.nc	13 Mar 2005 07:23:07 -0000	1.1
--- TestPC2420M.nc	16 May 2005 07:00:52 -0000	1.2
***************
*** 44,48 ****
      interface CC2420Control;
      interface MacControl;
!     interface Timer;
      interface Leds;
      interface BareSendMsg as Send;
--- 44,49 ----
      interface CC2420Control;
      interface MacControl;
!     interface Timer as SendTimer;
!     interface Timer as ResponseTimer;
      interface Leds;
      interface BareSendMsg as Send;
***************
*** 76,79 ****
--- 77,82 ----
    //
  
+ #define POWERTOSSIM
+ 
    //
    // Constants.
***************
*** 81,89 ****
  
    // Which test to run.
!   static const uint8_t testId = 1;
    // Time in ms to wait before responding to a message.
!   static const uint8_t responseDelay = 0;
    // Max length of the debug buffer.
!   static const uint8_t maxBufLen = 255;
  
    //
--- 84,94 ----
  
    // Which test to run.
!   static uint8_t testId = 1;
    // Time in ms to wait before responding to a message.
!   static uint8_t responseDelay = 0;
!   // Time in ms to wait before sending a new message.
!   static uint32_t sendDelay = 1000;
    // Max length of the debug buffer.
!   static uint8_t maxBufLen = 255;
  
    //
***************
*** 112,125 ****
    // Convenience function for outputting debug information
    void pp(const char *fmt, ...) {
! //    va_list argp;
! //    char str[maxBufLen];
! //    char timeStr[128];
! //
! //    va_start(argp, fmt);
! //    vsnprintf(str, maxBufLen, fmt, argp);
! //    va_end(argp);
! //
! //    printTime(timeStr, 128);
! //    dbg(DBG_USR2, "TEST (%s): %s\n", timeStr, str);
    }
  
--- 117,132 ----
    // Convenience function for outputting debug information
    void pp(const char *fmt, ...) {
! #ifndef POWERTOSSIM
!     va_list argp;
!     char str[maxBufLen];
!     char timeStr[128];
! 
!     va_start(argp, fmt);
!     vsnprintf(str, maxBufLen, fmt, argp);
!     va_end(argp);
! 
!     printTime(timeStr, 128);
!     dbg(DBG_USR2, "TEST (%s): %s\n", timeStr, str);
! #endif // POWERTOSSIM
    }
  
***************
*** 136,141 ****
        msg.addr = addr;
        msg.type = 0;
! //      snprintf((char*) msg.data, 15, "from %x to %x",
! //          TOS_LOCAL_ADDRESS, addr);
        return call Send.send(&msg);
      }
--- 143,152 ----
        msg.addr = addr;
        msg.type = 0;
! #ifdef POWERTOSSIM
!       memcpy(msg.data, "happy", 6);
! #else // POWERTOSSIM
!       snprintf((char*) msg.data, 15, "%x > %x",
!           TOS_LOCAL_ADDRESS, addr);
! #endif // POWERTOSSIM
        return call Send.send(&msg);
      }
***************
*** 190,194 ****
  
      if (doSend) {
!       return call Timer.start(TIMER_REPEAT, 1000);
      }
  
--- 201,205 ----
  
      if (doSend) {
!       return call SendTimer.start(TIMER_REPEAT, sendDelay);
      }
  
***************
*** 203,231 ****
     **/
    command result_t StdControl.stop() {
      p("StdControl.stop()");
      if (TOS_LOCAL_ADDRESS == 0) {
!       return call Timer.stop();
      }
!     return SUCCESS;
    }
  
    /**
!    * Send a message in response to the <code>Timer.fired</code> event.  
     *
     * @return Always returns <code>SUCCESS</code>
     **/
!   event result_t Timer.fired() {
      uint16_t addr = TOS_BCAST_ADDR;
  
!     if (isResponding) {
!       addr = 0;
!       switch (testId) {
!         case 9:
!         case 10:
!           addr = TOS_LOCAL_ADDRESS + 1;
!           break;
!       }
!       isResponding = FALSE;
!     } else {
        switch (testId) {
          case 1:
--- 214,247 ----
     **/
    command result_t StdControl.stop() {
+     result_t result = SUCCESS;
      p("StdControl.stop()");
      if (TOS_LOCAL_ADDRESS == 0) {
!       result_t sendTimerResult = call SendTimer.stop();
!       result_t responseTimerResult = call ResponseTimer.stop();
!       result = rcombine(sendTimerResult, responseTimerResult);
      }
!     return result;
    }
  
    /**
!    * Send a message in response to the <code>SendTimer.fired</code> event.  
     *
     * @return Always returns <code>SUCCESS</code>
     **/
!   event result_t SendTimer.fired() {
      uint16_t addr = TOS_BCAST_ADDR;
  
!     p("SendTimer.fired()");
! 
! //    if (isResponding) {
! //      addr = 0;
! //      switch (testId) {
! //        case 9:
! //        case 10:
! //          addr = TOS_LOCAL_ADDRESS + 1;
! //          break;
! //      }
! //      isResponding = FALSE;
! //    } else {
        switch (testId) {
          case 1:
***************
*** 242,247 ****
            addr = TOS_LOCAL_ADDRESS == 0 ? TOS_BCAST_ADDR : 0;
            break;
!       }
      }
  
      return sendMsg(addr);
--- 258,277 ----
            addr = TOS_LOCAL_ADDRESS == 0 ? TOS_BCAST_ADDR : 0;
            break;
! //      }
!     }
! 
!     return sendMsg(addr);
!   }
! 
!   event result_t ResponseTimer.fired() {
!     uint16_t addr = 0;
!     p("ResponseTimer.fired()");
!     switch (testId) {
!       case 9:
!       case 10:
!         addr = TOS_LOCAL_ADDRESS + 1;
!         break;
      }
+     isResponding = FALSE;
  
      return sendMsg(addr);
***************
*** 254,258 ****
      if (doRespond) {
        isResponding = TRUE;
!       call Timer.start(TIMER_ONE_SHOT, responseDelay);
      }
  
--- 284,288 ----
      if (doRespond) {
        isResponding = TRUE;
!       call ResponseTimer.start(TIMER_ONE_SHOT, responseDelay);
      }
  



More information about the Tinyos-beta-commits mailing list