[Tinyos-beta-commits] CVS: tinyos-1.x/beta/Deluge/Deluge Deluge.h, 1.1, 1.2 DelugeM.nc, 1.1, 1.2 DelugeMetadataM.nc, 1.1, 1.2 DelugePageTransferC.nc, 1.1, 1.2 DelugePageTransferM.nc, 1.1, 1.2 DelugeStorageC.nc, 1.1, 1.2 DelugeStorageM.nc, 1.1, 1.2

Jonathan Hui jwhui at users.sourceforge.net
Mon Nov 22 18:54:08 PST 2004


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

Modified Files:
	Deluge.h DelugeM.nc DelugeMetadataM.nc DelugePageTransferC.nc 
	DelugePageTransferM.nc DelugeStorageC.nc DelugeStorageM.nc 
Log Message:
- Added support for multiple download images. Currently, there are two
downloadable slots. Adding more slots requires additional wiring, as
required by the new storage stack (HILs are wired to specific volumes
on external flash).

- Added a 2ms delay between successive sends of a data packet since a
rev.B node receiving at full speed cannot consume all messages due to
the serialized access to both flash and radio.

- Added back received data queue to reduce chance of dropping received
data. Tradeoffs are to further increase the time between data
messages, or increase memory requirements.



Index: Deluge.h
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/Deluge/Deluge/Deluge.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Deluge.h	22 Nov 2004 05:30:57 -0000	1.1
--- Deluge.h	23 Nov 2004 02:54:05 -0000	1.2
***************
*** 7,11 ****
  enum {
    DELUGE_VERSION                    = 2,
!   DELUGE_NUM_IMAGES                 = 2,
    DELUGE_MIN_ADV_PERIOD_LOG2        = 9,
    DELUGE_MAX_ADV_PERIOD_LOG2        = 20,
--- 7,11 ----
  enum {
    DELUGE_VERSION                    = 2,
!   DELUGE_NUM_IMAGES                 = 3,
    DELUGE_MIN_ADV_PERIOD_LOG2        = 9,
    DELUGE_MAX_ADV_PERIOD_LOG2        = 20,
***************
*** 30,33 ****
--- 30,34 ----
    DELUGE_IMAGE0_VOLUME              = unique("FlashVolume"),
    DELUGE_IMAGE1_VOLUME              = unique("FlashVolume"),
+   DELUGE_IMAGE2_VOLUME              = unique("FlashVolume"),
    DELUGE_DATA_OFFSET                = 128,
    DELUGE_IDENT_SIZE                 = 128,
***************
*** 35,38 ****
--- 36,40 ----
  };
  
+ /*
  typedef struct DelugeAdvTimer {
    uint32_t timer      : 24;
***************
*** 40,43 ****
--- 42,53 ----
    uint32_t overheard  : 1;
    uint8_t  newAdvs;
+ } DelugeAdvTime;r
+ */
+ 
+ typedef struct DelugeAdvTimer {
+   uint32_t timer;
+   uint8_t periodLog2;
+   bool overheard;
+   uint8_t  newAdvs;
  } DelugeAdvTimer;
  

Index: DelugeM.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/Deluge/Deluge/DelugeM.nc,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** DelugeM.nc	22 Nov 2004 05:30:57 -0000	1.1
--- DelugeM.nc	23 Nov 2004 02:54:05 -0000	1.2
***************
*** 31,39 ****
    uint8_t rebootDelay;
  
!   void setupAdvTimer(DelugeAdvTimer* timer) {
!     timer->timer = 0x1 << (timer->periodLog2-1);
!     timer->timer += call Random.rand() & (timer->timer-1);
    }
!   
    uint8_t findMinTimer() {
  
--- 31,39 ----
    uint8_t rebootDelay;
  
!   void setupAdvTimer(uint8_t timerNum) {
!     advTimers[timerNum].timer = (uint32_t)0x1 << (advTimers[timerNum].periodLog2-1);
!     advTimers[timerNum].timer += call Random.rand() & (advTimers[timerNum].timer-1);
    }
! 
    uint8_t findMinTimer() {
  
***************
*** 51,54 ****
--- 51,63 ----
    }
  
+   void updateTimers() {
+     uint8_t minTimer = findMinTimer();
+     uint8_t i;
+     for ( i = 0; i < DELUGE_NUM_TIMERS; i++ ) {
+       if (advTimers[i].timer >= advTimers[minTimer].timer)
+ 	advTimers[i].timer -= advTimers[minTimer].timer;
+     }
+   }
+ 
    void startTimer() {
      
***************
*** 94,98 ****
      for ( i = 0; i < DELUGE_NUM_TIMERS; i++ ) {
        advTimers[i].periodLog2 = DELUGE_MIN_ADV_PERIOD_LOG2;
!       setupAdvTimer(&advTimers[i]);
      }
      rebootDelay = 0;
--- 103,107 ----
      for ( i = 0; i < DELUGE_NUM_TIMERS; i++ ) {
        advTimers[i].periodLog2 = DELUGE_MIN_ADV_PERIOD_LOG2;
!       setupAdvTimer(i);
      }
      rebootDelay = 0;
***************
*** 119,123 ****
  
      uint8_t minTimer = findMinTimer();
-     uint8_t i;
  
      if (call PageTransfer.getWorkingImage() == DELUGE_INVALID_IMGNUM)
--- 128,131 ----
***************
*** 131,136 ****
      call Leds.greenToggle();
  
!     for ( i = 0; i < DELUGE_NUM_TIMERS; i++ )
!       advTimers[i].timer -= advTimers[minTimer].timer;
  
      if (!advTimers[minTimer].overheard
--- 139,143 ----
      call Leds.greenToggle();
  
!     updateTimers();
  
      if (!advTimers[minTimer].overheard
***************
*** 143,147 ****
      }
  
!     if (advTimers[minTimer].newAdvs > 0)
        advTimers[minTimer].newAdvs--;
  
--- 150,155 ----
      }
  
!     if (advTimers[minTimer].newAdvs > 0
! 	&& !call PageTransfer.isTransferring())
        advTimers[minTimer].newAdvs--;
  
***************
*** 162,166 ****
      advTimers[minTimer].overheard = 0;
      
!     setupAdvTimer(&advTimers[minTimer]);
      
      startTimer();
--- 170,174 ----
      advTimers[minTimer].overheard = 0;
      
!     setupAdvTimer(minTimer);
      
      startTimer();
***************
*** 210,218 ****
  	call PageTransfer.dataAvailable(rxAdvMsg->sourceAddr);
        break;
      }
  
!     if (cmpResult != DELUGE_IMGDESC_EQUAL) {
        advTimers[imgNum-1].periodLog2 = DELUGE_MIN_ADV_PERIOD_LOG2;
!       setupAdvTimer(&advTimers[imgNum-1]);
        startTimer();
      }
--- 218,231 ----
  	call PageTransfer.dataAvailable(rxAdvMsg->sourceAddr);
        break;
+     case DELUGE_IMGDESC_OLDER:
+     case DELUGE_IMGDESC_SMALLER:
+       advTimers[imgNum-1].newAdvs = DELUGE_NUM_NEWDATA_ADVS_REQUIRED;
+       break;
      }
  
!     if (cmpResult != DELUGE_IMGDESC_EQUAL
! 	&& advTimers[imgNum-1].periodLog2 != DELUGE_MIN_ADV_PERIOD_LOG2) {
        advTimers[imgNum-1].periodLog2 = DELUGE_MIN_ADV_PERIOD_LOG2;
!       setupAdvTimer(imgNum-1);
        startTimer();
      }
***************
*** 225,229 ****
        advTimers[imgNum-1].periodLog2 = DELUGE_MIN_ADV_PERIOD_LOG2;
        rebootDelay = DELUGE_REBOOT_DELAY;
!       setupAdvTimer(&advTimers[imgNum-1]);
        startTimer();
      }
