[Tinyos-2-commits] CVS: tinyos-2.x/tos/lib/net/Deluge Deluge.h, 1.1, 1.2 DelugeC.nc, 1.3, 1.4 DelugeMsgs.h, 1.2, 1.3 DelugeP.nc, 1.2, 1.3 ObjectTransferP.nc, 1.2, 1.3

Razvan Musaloiu-E. razvanm at users.sourceforge.net
Mon Jul 9 18:17:42 PDT 2007


Update of /cvsroot/tinyos/tinyos-2.x/tos/lib/net/Deluge
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv26582/tos/lib/net/Deluge

Modified Files:
	Deluge.h DelugeC.nc DelugeMsgs.h DelugeP.nc ObjectTransferP.nc 
Log Message:
This commit from Chieh-Jan (Mike) Liang fixes the following issues:
- Add a new command to reprogram the network (instead of motes automatically reprogram after they receive an image).
- Update the documentation to reflect the new command.
- Add README.txt files for the examples.


Index: Deluge.h
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/lib/net/Deluge/Deluge.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Deluge.h	22 May 2007 20:34:22 -0000	1.1
--- Deluge.h	10 Jul 2007 01:17:40 -0000	1.2
***************
*** 30,33 ****
--- 30,36 ----
  #include "DelugeMetadata.h"
  
