[Tinyos-beta-commits] CVS: tinyos-1.x/beta/Deluge/Deluge DelugeM.nc, 1.9, 1.10 DelugePageTransferM.nc, 1.6, 1.7 SharedMsgBuf.nc, 1.1, 1.2 SharedMsgBufM.nc, 1.1, 1.2

Jonathan Hui jwhui at users.sourceforge.net
Mon Mar 14 22:24:35 PST 2005


Update of /cvsroot/tinyos/tinyos-1.x/beta/Deluge/Deluge
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22049/Deluge

Modified Files:
	DelugeM.nc DelugePageTransferM.nc SharedMsgBuf.nc 
	SharedMsgBufM.nc 
Log Message:
- Minor code cleanup.



Index: DelugeM.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/Deluge/Deluge/DelugeM.nc,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** DelugeM.nc	11 Mar 2005 21:46:37 -0000	1.9
--- DelugeM.nc	15 Mar 2005 06:24:32 -0000	1.10
***************
*** 157,160 ****
--- 157,161 ----
    command result_t StdControl.start() {
      result_t result;
+ 
      result = call PageTransferControl.start();
  
***************
*** 196,199 ****
--- 197,211 ----
    }
  
+   void sendAdvMsg(uint8_t imgNum, uint16_t addr) {
+     if (!call SharedMsgBuf.isLocked()) {
+       TOS_MsgPtr pMsgBuf = call SharedMsgBuf.getMsgBuf();
+       fillAdvMsg(imgNum, (DelugeAdvMsg*)pMsgBuf->data);
+       if (call SendAdvMsg.send(addr, sizeof(DelugeAdvMsg), pMsgBuf) == SUCCESS) {
+ 	call Leds.greenToggle();
+ 	call SharedMsgBuf.lock();
+       }
+     }
+   }
+ 
    event result_t Timer.fired() {
  
***************
*** 210,222 ****
      updateTimers();
  
!     if (!advTimers[minTimer].overheard
! 	&& !call SharedMsgBuf.isLocked()) {
!       TOS_MsgPtr pMsgBuf = call SharedMsgBuf.getMsgBuf();
!       fillAdvMsg(minTimer+1, (DelugeAdvMsg*)(pMsgBuf->data));
!       if (call SendAdvMsg.send(TOS_BCAST_ADDR, sizeof(DelugeAdvMsg), pMsgBuf) == SUCCESS) {
! 	call Leds.greenToggle();
! 	call SharedMsgBuf.lock();
!       }
!     }
  
      if (call PageTransfer.isTransferring())
--- 222,227 ----
      updateTimers();
  
!     if (!advTimers[minTimer].overheard)
!       sendAdvMsg(minTimer+1, TOS_BCAST_ADDR);
  
      if (call PageTransfer.isTransferring())
***************
*** 276,285 ****
  	   && rxAdvMsg->nodeDesc.imgNum == DELUGE_INVALID_IMGNUM)
  	  || (cmpResult == DELUGE_IMGDESC_EQUAL)) {
! 	if (!call SharedMsgBuf.isLocked()) {
! 	  TOS_MsgPtr pMsgBuf = call SharedMsgBuf.getMsgBuf();
! 	  fillAdvMsg(imgNum, (DelugeAdvMsg*)pMsgBuf->data);
! 	  if (call SendAdvMsg.send(rxAdvMsg->sourceAddr, sizeof(DelugeAdvMsg), pMsgBuf) == SUCCESS)
! 	    call SharedMsgBuf.lock();
! 	}
  	return pMsg;
        }
--- 281,285 ----
  	   && rxAdvMsg->nodeDesc.imgNum == DELUGE_INVALID_IMGNUM)
  	  || (cmpResult == DELUGE_IMGDESC_EQUAL)) {
! 	sendAdvMsg(imgNum, rxAdvMsg->sourceAddr);
  	return pMsg;
        }
***************
*** 367,371 ****
    }
  
!   event result_t SharedMsgBuf.bufFree() { return SUCCESS; }
  
  }
--- 367,371 ----
    }
  
!   event void SharedMsgBuf.bufFree() { ; }
  
  }

Index: DelugePageTransferM.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/Deluge/Deluge/DelugePageTransferM.nc,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** DelugePageTransferM.nc	11 Mar 2005 21:46:38 -0000	1.6
--- DelugePageTransferM.nc	15 Mar 2005 06:24:32 -0000	1.7
***************
*** 192,199 ****
  
      if (state == S_TX_LOCKING) {
!       if (call SharedMsgBuf.lock() == FAIL) {
! 	post retrySetupDataMsg();
  	return;
-       }
        changeState(S_SENDING);
        pDataMsg->vNum = call Metadata.getVNum(vars.tx.imgToSend);
--- 192,197 ----
  
      if (state == S_TX_LOCKING) {
!       if (call SharedMsgBuf.lock() == FAIL)
  	return;
        changeState(S_SENDING);
        pDataMsg->vNum = call Metadata.getVNum(vars.tx.imgToSend);
***************
*** 222,226 ****
    }
  
!   event result_t ReqTimer.fired() {
  
      TOS_MsgPtr pMsgBuf = call SharedMsgBuf.getMsgBuf();
--- 220,224 ----
    }
  
!   void setupReqMsg() {
  
      TOS_MsgPtr pMsgBuf = call SharedMsgBuf.getMsgBuf();
***************
*** 228,238 ****
  
      if (state != S_RECEIVING && state != S_RX_LOCKING)
!       return SUCCESS;
  
      if (state == S_RX_LOCKING) {
!       if (call SharedMsgBuf.lock() == FAIL) {
! 	call ReqTimer.start(TIMER_ONE_SHOT, DELUGE_FAILED_SEND_DELAY);	
! 	return SUCCESS;
!       }
        // update address of source node
        changeState(S_RECEIVING);
--- 226,234 ----
  
      if (state != S_RECEIVING && state != S_RX_LOCKING)
!       return;
  
      if (state == S_RX_LOCKING) {
!       if (call SharedMsgBuf.lock() == FAIL)
! 	return;
        // update address of source node
        changeState(S_RECEIVING);
***************
*** 251,255 ****
  			  call Random.rand() % DELUGE_NACK_TIMEOUT);
        vars.rx.suppressReq = FALSE;
!       return SUCCESS;
      }
  
--- 247,251 ----
  			  call Random.rand() % DELUGE_NACK_TIMEOUT);
        vars.rx.suppressReq = FALSE;
!       return;
      }
  