--- 238,242 ----
        advTimers[imgNum-1].periodLog2 = DELUGE_MIN_ADV_PERIOD_LOG2;
        rebootDelay = DELUGE_REBOOT_DELAY;
!       setupAdvTimer(imgNum-1);
        startTimer();
      }
***************
*** 263,266 ****
--- 276,282 ----
      call Metadata.receivedPage(imgNum, pgNum);
      advTimers[imgNum-1].newAdvs = DELUGE_NUM_NEWDATA_ADVS_REQUIRED;    
+     advTimers[imgNum-1].periodLog2 = DELUGE_MIN_ADV_PERIOD_LOG2;
+     setupAdvTimer(imgNum-1);
+     startTimer();
      setNextPage();
      return SUCCESS;

Index: DelugeMetadataM.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/Deluge/Deluge/DelugeMetadataM.nc,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** DelugeMetadataM.nc	22 Nov 2004 05:30:57 -0000	1.1
--- DelugeMetadataM.nc	23 Nov 2004 02:54:05 -0000	1.2
***************
*** 194,197 ****
--- 194,198 ----
  	if (call MetadataRead.read(curImage, &(imgDesc[curImage])) == FAIL)
  	  post retry();
+ 	return SUCCESS;
        }
      }

Index: DelugePageTransferC.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/Deluge/Deluge/DelugePageTransferC.nc,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** DelugePageTransferC.nc	22 Nov 2004 05:30:57 -0000	1.1
--- DelugePageTransferC.nc	23 Nov 2004 02:54:05 -0000	1.2
***************
*** 41,44 ****
--- 41,45 ----
    DelugePageTransferM.ReceiveReqMsg = ReceiveReqMsg;
    DelugePageTransferM.ReqTimer -> TimerC.Timer[unique("Timer")];
