Update of /cvsroot/tinyos/tinyos-2.x/tos/lib/net/collection
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv10533
Modified Files:
Tag: tinyos-2_0_devel-BRANCH
TreeCollectionC.nc TreeRoutingEngineP.nc
Added Files:
Tag: tinyos-2_0_devel-BRANCH
CollectionDebug.nc UARTDebugSenderP.nc
Log Message:
Added CollectionDebug interface and UARTDebugSenderP, which together send
debug messages over the UART.
--- NEW FILE: CollectionDebug.nc ---
interface CollectionDebug {
command error_t logEvent(uint8_t type);
command error_t logEventMsg(uint8_t type, uint16_t msg, am_addr_t origin, am_addr_t node);
command error_t logEventRoute(uint8_t type, am_addr_t parent, uint8_t hopcount, uint16_t metric);
command error_t logEventSimple(uint8_t type, uint16_t arg);
command error_t logEventDbg(uint8_t type, uint16_t arg1, uint16_t arg2, uint16_t arg3);
}
--- NEW FILE: UARTDebugSenderP.nc ---
#include <CollectionDebugMsg.h>
module UARTDebugSenderP {
provides {
interface CollectionDebug;
}
uses {
interface Boot;
interface AMSend as UARTSend;
}
}
implementation {
message_t uartPacket;
CollectionDebugMsg* dbg_msg;
bool busy;
uint8_t len;
event void Boot.booted() {
busy = FALSE;
len = sizeof(CollectionDebugMsg);
dbg_msg = call UARTSend.getPayload(&uartPacket);
}
command error_t CollectionDebug.logEvent(uint8_t type) {
if (busy)
return FAIL;
dbg_msg->type = type;
if (call UARTSend.send(AM_BROADCAST_ADDR, &uartPacket, len) != SUCCESS) {
return FAIL;
}
busy = TRUE;
return SUCCESS;
}
command error_t CollectionDebug.logEventMsg(uint8_t type, uint16_t msg_id, am_addr_t origin, am_addr_t node) {
return SUCCESS;
}
command error_t CollectionDebug.logEventRoute(uint8_t type, am_addr_t parent, uint8_t hopcount, uint16_t metric) {
return SUCCESS;
}
command error_t CollectionDebug.logEventSimple(uint8_t type, uint16_t arg) {
return SUCCESS;
}
command error_t CollectionDebug.logEventDbg(uint8_t type, uint16_t arg1, uint16_t arg2, uint16_t arg3) {
return SUCCESS;
}
event void UARTSend.sendDone(message_t *msg, error_t error) {
busy = FALSE;
}
}
Index: TreeCollectionC.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/lib/net/collection/Attic/TreeCollectionC.nc,v
retrieving revision 1.1.2.14
retrieving revision 1.1.2.15
diff -C2 -d -r1.1.2.14 -r1.1.2.15
*** TreeCollectionC.nc 14 Jun 2006 18:57:44 -0000 1.1.2.14
--- TreeCollectionC.nc 14 Jun 2006 20:53:16 -0000 1.1.2.15
***************
*** 16,20 ****
}
! uses interface CollectionId[uint8_t client];
}
--- 16,23 ----
}
! uses {
! interface CollectionId[uint8_t client];
! interface CollectionDebug;
! }
}
***************
*** 68,71 ****
--- 71,75 ----
Router.RadioControl -> ActiveMessageC;
Router.BeaconTimer -> RoutingBeaconTimer;
+ Router.CollectionDebug = CollectionDebug;
TreeRoutingInspect = Router;
Index: TreeRoutingEngineP.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/lib/net/collection/Attic/TreeRoutingEngineP.nc,v
retrieving revision 1.1.2.9
retrieving revision 1.1.2.10
diff -C2 -d -r1.1.2.9 -r1.1.2.10
*** TreeRoutingEngineP.nc 11 Jun 2006 16:32:28 -0000 1.1.2.9
--- TreeRoutingEngineP.nc 14 Jun 2006 20:53:16 -0000 1.1.2.10
***************
*** 1,4 ****
--- 1,5 ----
#include <Timer.h>
#include <TreeRouting.h>
+ #include <CollectionDebugMsg.h>
//#define TEST_INSERT
/* $Id$ */
***************
*** 38,42 ****
interface UnicastNameFreeRouting as Routing;
interface RootControl;
! interface TreeRoutingInspect;
interface StdControl;
interface Init;
--- 39,43 ----
interface UnicastNameFreeRouting as Routing;
interface RootControl;
! interface TreeRoutingInspect;
interface StdControl;
interface Init;
***************
*** 51,54 ****
--- 52,56 ----
interface Timer<TMilli> as BeaconTimer;
interface Random;
+ interface CollectionDebug;
}
}
***************
*** 226,229 ****
--- 228,232 ----
parentChanges++;
dbg("TreeRouting","Changed parent. from %d to %d\n", routeInfo.parent, best->neighbor);
+ call CollectionDebug.logEventRoute(NET_C_TREE_NEW_PARENT, best->neighbor, best->info.hopcount + 1, best->info.metric);
atomic {
routeInfo.parent = best->neighbor;
***************
*** 289,297 ****
event void BeaconTimer.fired() {
- // determine next interval
if (radioOn && running) {
uint16_t nextInt;
nextInt = call Random.rand16() % BEACON_INTERVAL;
nextInt += BEACON_INTERVAL >> 1;
call BeaconTimer.startOneShot(nextInt);
post updateRouteTask();
--- 292,301 ----
event void BeaconTimer.fired() {
if (radioOn && running) {
+ // determine next interval
uint16_t nextInt;
nextInt = call Random.rand16() % BEACON_INTERVAL;
nextInt += BEACON_INTERVAL >> 1;
+ call CollectionDebug.logEvent(NET_C_TREE_ROUTE_INFO);
call BeaconTimer.startOneShot(nextInt);
post updateRouteTask();
***************
*** 354,382 ****
}
! /* TreeRoutingInspect interface */
! command error_t TreeRoutingInspect.getParent(am_addr_t* parent) {
! if (parent == NULL)
! return FAIL;
! if (routeInfo.parent == INVALID_ADDR)
! return FAIL;
! *parent = routeInfo.parent;
! return SUCCESS;
! }
! command error_t TreeRoutingInspect.getHopcount(uint8_t* hopcount) {
! if (hopcount == NULL)
! return FAIL;
! if (routeInfo.parent == INVALID_ADDR)
! return FAIL;
! *hopcount= routeInfo.hopcount;
! return SUCCESS;
! }
! command error_t TreeRoutingInspect.getMetric(uint16_t* metric) {
! if (metric == NULL)
! return FAIL;
! if (routeInfo.parent == INVALID_ADDR)
! return FAIL;
! *metric = routeInfo.metric;
! return SUCCESS;
! }
/* RootControl interface */
--- 358,386 ----
}
! /* TreeRoutingInspect interface */
! command error_t TreeRoutingInspect.getParent(am_addr_t* parent) {
! if (parent == NULL)
! return FAIL;
! if (routeInfo.parent == INVALID_ADDR)
! return FAIL;
! *parent = routeInfo.parent;
! return SUCCESS;
! }
! command error_t TreeRoutingInspect.getHopcount(uint8_t* hopcount) {
! if (hopcount == NULL)
! return FAIL;
! if (routeInfo.parent == INVALID_ADDR)
! return FAIL;
! *hopcount= routeInfo.hopcount;
! return SUCCESS;
! }
! command error_t TreeRoutingInspect.getMetric(uint16_t* metric) {
! if (metric == NULL)
! return FAIL;
! if (routeInfo.parent == INVALID_ADDR)
! return FAIL;
! *metric = routeInfo.metric;
! return SUCCESS;
! }
/* RootControl interface */