[Tinyos-contrib-commits] CVS: tinyos-1.x/contrib/wustl/apps/Agilla/components AddressMgrM.nc, 1.11, 1.11.2.1 ErrorMgrC.nc, 1.4, 1.4.2.1 ErrorMgrDummy.nc, 1.3, 1.3.2.1 ErrorMgrM.nc, 1.5, 1.5.2.1 LocationMgrC.nc, 1.7, 1.7.2.1 LocationMgrM.nc, 1.7, 1.7.2.1 LocationUtils.nc, 1.3, 1.3.2.1

Chien-Liang Fok chien-liang at users.sourceforge.net
Tue Nov 14 20:29:37 PST 2006


Update of /cvsroot/tinyos/tinyos-1.x/contrib/wustl/apps/Agilla/components
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv26847/components

Modified Files:
      Tag: GroupComm
	AddressMgrM.nc ErrorMgrC.nc ErrorMgrDummy.nc ErrorMgrM.nc 
	LocationMgrC.nc LocationMgrM.nc LocationUtils.nc 
Log Message:
Added a proxy heart beat and a virtual ID for the proxy.

Index: AddressMgrM.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/contrib/wustl/apps/Agilla/components/AddressMgrM.nc,v
retrieving revision 1.11
retrieving revision 1.11.2.1
diff -C2 -d -r1.11 -r1.11.2.1
*** AddressMgrM.nc	18 May 2006 19:58:40 -0000	1.11
--- AddressMgrM.nc	15 Nov 2006 04:29:34 -0000	1.11.2.1
***************
*** 89,92 ****
--- 89,97 ----
    bool recvBS;
    