+   DelugePageTransferM.SendTimer -> TimerC.Timer[unique("Timer")];
    DelugePageTransferM.SendDataMsg = SendDataMsg;
    DelugePageTransferM.SendReqMsg = SendReqMsg;

Index: DelugePageTransferM.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/Deluge/Deluge/DelugePageTransferM.nc,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** DelugePageTransferM.nc	22 Nov 2004 05:30:57 -0000	1.1
--- DelugePageTransferM.nc	23 Nov 2004 02:54:05 -0000	1.2
***************
*** 19,22 ****
--- 19,23 ----
      interface StdControl as SubControl;
      interface Timer as ReqTimer;
+     interface Timer as SendTimer;
    }
  }
***************
*** 50,56 ****
      uint8_t pktNum;
      uint8_t data[DELUGE_PKT_PAYLOAD_SIZE];
!   } ReceivedData;
  
!   ReceivedData receivedData;
  
    // state variables
--- 51,59 ----
      uint8_t pktNum;
      uint8_t data[DELUGE_PKT_PAYLOAD_SIZE];
!   } DataQEntry;
  
!   // Data Write Queue
!   DataQEntry dataQ[DELUGE_DATA_Q_SIZE];
!   uint8_t  dataQHead, dataQLen;  
  
    // state variables
***************
*** 85,89 ****
    command result_t StdControl.init() {
      changeState(S_DISABLED);
-     receivedData.pktNum = DELUGE_INVALID_PKTNUM;
      workingImgNum = DELUGE_INVALID_IMGNUM;
      workingPgNum = DELUGE_INVALID_PGNUM;
--- 88,91 ----
***************
*** 93,96 ****
--- 95,99 ----
    command result_t StdControl.start() {
      changeState(S_IDLE);
+     dataQHead = dataQLen = 0;
      return call SubControl.start();
    }
***************
*** 318,323 ****
  
    task void writeData() {
!     if (call DataWrite.write(workingImgNum, calcOffset(workingPgNum, receivedData.pktNum),
! 			     receivedData.data, DELUGE_PKT_PAYLOAD_SIZE) == FAIL)
        post writeData();
    }
--- 321,326 ----
  
    task void writeData() {
!     if (call DataWrite.write(workingImgNum, calcOffset(workingPgNum, dataQ[dataQHead].pktNum),
! 			     dataQ[dataQHead].data, DELUGE_PKT_PAYLOAD_SIZE) == FAIL)
        post writeData();
    }
***************
*** 348,352 ****
        }
  
!       if (receivedData.pktNum == DELUGE_INVALID_PKTNUM
  	  && rxDataMsg->pgNum == workingPgNum
  	  && rxDataMsg->pktNum < DELUGE_PKTS_PER_PAGE
--- 351,361 ----
        }
  
