[Tinyos-beta-commits] CVS: tinyos-1.x/beta/Drain DrainC.nc, 1.5, 1.6 DrainLinkEstM.nc, 1.8, 1.9 DrainM.nc, 1.6, 1.7

Gilman Tolle gtolle at users.sourceforge.net
Tue Apr 26 17:21:29 PDT 2005


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

Modified Files:
	DrainC.nc DrainLinkEstM.nc DrainM.nc 
Log Message:
Took out the partially-complete system for routing down the tree. I'll add it back in later when it works. Improved the UI and display for Drain and DrainConnector. Made TestDrain work again.

Index: DrainC.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/Drain/DrainC.nc,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** DrainC.nc	15 Mar 2005 01:19:13 -0000	1.5
--- DrainC.nc	27 Apr 2005 00:21:27 -0000	1.6
***************
*** 55,60 ****
--- 55,62 ----
    DrainLinkEstM.Leds -> LedsC;
  
+ #ifdef DRAIN_DOWN_ROUTE
    DrainLinkEstM.SendRegisterMsg -> GenericComm.SendMsg[AM_DRAINREGISTERMSG];
    DrainLinkEstM.ReceiveRegisterMsg -> GenericComm.ReceiveMsg[AM_DRAINREGISTERMSG];
+ #endif
  
  #ifdef _CC2420CONST_H

Index: DrainLinkEstM.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/Drain/DrainLinkEstM.nc,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** DrainLinkEstM.nc	16 Mar 2005 02:19:32 -0000	1.8
--- DrainLinkEstM.nc	27 Apr 2005 00:21:27 -0000	1.9
***************
*** 33,36 ****
--- 33,37 ----
   */
  
+ includes Attrs;
  
  module DrainLinkEstM {
***************
*** 42,48 ****
      interface Attr<uint16_t> as DrainNextHopCost @nucleusAttr();
      interface Attr<uint16_t> as DrainNextHopLinkEst @nucleusAttr();
-     interface AttrList<uint16_t> as DrainChildren @nucleusAttr();
-     interface Attr<uint8_t> as DrainChildrenCount @nucleusAttr();
-     interface Attr<uint16_t> as DrainToAddr @nucleusAttr();
    }
  
--- 43,46 ----
***************
*** 55,61 ****
      interface ReceiveMsg;
  
-     interface SendMsg as SendRegisterMsg;
-     interface ReceiveMsg as ReceiveRegisterMsg;
- 
      interface Leds;
    }
--- 53,56 ----
***************
*** 66,81 ****
    DrainRouteEntry routes[DRAIN_MAX_ROUTES];
  
-   uint16_t toAddr;
-   uint16_t children[DRAIN_MAX_CHILDREN];
-   uint8_t  childrenToNotify;
-   uint8_t  toAddrLength;
- 
-   uint16_t unwantedChild;
- 
-   // STATISTICS
- 
-   uint8_t  regAttempts;
-   uint8_t  regFires;
- 
    bool msgBufBusy;
    TOS_Msg msgBuf;
--- 61,64 ----
***************
*** 93,98 ****
  
    task void SendRouteTask();
-   task void SendRegisterTask();
-   task void NotifyChildrenTask();
  
    command result_t StdControl.init() {
--- 76,79 ----
***************
*** 146,159 ****
    }
  
-   void clearChildren() {
-     uint8_t i;
-     toAddr = 0;
-     regFires = 0;
-     regAttempts = 0;
-     for(i = 0; i < DRAIN_MAX_CHILDREN; i++) {
-       children[i] = 0;
-     }
-   }
- 
    command result_t StdControl.start() {
  #ifdef PLATFORM_PC
--- 127,130 ----
***************
*** 250,260 ****
        }
  
-     } else {
-       
-       uint8_t pos = pMHMsg->dest & 0x7; // Assumes 3 bits per hop
-       uint16_t dest = children[pos];
-       
-       Msg->addr = dest;
-       pMHMsg->dest = pMHMsg->dest >> 2;
      }
  
--- 221,224 ----
***************
*** 285,289 ****
      if (route == NULL) {
        route = newRoute(pRP->source);
-       clearChildren();
      }
  
--- 249,252 ----
***************
*** 344,349 ****
        route->treeInstance = pRP->treeInstance;
  
-       clearChildren();
- 
      } else {
        
--- 307,310 ----
***************
*** 367,371 ****
  	  route->destDistance = DRAIN_MAX_TTL - pRP->ttl;
  
- 	  clearChildren();
  	}
      }
--- 328,331 ----
***************
*** 386,401 ****
        route->sentRoute = TRUE;
        post SendRouteTask();