+   /**
+    * The virtual ID of the proxy.
+    */
+   uint16_t vID;
+   
    command result_t StdControl.init() 
    {
***************
*** 142,145 ****
--- 147,157 ----
    
    /**
+    * Returns the virtual ID of this proxy.
+    */
+   command result_t AddressMgrI.getVID() {
+     return vID;
+   }
+   
+   /**
     * Returns TRUE if the specified address is the one
     * that this mote was programmed as.
***************
*** 154,159 ****
--- 166,173 ----
     */
    event TOS_MsgPtr ReceiveSetBSMsg.receive(TOS_MsgPtr m) {  
+     AgillaSetBSMsg* bmsg = (AgillaSetBSMsg *)m->data;
      isGW = TRUE;
      recvBS = TRUE; 
+     vID = bmsg->vID;
      #if DEBUG_ADDRESS_MGR
        dbg(DBG_USR1, "AddressMgrM: isGW = TRUE.\n");

Index: ErrorMgrC.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/contrib/wustl/apps/Agilla/components/ErrorMgrC.nc,v
retrieving revision 1.4
retrieving revision 1.4.2.1
diff -C2 -d -r1.4 -r1.4.2.1
*** ErrorMgrC.nc	18 May 2006 19:58:40 -0000	1.4
--- ErrorMgrC.nc	15 Nov 2006 04:29:34 -0000	1.4.2.1
***************
*** 49,55 ****
    components Main, ErrorMgrM, CodeMgrC, AddressMgrC; 
    components LedsC, TimerC, NetworkInterfaceProxy as Comm; //GenericComm;
!   components AgentMgrC;
    
    Main.StdControl -> ErrorMgrM;  
    
    ErrorMgrI = ErrorMgrM;
--- 49,56 ----
    components Main, ErrorMgrM, CodeMgrC, AddressMgrC; 
    components LedsC, TimerC, NetworkInterfaceProxy as Comm; //GenericComm;
!   components AgentMgrC, MessageBufferM;
    
    Main.StdControl -> ErrorMgrM;  
+   Main.StdControl -> MessageBufferM;
    
    ErrorMgrI = ErrorMgrM;
***************
*** 62,64 ****
--- 63,66 ----
    ErrorMgrM.SendError -> Comm.SendMsg[AM_AGILLAERRORMSG];
    ErrorMgrM.ReceiveError -> Comm.ReceiveMsg[AM_AGILLAERRORMSG];  
+   ErrorMgrM.MessageBufferI -> MessageBufferM;
  }

Index: ErrorMgrDummy.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/contrib/wustl/apps/Agilla/components/ErrorMgrDummy.nc,v
retrieving revision 1.3
retrieving revision 1.3.2.1
diff -C2 -d -r1.3 -r1.3.2.1
*** ErrorMgrDummy.nc	18 May 2006 19:58:40 -0000	1.3
--- ErrorMgrDummy.nc	15 Nov 2006 04:29:34 -0000	1.3.2.1
***************
*** 89,92 ****
--- 89,108 ----
    
    /**
+    * Notifies the base station of an error.  Supports fatal and non-fatal errors.
+    *
+    * @param errorType Either FATAL or NONFATAL.  Fatal errors halt the agent and periodically
+    * sends the error message.  Nonfatal errors only send the error message once.
+    * @param context The agent context that caused the error.
+    * @param cause The cause of the errror.
+    * @param data1 The first associated data paramter.
+    * @param data2 The second associated data parameter.   
+    */    
+   command result_t ErrorMgrI.sendError(uint16_t errorType, AgillaAgentContext* context, 
+     uint8_t cause, uint16_t data1, uint16_t data2) 
+   {
+     return SUCCESS;
+   }
+   
+   /**
     * Returns SUCCESS if Agilla is in an error state, 
     * else returns FAIL.

Index: ErrorMgrM.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/contrib/wustl/apps/Agilla/components/ErrorMgrM.nc,v
retrieving revision 1.5
retrieving revision 1.5.2.1
diff -C2 -d -r1.5 -r1.5.2.1
*** ErrorMgrM.nc	18 May 2006 19:58:40 -0000	1.5
--- ErrorMgrM.nc	15 Nov 2006 04:29:34 -0000	1.5.2.1
***************
*** 58,64 ****
--- 58,71 ----
      interface SendMsg as SendError;
      interface ReceiveMsg as ReceiveError;  
+     interface MessageBufferI;
    }
  }
  implementation {
+ 
+   /**
+    * The error message to send in a fatal state.
+    */
+   AgillaErrorMsg _errorMsg;
+ 
    /** 
     * Determines whether the mote is in an error state.
***************
*** 66,74 ****
     */
    bool inErrorState;
! 
    /**
!    * A message buffer used for sending error messages.
     */
!   TOS_Msg msg;    
    
    command result_t StdControl.init() {
--- 73,90 ----
     */
    bool inErrorState;
!   
!   
    /**
!    * If this node is a gateway, send the error message to the serial
!    * port.  Otherwise send it to the broadcast address.
!    *
!    * @param msg A pointer to the error message to send.
     */
!   result_t sendErrorMsg(TOS_MsgPtr msg) {
!     if (call AddressMgrI.isGW())    
!       return call SendError.send(TOS_UART_ADDR, sizeof(AgillaErrorMsg), msg);
!     else
!       return call SendError.send(TOS_BCAST_ADDR, sizeof(AgillaErrorMsg), msg);  
!   }
    
    command result_t StdControl.init() {
***************
*** 85,89 ****
      return SUCCESS;
    }
! 
    /**
     * Called when an error with no associated data occurs.
--- 101,105 ----
      return SUCCESS;
    }
!   
    /**
     * Called when an error with no associated data occurs.
***************
*** 101,106 ****
     * @param data1 The associated data paramter.
     */
!   command result_t ErrorMgrI.errord(AgillaAgentContext* context, uint8_t cause, 
!     uint16_t data1) 
    {
      return call ErrorMgrI.error2d(context, cause, data1, 0);
--- 117,121 ----
     * @param data1 The associated data paramter.
     */
!   command result_t ErrorMgrI.errord(AgillaAgentContext* context, uint8_t cause, uint16_t data1) 
    {
      return call ErrorMgrI.error2d(context, cause, data1, 0);
***************
*** 109,122 ****
    /**
     * Called when an error with two data parameters occurs.
     *
     * @param context The agent context that caused the error.
     * @param data1 The first associated data paramter.
     * @param data2 The second associated data parameter.
     */
!   command result_t ErrorMgrI.error2d(AgillaAgentContext* context, uint8_t cause, 
!     uint16_t data1, uint16_t data2) 
    {
!     AgillaErrorMsg* errorMsg = (AgillaErrorMsg*)msg.data;
!     inErrorState = TRUE;
      
      dbg(DBG_ERROR|DBG_USR1, "VM (%i, %i): Entering ERROR state. Agent: %i, pc: %i, cause %i (0x%x), reason1 %i, reason2 %i\n", 
--- 124,169 ----
    /**
     * Called when an error with two data parameters occurs.
+    * This is deprecated by sendError(uint16_t errorType, AgillaAgentContext* context, uint8_t cause, uint16_t data1, uint16_t data2).
     *
     * @param context The agent context that caused the error.
+    * @param cause The cause of the errror.
     * @param data1 The first associated data paramter.
     * @param data2 The second associated data parameter.
     */
!   command result_t ErrorMgrI.error2d(AgillaAgentContext* context, uint8_t cause, uint16_t data1, uint16_t data2) 
    {
!     return call ErrorMgrI.sendError(FATAL, context, cause, data1, data2);
!   }
!   
!   /**
!    * Notifies the base station of an error.  Supports fatal and non-fatal errors.
!    *
!    * @param errorType Either FATAL or NONFATAL.  Fatal errors halt the agent and periodically
!    * sends the error message.  Nonfatal errors only send the error message once.
!    * @param context The agent context that caused the error.
!    * @param cause The cause of the errror.
!    * @param data1 The first associated data paramter.
!    * @param data2 The second associated data parameter.   
!    */
!   command result_t ErrorMgrI.sendError(uint16_t errorType, AgillaAgentContext* context, uint8_t cause, uint16_t data1, uint16_t data2) {
!     AgillaErrorMsg* errorMsg;
!     TOS_MsgPtr msg;
!     
!     if (errorType == NONFATAL) {
!       msg = call MessageBufferI.getMsg();    
!       if (msg == NULL)
!         return FAIL;
!       errorMsg = (struct AgillaErrorMsg *)msg->data;
!       if (!sendErrorMsg(msg)) {
!         call MessageBufferI.freeMsg(msg);
!         return FAIL;
!       }
!     } else {
!       errorMsg = &_errorMsg;            
!       inErrorState = TRUE;
!       call Leds.redOn();
!       call Leds.greenOff();
!       call Leds.yellowOn();             
!     }
      
      dbg(DBG_ERROR|DBG_USR1, "VM (%i, %i): Entering ERROR state. Agent: %i, pc: %i, cause %i (0x%x), reason1 %i, reason2 %i\n", 
***************
*** 127,135 ****
        cause, cause, data1, data2);
      
-     call Leds.redOn();
-     call Leds.greenOff();
-     call Leds.yellowOn();
-     
-     call ErrorTimer.start(TIMER_ONE_SHOT, 1024);    
      errorMsg->cause = cause;
      errorMsg->src = TOS_LOCAL_ADDRESS;
--- 174,177 ----
***************
*** 137,142 ****
      errorMsg->reason2 = data2;
      
!     if (context != NULL) {    
!       //context->state = AGILLA_STATE_HALT;
        errorMsg->id = context->id;            
        errorMsg->pc = context->pc - 1;
--- 179,183 ----
      errorMsg->reason2 = data2;
      
!     if (context != NULL) {          
        errorMsg->id = context->id;            
        errorMsg->pc = context->pc - 1;
***************
*** 151,155 ****
        errorMsg->sp = 0xff;
      }
!     return SUCCESS;        
    }
    
--- 192,200 ----
        errorMsg->sp = 0xff;
      }
!     
!     if (errorType == FATAL)
!       call ErrorTimer.start(TIMER_ONE_SHOT, 1024);  
!         
!     return SUCCESS;            
    }
    
***************
*** 172,189 ****
     */
    event result_t ErrorTimer.fired() {
!     dbg(DBG_USR1|DBG_ERROR, "ErrorMgrM: ERROR cause = %i\n", ((AgillaErrorMsg*)msg.data)->cause);
      
!     call Leds.redToggle();
!     call Leds.greenToggle();
!     call Leds.yellowToggle();
  
!     if (call AddressMgrI.isGW())    
!       call SendError.send(TOS_UART_ADDR, sizeof(AgillaErrorMsg), &msg);
!     else
!       call SendError.send(TOS_BCAST_ADDR, sizeof(AgillaErrorMsg), &msg);
!     
      if (inErrorState)
        call ErrorTimer.start(TIMER_ONE_SHOT, 1024);
-     
      return SUCCESS;
    }  
--- 217,236 ----
     */
    event result_t ErrorTimer.fired() {
!     TOS_MsgPtr msg = call MessageBufferI.getMsg();
!     if (msg != NULL) {
!       struct AgillaErrorMsg* errorMsg = (struct AgillaErrorMsg *)msg->data;
!       *errorMsg = _errorMsg;
!       
!       dbg(DBG_USR1|DBG_ERROR, "ErrorMgrM: ERROR cause = %i\n", errorMsg->cause);
      
!       call Leds.redToggle();
!       call Leds.greenToggle();
!       call Leds.yellowToggle();
  
!       if (!sendErrorMsg(msg))
!         call MessageBufferI.freeMsg(msg);
!     }
      if (inErrorState)
        call ErrorTimer.start(TIMER_ONE_SHOT, 1024);
      return SUCCESS;
    }  
***************
*** 195,200 ****
    event TOS_MsgPtr ReceiveError.receive(TOS_MsgPtr m) {
      if (call AddressMgrI.isGW()) {
!       msg = *m;
!       call SendError.send(TOS_UART_ADDR, sizeof(AgillaErrorMsg), &msg);
      }
      return m;
--- 242,251 ----
    event TOS_MsgPtr ReceiveError.receive(TOS_MsgPtr m) {
      if (call AddressMgrI.isGW()) {
!       TOS_MsgPtr msg = call MessageBufferI.getMsg();
!       if (msg != NULL) {    
!         *msg = *m;
!         if (!call SendError.send(TOS_UART_ADDR, sizeof(AgillaErrorMsg), msg))
!           call MessageBufferI.freeMsg(msg);
!       }
      }
      return m;
***************
*** 202,205 ****
--- 253,257 ----
    
    event result_t SendError.sendDone(TOS_MsgPtr mesg, result_t success) {
+     call MessageBufferI.freeMsg(mesg);
      return SUCCESS;
    }  

Index: LocationMgrC.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/contrib/wustl/apps/Agilla/components/LocationMgrC.nc,v
retrieving revision 1.7
retrieving revision 1.7.2.1
diff -C2 -d -r1.7 -r1.7.2.1
*** LocationMgrC.nc	18 May 2006 19:58:40 -0000	1.7
--- LocationMgrC.nc	15 Nov 2006 04:29:34 -0000	1.7.2.1
***************
*** 53,57 ****
  implementation {
    components Main, LocationMgrM, NetworkInterfaceProxy as Comm, TimerC;
!   components LedsC;
  
    #if ENABLE_SPACE_LOCALIZER
--- 53,57 ----
  implementation {
    components Main, LocationMgrM, NetworkInterfaceProxy as Comm, TimerC;
!   components LocationUtils, LedsC;
  
    #if ENABLE_SPACE_LOCALIZER
***************
*** 76,79 ****
--- 76,82 ----
    LocationMgrM.ReceiveGridSizeMsg -> Comm.ReceiveMsg[AM_AGILLAGRIDSIZEMSG];  
    LocationMgrM.SendGridSizeMsg -> Comm.SendMsg[AM_AGILLAGRIDSIZEMSG];    
+   
+   LocationUtils.LocationMgrI -> LocationMgrM;
+   LocationMgrM.LocationUtilI -> LocationUtils;
  
    #if ENABLE_SPACE_LOCALIZER

Index: LocationMgrM.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/contrib/wustl/apps/Agilla/components/LocationMgrM.nc,v
retrieving revision 1.7
retrieving revision 1.7.2.1
diff -C2 -d -r1.7 -r1.7.2.1
*** LocationMgrM.nc	27 Sep 2006 04:20:32 -0000	1.7
--- LocationMgrM.nc	15 Nov 2006 04:29:34 -0000	1.7.2.1
***************
*** 59,62 ****
--- 59,63 ----
      interface ReceiveMsg as ReceiveGridSizeMsg;
      interface SendMsg as SendGridSizeMsg;
+     interface LocationUtilI;
      
      // Interfaces with the Cricket 2 Motes.
***************
*** 138,141 ****
--- 139,151 ----
    
    /**
+    * Determines whether this mote is a proxy;
+    */
+   command result_t LocationMgrI.isProxy() {
+     AgillaLocation myLoc;
+     call LocationMgrI.getLocation(TOS_LOCAL_ADDRESS, &myLoc);
+     return call LocationUtilI.isProxy(&myLoc);
+   }
+   
+   /**
     * Converts a location to an address.
     *
***************
*** 150,154 ****
      //if (loc->x == UART_X && loc->y == UART_Y)
      if ((loc->x == UART_X && loc->y == UART_Y) 
!     	|| (loc->x == FORCE_UART_X && loc->y == FORCE_UART_Y))
        return TOS_UART_ADDR;      
      else if (loc->x == BCAST_X && loc->y == BCAST_Y)
--- 160,164 ----
      //if (loc->x == UART_X && loc->y == UART_Y)
      if ((loc->x == UART_X && loc->y == UART_Y) 
!       || (loc->x == FORCE_UART_X && loc->y == FORCE_UART_Y))
        return TOS_UART_ADDR;      
      else if (loc->x == BCAST_X && loc->y == BCAST_Y)

Index: LocationUtils.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/contrib/wustl/apps/Agilla/components/LocationUtils.nc,v
retrieving revision 1.3
retrieving revision 1.3.2.1
diff -C2 -d -r1.3 -r1.3.2.1
*** LocationUtils.nc	18 May 2006 19:58:40 -0000	1.3
--- LocationUtils.nc	15 Nov 2006 04:29:34 -0000	1.3.2.1
***************
*** 46,49 ****
--- 46,55 ----
  module LocationUtils {
    provides interface LocationUtilI;
+   
+   /*
+    * fs2:  GroupComm
+    */
+   uses interface LocationMgrI; 
+    
  }
  implementation {
***************
*** 88,96 ****
    
    /**
     * Returns true if the two locations are grid neighbors, false otherwise.
     * Two locations are neighbors if their distance is <= 2.
     */
    command result_t LocationUtilI.isGridNbr(AgillaLocation* l1, AgillaLocation* l2) {
!     return call LocationUtilI.dist(l1, l2) <= 2;
    }
  }
--- 94,141 ----
    
    /**
+    * Determines whether the specified location is a proxy address.
+    */
+   command result_t LocationUtilI.isProxy(AgillaLocation* loc) {
+     uint16_t reservedAddr[] = {0xFFFA, 0xFFFB, 0xFFFC, 0xFFFD, 0xFFFE}; // reserved addr
+     int ir;
+     for(ir=0; ir<5; ir++)
+     {
+       AgillaLocation rloc;
+       call LocationMgrI.getLocation(reservedAddr[ir], &rloc);
+       if (call LocationUtilI.equals(loc, &rloc))
+         return SUCCESS;
+     } 
+     return FAIL;
+   }
+   
+   /**
     * Returns true if the two locations are grid neighbors, false otherwise.
     * Two locations are neighbors if their distance is <= 2.
     */
    command result_t LocationUtilI.isGridNbr(AgillaLocation* l1, AgillaLocation* l2) {
!     //return call LocationUtilI.dist(l1, l2) <= 2;
!     
!   /*
!    * fs2:  GroupComm
!    */
!     AgillaLocation rloc;
!     
!     uint8_t l1_reserved = 0;
!     uint8_t l2_reserved = 0;
!            
!     // check if l1 or l2 is reserved location
!     if(call LocationUtilI.isProxy(l1)) l1_reserved = 1;
!     if(call LocationUtilI.isProxy(l2)) l2_reserved = 1;        
!     
!     
!     //if neither l1 l2 is reserved location, l1 l2 are neighbors if they are one hop away
!     if((l1_reserved+l2_reserved) == 0)
!       return call LocationUtilI.dist(l1, l2) <= 2;
!     // if one of l1 l2 is reserved loation and the other is not, l1 l2 are neighbors
!     if((l1_reserved+l2_reserved) == 1)
!       return SUCCESS;
!     // if l1 l2 are both reserved locations, they are NOT neighbors
!     if((l1_reserved+l2_reserved) == 2)
!       return FAIL;        
    }
  }



More information about the Tinyos-contrib-commits mailing list