!       if (dataQLen >= DELUGE_DATA_Q_SIZE) {
! 	call Leds.set(0x5);
! 	while(1);
!       }
! 	
! 
!       if (dataQLen < DELUGE_DATA_Q_SIZE
  	  && rxDataMsg->pgNum == workingPgNum
  	  && rxDataMsg->pktNum < DELUGE_PKTS_PER_PAGE
***************
*** 359,372 ****
  	
  	// copy data
! 	receivedData.pktNum = rxDataMsg->pktNum;
! 	memcpy(receivedData.data, rxDataMsg->data, DELUGE_PKT_PAYLOAD_SIZE);
! 	if (call DataWrite.write(workingImgNum, calcOffset(workingPgNum, receivedData.pktNum),
! 				 receivedData.data, DELUGE_PKT_PAYLOAD_SIZE) == FAIL)
! 	  post writeData();
  
  	// mark packet as received in request packet
! 	BITVEC_CLEAR(pktsToReceive, receivedData.pktNum);
  	if (state == S_RECEIVING)
! 	  BITVEC_CLEAR(pReqMsg->requestedPkts, receivedData.pktNum);
  
  	// stop requests if all packets are received
--- 368,384 ----
  	
  	// copy data
! 	dataQ[(dataQHead+dataQLen)%DELUGE_DATA_Q_SIZE].pktNum = rxDataMsg->pktNum;
! 	memcpy(dataQ[(dataQHead+dataQLen)%DELUGE_DATA_Q_SIZE].data, rxDataMsg->data, DELUGE_PKT_PAYLOAD_SIZE);
! 	dataQLen++;
! 	if (dataQLen == 1) {
! 	  if (call DataWrite.write(workingImgNum, calcOffset(workingPgNum, dataQ[dataQHead].pktNum),
! 				   dataQ[dataQHead].data, DELUGE_PKT_PAYLOAD_SIZE) == FAIL)
! 	    post writeData();
! 	}
  
  	// mark packet as received in request packet
! 	BITVEC_CLEAR(pktsToReceive, rxDataMsg->pktNum);
  	if (state == S_RECEIVING)
! 	  BITVEC_CLEAR(pReqMsg->requestedPkts, rxDataMsg->pktNum);
  
  	// stop requests if all packets are received
***************
*** 430,436 ****
      }
      
!     receivedData.pktNum = DELUGE_INVALID_PKTNUM;
! 
!     if (!call BitVecUtils.indexOf(&tmp, 0, pktsToReceive, DELUGE_PKTS_PER_PAGE)) {
        imgnum_t tmpImgNum = workingImgNum;
        pgnum_t  tmpPgNum = workingPgNum;
--- 442,453 ----
      }
      
!     if (dataQLen > 0) {
!       dataQHead = (dataQHead + 1) % DELUGE_DATA_Q_SIZE;
!       dataQLen--;
!     }
!     if (dataQLen > 0) {
!       post writeData();
!     }
!     else if (!call BitVecUtils.indexOf(&tmp, 0, pktsToReceive, DELUGE_PKTS_PER_PAGE)) {
        imgnum_t tmpImgNum = workingImgNum;
        pgnum_t  tmpPgNum = workingPgNum;
***************
*** 469,472 ****
--- 486,494 ----
    }
  
+   event result_t SendTimer.fired() {
+     setupDataMsg();
+     return SUCCESS;
+   }
+ 
    event result_t SendDataMsg.sendDone(TOS_MsgPtr pMsg, result_t success) {
  
***************
*** 477,481 ****
        pDataMsg->pktNum = 0;
  
!     setupDataMsg();
  
      return SUCCESS;
--- 499,504 ----
        pDataMsg->pktNum = 0;
  
! //    setupDataMsg();
!     call SendTimer.start(TIMER_ONE_SHOT, 2);
  
      return SUCCESS;

Index: DelugeStorageC.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/Deluge/Deluge/DelugeStorageC.nc,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** DelugeStorageC.nc	22 Nov 2004 05:30:57 -0000	1.1
--- DelugeStorageC.nc	23 Nov 2004 02:54:05 -0000	1.2
***************
*** 30,37 ****
--- 30,40 ----
    Storage.Image0Volume -> FlashVolumeC.FlashVolume[DELUGE_IMAGE0_VOLUME];
    Storage.Image1Volume -> FlashVolumeC.FlashVolume[DELUGE_IMAGE1_VOLUME]; 
+   Storage.Image2Volume -> FlashVolumeC.FlashVolume[DELUGE_IMAGE2_VOLUME]; 
    Storage.Image0Read -> BlockStorageC.BlockRead[DELUGE_IMAGE0_VOLUME];
    Storage.Image1Read -> BlockStorageC.BlockRead[DELUGE_IMAGE1_VOLUME];
+   Storage.Image2Read -> BlockStorageC.BlockRead[DELUGE_IMAGE2_VOLUME];
    Storage.Image0Write -> BlockStorageC.BlockWrite[DELUGE_IMAGE0_VOLUME];
    Storage.Image1Write -> BlockStorageC.BlockWrite[DELUGE_IMAGE1_VOLUME];
+   Storage.Image2Write -> BlockStorageC.BlockWrite[DELUGE_IMAGE2_VOLUME];
  
  }