***************
*** 257,261 ****
        // tried too many times, give up
        changeState(S_IDLE);
!       return SUCCESS;
      }
  
--- 253,257 ----
        // tried too many times, give up
        changeState(S_IDLE);
!       return;
      }
  
***************
*** 271,276 ****
      }
  
!     return SUCCESS;
  
    }
  
--- 267,275 ----
      }
  
!   }
  
+   event result_t ReqTimer.fired() {
+     setupReqMsg();
+     return SUCCESS;
    }
  
***************
*** 310,315 ****
      if (rxReqMsg->dest != TOS_LOCAL_ADDRESS) {
        if ((state == S_RECEIVING || state == S_RX_LOCKING)
! 	  && rxReqMsg->imgNum == workingImgNum
! 	  && rxReqMsg->vNum == call Metadata.getVNum(workingImgNum)
  	  && rxReqMsg->pgNum <= workingPgNum) {
  	// suppress next request since similar request has been overheard
--- 309,313 ----
      if (rxReqMsg->dest != TOS_LOCAL_ADDRESS) {
        if ((state == S_RECEIVING || state == S_RX_LOCKING)
! 	  && rxReqMsg->imgNum <= workingImgNum
  	  && rxReqMsg->pgNum <= workingPgNum) {
  	// suppress next request since similar request has been overheard
***************
*** 363,368 ****
  	rxDataMsg->vNum, rxDataMsg->imgNum, rxDataMsg->pgNum, rxDataMsg->pktNum);
  
!     if (state == S_DISABLED
! 	|| workingImgNum == DELUGE_INVALID_IMGNUM)
        return pMsg;
  
--- 361,365 ----
  	rxDataMsg->vNum, rxDataMsg->imgNum, rxDataMsg->pgNum, rxDataMsg->pktNum);
  
!     if (state == S_DISABLED)
        return pMsg;
  
***************
*** 377,380 ****
--- 374,378 ----
  
        if (dataQLen < DELUGE_DATA_Q_SIZE
+ 	  && rxDataMsg->imgNum == workingImgNum
  	  && rxDataMsg->pgNum == workingPgNum
  	  && rxDataMsg->pktNum < DELUGE_PKTS_PER_PAGE
***************
*** 497,500 ****
--- 495,505 ----
    }
  
+   event void SharedMsgBuf.bufFree() { 
+     if (state == S_TX_LOCKING)
+       setupDataMsg();
+     else if (state == S_RX_LOCKING) 
+       setupReqMsg();
+   }
+ 
    event void DataRead.verifyDone(storage_result_t result) { ; }
    event void DataWrite.eraseDone(storage_result_t result) { ; }
***************
*** 502,506 ****
    event void Metadata.receivedPageDone(result_t result) { ; }
  
-   event result_t SharedMsgBuf.bufFree() { return SUCCESS; }
- 
  }
--- 507,509 ----

Index: SharedMsgBuf.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/Deluge/Deluge/SharedMsgBuf.nc,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** SharedMsgBuf.nc	22 Nov 2004 05:30:57 -0000	1.1
--- SharedMsgBuf.nc	15 Mar 2005 06:24:32 -0000	1.2
***************
*** 67,75 ****
     * Signal that the bus is free to allow other components waiting to
     * begin using it right away.
-    *
-    * @return <code>SUCCESS</code> on success,
-    *         <code>FAIL</code> otherwise.
     */
!   event result_t bufFree();
  
  }
--- 67,72 ----
     * Signal that the bus is free to allow other components waiting to
     * begin using it right away.
     */
!   event void bufFree();
  
  }

Index: SharedMsgBufM.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/Deluge/Deluge/SharedMsgBufM.nc,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** SharedMsgBufM.nc	22 Nov 2004 05:30:57 -0000	1.1
--- SharedMsgBufM.nc	15 Mar 2005 06:24:32 -0000	1.2
***************
*** 77,80 ****
--- 77,81 ----
        return FAIL;
      BITVEC_CLEAR(lockedMsgBufs, id);
+     signal SharedMsgBuf.bufFree[id]();
      return SUCCESS;
    }
***************
*** 86,90 ****
    }
  
!   default event result_t SharedMsgBuf.bufFree[uint8_t id]() { return SUCCESS; }
  
  }
--- 87,91 ----
    }
  
!   default event void SharedMsgBuf.bufFree[uint8_t id]() { ; }
  
  }



More information about the Tinyos-beta-commits mailing list