-       call Timer.start(TIMER_REPEAT, 1024 * 2 * route->announceDelay);
-     } else {
-       regFires++;
-       if (regFires > DRAIN_MAX_REG_ATTEMPTS) {
- 	call Timer.stop();
-       }
- #ifdef PLATFORM_PC
-       if (TOS_LOCAL_ADDRESS != 0)
- #endif
- 	post SendRegisterTask();
      }
! 
      return SUCCESS;
    }
--- 346,351 ----
        route->sentRoute = TRUE;
        post SendRouteTask();
      }
!     
      return SUCCESS;
    }
***************
*** 447,608 ****
    }
  
-   task void SendRegisterTask() {
- 
-     TOS_MsgPtr pMsgBuf = &msgBuf;
-     DrainRegisterMsg *pRM = (DrainRegisterMsg *)&pMsgBuf->data[0];
-     DrainRouteEntry *route = &routes[0];
-     
-     dbg(DBG_ROUTE,"DrainLinkEstM: Sending Registration Msg\n");
-     
-     if (msgBufBusy) {
- #ifndef PLATFORM_PC
-       post SendRegisterTask();
- #endif
-       return;
-     }
- 
-     atomic msgBufBusy = TRUE;
- 
-     pRM->linkSource = TOS_LOCAL_ADDRESS;
-     pRM->destAddr = 0;
-     pRM->op = DRAIN_REGISTER_OP_JOIN;
- 
-     if (call SendRegisterMsg.send(route->nextHop, sizeof(DrainRegisterMsg), pMsgBuf)) {
- 
-       dbg(DBG_ROUTE,"to %d, send DrainRegisterMsg(linkSource=%d,destAddr=%d,op=%d)\n",
- 	  route->nextHop, pRM->linkSource, pRM->destAddr, pRM->op);
-       
-       regAttempts++;
- 
-     } else {
-       dbg(DBG_ROUTE, "send DrainRegisterMsg FAILED\n");
- #ifndef PLATFORM_PC
-       post SendRegisterTask();
- #endif
-       atomic msgBufBusy = FALSE;
-     }
-   }
- 
-   event TOS_MsgPtr ReceiveRegisterMsg.receive(TOS_MsgPtr Msg) {
- 
-     DrainRegisterMsg *pRM = (DrainRegisterMsg *)&Msg->data[0];
-     uint8_t i;
-     DrainRouteEntry *route = &routes[0];
- 
-     dbg(DBG_ROUTE,"receive DrainRegisterMsg(linkSource=%d,destAddr=%d,op=%d)\n",
- 	pRM->linkSource, pRM->destAddr, pRM->op);
- 
-     if (pRM->op == DRAIN_REGISTER_OP_JOIN) {
- 
-       for(i = 1; i < DRAIN_MAX_CHILDREN; i++) {
- 	if (children[i] == DRAIN_INVALID_DEST || 
- 	    children[i] == pRM->linkSource) {
- 	  children[i] = pRM->linkSource;
- 	  childrenToNotify = BIT_SET(childrenToNotify, i);
- 	  dbg(DBG_ROUTE, "new child: index=%d, address=%d\n",
- 	      i, children[i]);
- 	  break;
- 	}
-       }
-       
-       // we're full. inform the child.
- 
-       unwantedChild = pRM->linkSource;
- 
-     } else if (pRM->op == DRAIN_REGISTER_OP_JOINED) {
- 
-       if (pRM->linkSource == route->nextHop) {
- 	call Timer.stop();
- 	toAddr = pRM->destAddr;
- 	toAddrLength = pRM->addrLength;
-       }
- 
-     } else if (pRM->op == DRAIN_REGISTER_OP_FULL) {
- 
-       if (pRM->linkSource == route->nextHop) {
- 	call Timer.stop();
-       }      
- 
-     }
-     
-     post NotifyChildrenTask();
- 
-     return Msg;
-   }
- 
-   task void NotifyChildrenTask() {
- 
-     TOS_MsgPtr pMsgBuf = &msgBuf;
-     DrainRegisterMsg *pRM = (DrainRegisterMsg *)&pMsgBuf->data[0];
-     uint8_t i;
-     result_t result = FAIL;
- 
-     dbg(DBG_ROUTE,"DrainLinkEstM: Sending Registration Msg\n");
-     
-     if (toAddr == DRAIN_INVALID_DEST) {
-       return;
-     }
-     
-     if (unwantedChild == DRAIN_INVALID_DEST && childrenToNotify == 0) {
-       return;
-     }
-     
-     if (msgBufBusy) {
- #ifndef PLATFORM_PC
-       post NotifyChildrenTask();
- #endif
-       return;
-     }
-     
-     atomic msgBufBusy = TRUE;
- 
-     if (unwantedChild) {
- 
- 	pRM->linkSource = TOS_LOCAL_ADDRESS;
- 	pRM->op = DRAIN_REGISTER_OP_FULL;
- 	
- 	result = call SendRegisterMsg.send(unwantedChild, 
- 					   sizeof(DrainRegisterMsg), 
- 					   pMsgBuf);
- 	if (result == SUCCESS) {
- 	  unwantedChild = DRAIN_INVALID_DEST;
- 	}
- 	
-     } else {
- 
-       for(i = 0; i < DRAIN_MAX_CHILDREN; i++) {
- 	
- 	if (BIT_GET(childrenToNotify, i)) {
- 	  
- 	  pRM->linkSource = TOS_LOCAL_ADDRESS;
- 	  pRM->destAddr = (i << toAddrLength) + toAddr;
- 	  pRM->op = DRAIN_REGISTER_OP_JOINED;
- 	  
- 	  result = call SendRegisterMsg.send(children[i], 
- 					     sizeof(DrainRegisterMsg), 
- 					     pMsgBuf);
- 	  
- 	  if (result == SUCCESS) {
- 	    dbg(DBG_ROUTE,"to %d, send DrainRegisterMsg(linkSource=%d,destAddr=%d,op=%d)\n",
- 		children[i], pRM->linkSource, pRM->destAddr, pRM->op);
- 	    
- 	    childrenToNotify = BIT_CLEAR(childrenToNotify, i);
- 	    break;
- 	  }
- 	}
-       }
-     }
-     
-     if (result == FAIL) {
- 	    
-       dbg(DBG_ROUTE, "send DrainRegisterMsg FAILED\n");
-       
- #ifndef PLATFORM_PC
-       post NotifyChildrenTask();
- #endif
-       atomic msgBufBusy = FALSE;
-     }
-   }
- 
    command result_t DrainLinkEst.messageSent(TOS_MsgPtr msg, uint8_t id, 
  					    result_t success) {
--- 397,400 ----
***************
*** 626,638 ****
    }
  