Index: DelugeStorageM.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/Deluge/Deluge/DelugeStorageM.nc,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** DelugeStorageM.nc	22 Nov 2004 05:30:57 -0000	1.1
--- DelugeStorageM.nc	23 Nov 2004 02:54:05 -0000	1.2
***************
*** 12,19 ****
--- 12,22 ----
      interface BlockRead as Image0Read;
      interface BlockRead as Image1Read;
+     interface BlockRead as Image2Read;
      interface BlockWrite as Image0Write;
      interface BlockWrite as Image1Write;
+     interface BlockWrite as Image2Write;
      interface FlashVolume as Image0Volume;
      interface FlashVolume as Image1Volume;
+     interface FlashVolume as Image2Volume;
      interface StdControl as SubControl;
    }
***************
*** 64,67 ****
--- 67,71 ----
      call Image0Volume.mount(FV_FACTORY_IMAGE);
      call Image1Volume.mount(0);
+     call Image2Volume.mount(1);
      return call SubControl.start();
    }
***************
*** 74,77 ****
--- 78,82 ----
      case 0: addr = call Image0Volume.physicalAddr(0); break;
      case 1: addr = call Image1Volume.physicalAddr(0); break;
+     case 2: addr = call Image2Volume.physicalAddr(0); break;
      default: return DELUGE_INVALID_ADDR;
      }
***************
*** 87,90 ****
--- 92,96 ----
      case 0: return call Image0Read.read(addr, buf, len);
      case 1: return call Image1Read.read(addr, buf, len);
+     case 2: return call Image2Read.read(addr, buf, len);
      }
      return FAIL;
***************
*** 95,98 ****
--- 101,105 ----
      case 0: return call Image0Write.write(addr, buf, len);
      case 1: return call Image1Write.write(addr, buf, len);
+     case 2: return call Image2Write.write(addr, buf, len);
      }
      return FAIL;
***************
*** 103,106 ****
--- 110,114 ----
      case 0: return call Image0Write.erase();
      case 1: return call Image1Write.erase();
+     case 2: return call Image2Write.erase();
      }
      return FAIL;
***************
*** 197,204 ****
--- 205,230 ----
    } 
  
+ 
+   event result_t Image2Read.readDone(result_t result) {
+     signalDone(result);
+     return SUCCESS;
+   }
+ 
+   event result_t Image2Write.writeDone(result_t result) {
+     signalDone(result);
+     return SUCCESS;
+   }
+ 
+   event result_t Image2Write.eraseDone(result_t result) { 
+     signalDone(result);
+     return SUCCESS; 
+   } 
+ 
    event result_t Image0Read.verifyDone(result_t result) { return SUCCESS; }
    event result_t Image0Write.commitDone(result_t result) { return SUCCESS; }
    event result_t Image1Read.verifyDone(result_t result) { return SUCCESS; }
    event result_t Image1Write.commitDone(result_t result) { return SUCCESS; }
+   event result_t Image2Read.verifyDone(result_t result) { return SUCCESS; }
+   event result_t Image2Write.commitDone(result_t result) { return SUCCESS; }
  
    default event result_t DataRead.readDone[uint8_t id](result_t result) { return SUCCESS; }



More information about the Tinyos-beta-commits mailing list