+ #define DISSMSG_DISS   0
+ #define DISSMSG_REPROG 1
+ 
  enum {
    DELUGE_INVALID_UID = 0xffffffff,
***************
*** 36,39 ****
--- 39,43 ----
  
  typedef nx_struct DelugeDissemination {
+   nx_uint8_t msg_type;
    nx_uint32_t uid;      // unique id of image
    nx_uint16_t vNum;     // version num of image

Index: DelugeC.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/lib/net/Deluge/DelugeC.nc,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** DelugeC.nc	27 Jun 2007 20:04:57 -0000	1.3
--- DelugeC.nc	10 Jul 2007 01:17:40 -0000	1.4
***************
*** 38,42 ****
    components new FlashVolumeManagerC(0xAB);
    
!   DelugeP.ReprogNotify -> FlashVolumeManagerC;
    FlashVolumeManagerC.BlockRead[VOLUME_DELUGE0] -> DelugeStorageC.BlockRead[VOLUME_DELUGE0];
    FlashVolumeManagerC.BlockWrite[VOLUME_DELUGE0] -> DelugeStorageC.BlockWrite[VOLUME_DELUGE0];
--- 38,43 ----
    components new FlashVolumeManagerC(0xAB);
    
!   DelugeP.DissNotify -> FlashVolumeManagerC.DissNotify;
!   DelugeP.ReprogNotify -> FlashVolumeManagerC.ReprogNotify;
    FlashVolumeManagerC.BlockRead[VOLUME_DELUGE0] -> DelugeStorageC.BlockRead[VOLUME_DELUGE0];
    FlashVolumeManagerC.BlockWrite[VOLUME_DELUGE0] -> DelugeStorageC.BlockWrite[VOLUME_DELUGE0];

Index: DelugeMsgs.h
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/lib/net/Deluge/DelugeMsgs.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** DelugeMsgs.h	25 May 2007 17:26:12 -0000	1.2
--- DelugeMsgs.h	10 Jul 2007 01:17:40 -0000	1.3
***************
*** 43,66 ****
  
  typedef nx_struct DelugeAdvMsg {
!   nx_uint16_t       sourceAddr;
!   nx_uint8_t        version;    // Deluge Version
!   nx_uint8_t        type;
    DelugeObjDesc  objDesc;
!   nx_uint8_t        reserved;
  } DelugeAdvMsg;
  
  typedef nx_struct DelugeReqMsg {
!   nx_uint16_t     dest;
!   nx_uint16_t     sourceAddr;
!   nx_object_id_t  objid;
!   nx_page_num_t   pgNum;
!   nx_uint8_t      requestedPkts[DELUGE_PKT_BITVEC_SIZE];
  } DelugeReqMsg;
  
  typedef nx_struct DelugeDataMsg {
    nx_object_id_t objid;
!   nx_page_num_t pgNum;
!   nx_uint8_t    pktNum;
!   nx_uint8_t    data[DELUGE_PKT_PAYLOAD_SIZE];
  } DelugeDataMsg;
  
--- 43,66 ----
  
  typedef nx_struct DelugeAdvMsg {
!   nx_uint16_t    sourceAddr;
!   nx_uint8_t     version;    // Deluge Version
!   nx_uint8_t     type;
    DelugeObjDesc  objDesc;
!   nx_uint8_t     reserved;
  } DelugeAdvMsg;
  
  typedef nx_struct DelugeReqMsg {
!   nx_uint16_t    dest;
!   nx_uint16_t    sourceAddr;
!   nx_object_id_t objid;
!   nx_page_num_t  pgNum;
!   nx_uint8_t     requestedPkts[DELUGE_PKT_BITVEC_SIZE];
  } DelugeReqMsg;
  
  typedef nx_struct DelugeDataMsg {
    nx_object_id_t objid;
!   nx_page_num_t  pgNum;
!   nx_uint8_t     pktNum;
!   nx_uint8_t     data[DELUGE_PKT_PAYLOAD_SIZE];
  } DelugeDataMsg;
  

Index: DelugeP.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/lib/net/Deluge/DelugeP.nc,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** DelugeP.nc	27 Jun 2007 20:04:57 -0000	1.2
--- DelugeP.nc	10 Jul 2007 01:17:40 -0000	1.3
***************
*** 40,43 ****
--- 40,44 ----
      
  #ifdef DELUGE_BASESTATION
+     interface Notify<uint8_t> as DissNotify;
      interface Notify<uint8_t> as ReprogNotify;
  #endif
***************
*** 47,51 ****
  implementation
  {
!   uint8_t img_num;
    
    /**
--- 48,52 ----
  implementation
  {
!   //uint8_t img_num;
    
    /**
***************
*** 61,81 ****
     * Starts disseminating image information
     */
!   event void ReprogNotify.notify(uint8_t new_img_num)
    {
!     DelugeDissemination delugeDis;
!     DelugeImgDesc *imgDesc;
!     
!     imgDesc = call DelugeMetadata.getImgDesc(new_img_num);
      if (imgDesc->uid != DELUGE_INVALID_UID) {
        call ObjectTransfer.stop();
        call Leds.led0Toggle();
-       img_num = new_img_num;
        
        delugeDis.uid = imgDesc->uid;
        delugeDis.vNum = imgDesc->vNum;
!       delugeDis.imgNum = img_num;
        delugeDis.size = imgDesc->size;
        
!       call DisseminationUpdate.change(&delugeDis);   // Disseminates image information
        call ObjectTransfer.publish(delugeDis.uid,
                                    delugeDis.size,
--- 62,81 ----
     * Starts disseminating image information
     */
!   event void DissNotify.notify(uint8_t new_img_num)
    {
!     DelugeImgDesc* imgDesc = call DelugeMetadata.getImgDesc(new_img_num);
      if (imgDesc->uid != DELUGE_INVALID_UID) {
+       DelugeDissemination delugeDis;
+       
        call ObjectTransfer.stop();
        call Leds.led0Toggle();
        
        delugeDis.uid = imgDesc->uid;
        delugeDis.vNum = imgDesc->vNum;
!       delugeDis.imgNum = new_img_num;
        delugeDis.size = imgDesc->size;
+       delugeDis.msg_type = DISSMSG_DISS;
        
!       call DisseminationUpdate.change(&delugeDis);   // Disseminates command
        call ObjectTransfer.publish(delugeDis.uid,
                                    delugeDis.size,
***************
*** 83,86 ****
--- 83,101 ----
      }
    }
+   
+   event void ReprogNotify.notify(uint8_t new_img_num)
+   {
+     DelugeDissemination delugeDis;
+     
+     call Leds.led2Toggle();
+     
+     delugeDis.uid = 0;
+     delugeDis.vNum = 0;
+     delugeDis.imgNum = new_img_num;
+     delugeDis.size = 0;
+     delugeDis.msg_type = DISSMSG_REPROG;
+     
+     call DisseminationUpdate.change(&delugeDis);   // Disseminates command
+   }
  #endif
  
***************
*** 94,117 ****
      DelugeImgDesc *imgDesc = call DelugeMetadata.getImgDesc(delugeDis->imgNum);
      
!     if (imgDesc->uid == delugeDis->uid) {
!       if (imgDesc->vNum < delugeDis->vNum) {
!         img_num = delugeDis->imgNum;   // Note which image number to boot
!         call ObjectTransfer.receive(delugeDis->uid, delugeDis->size, delugeDis->imgNum);
!       }
!     } else {
!       img_num = delugeDis->imgNum;   // Note which image number to boot
!       call ObjectTransfer.receive(delugeDis->uid, delugeDis->size, delugeDis->imgNum);
      }
    }
! 
!   /**
!    * Reboots and reprograms with the newly received image
!    */
    event void ObjectTransfer.receiveDone(error_t error)
    {
      call ObjectTransfer.stop();
!     if (error == SUCCESS) {
!       call NetProg.programImgAndReboot(img_num);
!     }
    }
  
--- 109,145 ----
      DelugeImgDesc *imgDesc = call DelugeMetadata.getImgDesc(delugeDis->imgNum);
      
!     switch (delugeDis->msg_type) {
!       case DISSMSG_DISS:
!         if (imgDesc->uid == delugeDis->uid && imgDesc->uid != DELUGE_INVALID_UID) {
!           if (imgDesc->vNum < delugeDis->vNum) {
!             call ObjectTransfer.receive(delugeDis->uid, delugeDis->size, delugeDis->imgNum);
!           }
!         } else {
!           call ObjectTransfer.receive(delugeDis->uid, delugeDis->size, delugeDis->imgNum);
!         }
!         
!         break;
!       case DISSMSG_REPROG:
!         if (imgDesc->uid != DELUGE_INVALID_UID) {
!           DelugeNodeDesc nodeDesc;
!           call IFlash.read((uint8_t*)IFLASH_NODE_DESC_ADDR,
!                            &nodeDesc,
!                            sizeof(DelugeNodeDesc));   // Reads which image was just reprogrammed
!           if (nodeDesc.uid != imgDesc->uid || nodeDesc.vNum != imgDesc->vNum) {
!             call NetProg.programImgAndReboot(delugeDis->imgNum);
!           }
!         }
!         
!         break;
      }
    }
!   
    event void ObjectTransfer.receiveDone(error_t error)
    {
+     //call ObjectTransfer.publish(imgDesc->uid, imgDesc->size, imgDesc->imgNum);
      call ObjectTransfer.stop();
! //    if (error == SUCCESS) {
! //      call NetProg.programImgAndReboot(img_num);
! //    }
    }
  
***************
*** 122,135 ****
    {
      if (error == SUCCESS) {
!       // Start publishing the current image
!       DelugeImgDesc *imgDesc;
!       DelugeNodeDesc nodeDesc;
!       call IFlash.read((uint8_t*)IFLASH_NODE_DESC_ADDR,
!                        &nodeDesc,
!                        sizeof(DelugeNodeDesc));   // Reads which image was just reprogrammed
!       imgDesc = call DelugeMetadata.getImgDesc(nodeDesc.imgNum);
!       if (nodeDesc.uid == imgDesc->uid && imgDesc->uid != DELUGE_INVALID_UID) {
!         call ObjectTransfer.publish(imgDesc->uid, imgDesc->size, imgDesc->imgNum);
!       }
              
        call StdControlDissemination.start();
--- 150,163 ----
    {
      if (error == SUCCESS) {
! //      // Start publishing the current image
! //      DelugeImgDesc *imgDesc;
! //      DelugeNodeDesc nodeDesc;
! //      call IFlash.read((uint8_t*)IFLASH_NODE_DESC_ADDR,
! //                       &nodeDesc,
! //                       sizeof(DelugeNodeDesc));   // Reads which image was just reprogrammed
! //      imgDesc = call DelugeMetadata.getImgDesc(nodeDesc.imgNum);
! //      if (nodeDesc.uid == imgDesc->uid && imgDesc->uid != DELUGE_INVALID_UID) {
! //        call ObjectTransfer.publish(imgDesc->uid, imgDesc->size, imgDesc->imgNum);
! //      }
              
        call StdControlDissemination.start();

Index: ObjectTransferP.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/lib/net/Deluge/ObjectTransferP.nc,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** ObjectTransferP.nc	27 Jun 2007 20:04:57 -0000	1.2
--- ObjectTransferP.nc	10 Jul 2007 01:17:40 -0000	1.3
***************
*** 113,116 ****
--- 113,117 ----
        call DelugePageTransfer.setWorkingPage(DELUGE_INVALID_OBJID, DELUGE_INVALID_PGNUM);
        state = S_SYNC;
+       call ObjectTransfer.stop();
        call BlockWrite.sync[cont_receive_img_num]();
      }
***************
*** 210,214 ****
      
      call ObjectTransfer.stop();
-     state = S_STOPPED;
  //call StatsCollector.startStatsCollector();
      
--- 211,214 ----
***************
*** 229,238 ****
      call Timer.stop();
      call DelugePageTransfer.stop();
  //call StatsCollector.stopStatsCollector();
      
-     state = S_STOPPED;
      curObjDesc.objid = DELUGE_INVALID_OBJID;
      curObjDesc.numPgs = DELUGE_INVALID_PGNUM;
      curObjDesc.numPgsComplete = DELUGE_INVALID_PGNUM;
      
      return SUCCESS;
--- 229,239 ----
      call Timer.stop();
      call DelugePageTransfer.stop();
+     state = S_STOPPED;
  //call StatsCollector.stopStatsCollector();
      
      curObjDesc.objid = DELUGE_INVALID_OBJID;
      curObjDesc.numPgs = DELUGE_INVALID_PGNUM;
      curObjDesc.numPgsComplete = DELUGE_INVALID_PGNUM;
+     advTimers.periodLog2 = 0;
      
      return SUCCESS;
***************
*** 249,252 ****
--- 250,254 ----
          call DelugePageTransfer.setWorkingPage(curObjDesc.objid, curObjDesc.numPgsComplete);
          state = S_SYNC;
+         call ObjectTransfer.stop();
          call BlockWrite.sync[cont_receive_img_num]();
        }
***************
*** 257,263 ****
    {
      if (state == S_SYNC) {
-       if (error != SUCCESS) {
-         call Leds.led2On();
-       }
        post signalObjRecvDone();
      }
--- 259,262 ----
***************
*** 318,322 ****
      
    event void Timer.fired()
!   {
      updateTimers();
      
--- 317,321 ----
      
    event void Timer.fired()
!   {    
      updateTimers();
      



More information about the Tinyos-2-commits mailing list