-   event result_t SendRegisterMsg.sendDone(TOS_MsgPtr pMsg, result_t success) {
-     if (pMsg == &msgBuf) {
-       atomic msgBufBusy = FALSE;
-       post NotifyChildrenTask();
-     }
-     return SUCCESS;
-   }
- 
- 
    command result_t DrainNextHop.get(uint16_t* buf) {
      memcpy(buf, &routes[0].nextHop, sizeof(uint16_t));
--- 418,421 ----
***************
*** 652,682 ****
      return SUCCESS;
    }
- 
-   command result_t DrainChildren.get(uint16_t* buf, uint8_t pos) {
-     if (pos >= DRAIN_MAX_CHILDREN) 
-       return FAIL;
- 
-     memcpy(buf, &children[pos], sizeof(uint16_t));
-     signal DrainChildren.getDone(buf);
-     return SUCCESS;
-   }
- 
-   command result_t DrainChildrenCount.get(uint8_t* buf) {
-     uint8_t i;
-     uint8_t count = 0;
-     for (i = 0; i < DRAIN_MAX_CHILDREN; i++) {
-       if (children[i] != 0)
- 	count++;
-     }
-     memcpy(buf, &count, sizeof(uint8_t));
-     signal DrainChildrenCount.getDone(buf);
-     return SUCCESS;
-   }
- 
-   command result_t DrainToAddr.get(uint16_t* buf) {
-     memcpy(buf, &toAddr, sizeof(uint16_t));
-     signal DrainToAddr.getDone(buf);
-     return SUCCESS;
-   }
  }
  
--- 435,438 ----

Index: DrainM.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/Drain/DrainM.nc,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** DrainM.nc	15 Mar 2005 01:52:35 -0000	1.6
--- DrainM.nc	27 Apr 2005 00:21:27 -0000	1.7
***************
*** 232,237 ****
          pMsg, pMHMsg->source, pMHMsg->dest);
  
-     signal Snoop.intercept[id](pMsg, &pMHMsg->data[0], payloadLen);
- 
      if (pMsg->addr == TOS_LOCAL_ADDRESS) { // Addressed to local node
  
--- 232,235 ----
***************
*** 258,261 ****
--- 256,263 ----
  	}
        }
+ 
+     } else {
+ 
+       signal Snoop.intercept[id](pMsg, &pMHMsg->data[0], payloadLen);
      }
      



More information about the Tinyos-beta-commits mailing list