[Tinyos-2-commits] CVS: tinyos-2.x/tos/lib/net/collection
CollectionDebugMsg.h, 1.1.2.4, 1.1.2.5 UARTDebugSenderP.nc,
1.1.2.2, 1.1.2.3
Rodrigo Fonseca
rfonseca76 at users.sourceforge.net
Fri Jun 16 05:58:22 PDT 2006
Update of /cvsroot/tinyos/tinyos-2.x/tos/lib/net/collection
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv19191
Modified Files:
Tag: tinyos-2_0_devel-BRANCH
CollectionDebugMsg.h UARTDebugSenderP.nc
Log Message:
1. Added two new types of debug message, to better instrument SendDone
2. Important change to UARTDebugSenderP: added a queue and a message pool to allow bursts of debug messages to be logged to the UART.
Before, many UART log messages were being lost
Index: CollectionDebugMsg.h
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/lib/net/collection/Attic/CollectionDebugMsg.h,v
retrieving revision 1.1.2.4
retrieving revision 1.1.2.5
diff -C2 -d -r1.1.2.4 -r1.1.2.5
*** CollectionDebugMsg.h 15 Jun 2006 20:27:00 -0000 1.1.2.4
--- CollectionDebugMsg.h 16 Jun 2006 12:58:20 -0000 1.1.2.5
***************
*** 19,22 ****
--- 19,25 ----
NET_C_FE_FWD_MSG = 0x22, //:fwd msg :msg uid, origin, next_hop
NET_C_FE_DST_MSG = 0x23, //:base app. recv :msg_uid, origin, last_hop
+ NET_C_FE_SENDDONE_FAIL = 0x24,
+ NET_C_FE_SENDDONE_WAITACK = 0x25,
+
NET_C_TREE_NO_ROUTE = 0x30, //: :no args
***************
*** 51,54 ****
--- 54,58 ----
} dbg;
} data;
+ nx_uint16_t seqno;
} CollectionDebugMsg;
Index: UARTDebugSenderP.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/lib/net/collection/Attic/UARTDebugSenderP.nc,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -C2 -d -r1.1.2.2 -r1.1.2.3
*** UARTDebugSenderP.nc 14 Jun 2006 21:13:33 -0000 1.1.2.2
--- UARTDebugSenderP.nc 16 Jun 2006 12:58:20 -0000 1.1.2.3
***************
*** 6,9 ****
--- 6,11 ----
uses {
interface Boot;
+ interface Pool<message_t> as MessagePool;
+ interface Queue<message_t*> as SendQueue;
interface AMSend as UARTSend;
}
***************
*** 11,98 ****
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;
! memset(dbg_msg, 0, len);
! dbg_msg->type = type;
! if (call UARTSend.send(AM_BROADCAST_ADDR, &uartPacket, len) != SUCCESS) {
return FAIL;
}
- busy = TRUE;
- return SUCCESS;
}
/* Used for FE_SENT_MSG, FE_RCV_MSG, FE_FWD_MSG, FE_DST_MSG */
command error_t CollectionDebug.logEventMsg(uint8_t type, uint16_t msg_id, am_addr_t origin, am_addr_t node) {
! if (busy)
! return FAIL;
! memset(dbg_msg, 0, len);
! dbg_msg->type = type;
! dbg_msg->data.msg.msg_uid = msg_id;
! dbg_msg->data.msg.origin = origin;
! dbg_msg->data.msg.other_node = node;
! if (call UARTSend.send(AM_BROADCAST_ADDR, &uartPacket, len) != SUCCESS) {
return FAIL;
}
- busy = TRUE;
- return SUCCESS;
}
/* Used for TREE_NEW_PARENT, TREE_ROUTE_INFO */
command error_t CollectionDebug.logEventRoute(uint8_t type, am_addr_t parent, uint8_t hopcount, uint16_t metric) {
! if (busy)
! return FAIL;
! memset(dbg_msg, 0, len);
! dbg_msg->type = type;
! dbg_msg->data.route_info.parent = parent;
! dbg_msg->data.route_info.hopcount = hopcount;
! dbg_msg->data.route_info.metric = metric;
! if (call UARTSend.send(AM_BROADCAST_ADDR, &uartPacket, len) != SUCCESS) {
return FAIL;
}
- busy = TRUE;
- return SUCCESS;
}
/* Used for DBG_1 */
command error_t CollectionDebug.logEventSimple(uint8_t type, uint16_t arg) {
! if (busy)
! return FAIL;
! memset(dbg_msg, 0, len);
! dbg_msg->type = type;
! dbg_msg->data.arg = arg;
! if (call UARTSend.send(AM_BROADCAST_ADDR, &uartPacket, len) != SUCCESS) {
return FAIL;
}
- busy = TRUE;
- return SUCCESS;
}
/* Used for DBG_2, DBG_3 */
command error_t CollectionDebug.logEventDbg(uint8_t type, uint16_t arg1, uint16_t arg2, uint16_t arg3) {
! if (busy)
! return FAIL;
! memset(dbg_msg, 0, len);
! dbg_msg->type = type;
! dbg_msg->data.dbg.a = arg1;
! dbg_msg->data.dbg.b = arg2;
! dbg_msg->data.dbg.c = arg3;
! if (call UARTSend.send(AM_BROADCAST_ADDR, &uartPacket, len) != SUCCESS) {
return FAIL;
}
- busy = TRUE;
- return SUCCESS;
}
- event void UARTSend.sendDone(message_t *msg, error_t error) {
- busy = FALSE;
- }
}
--- 13,202 ----
implementation {
message_t uartPacket;
! bool sending;
uint8_t len;
! uint16_t statLogReceived = 0;
! uint16_t statEnqueueFail = 0;
! uint16_t statSendFail = 0;
! uint16_t statSendDoneFail = 0;
! uint16_t statSendDoneOk = 0;
! uint16_t statSendDoneBug = 0;
!
event void Boot.booted() {
! sending = FALSE;
len = sizeof(CollectionDebugMsg);
! statSendFail = 0;
! statLogReceived = 0;
! statEnqueueFail = 0;
! statSendDoneOk = 0;
! statSendDoneFail = 0;
! statSendDoneBug = 0;
! }
!
! task void sendTask() {
! if (sending) {
! return;
! } else if (call SendQueue.empty()) {
! return;
! } else {
! message_t* smsg = call SendQueue.head();
! error_t eval = call UARTSend.send(AM_BROADCAST_ADDR, smsg, len);
! if (eval == SUCCESS) {
! sending = TRUE;
! return;
! } else {
! //Drop packet. Don't retry.
! statSendFail++;
! call SendQueue.dequeue();
! call MessagePool.put(smsg);
! if (! call SendQueue.empty())
! post sendTask();
! }
! }
! }
!
! event void UARTSend.sendDone(message_t *msg, error_t error) {
! message_t* qh = call SendQueue.head();
! if (qh == NULL || qh != msg) {
! //bad mojo
! statSendDoneBug++;
! } else {
! call SendQueue.dequeue();
! call MessagePool.put(msg);
! if (error == SUCCESS)
! statSendDoneOk++;
! else
! statSendDoneFail++;
! }
! sending = FALSE;
! if (!call SendQueue.empty())
! post sendTask();
}
command error_t CollectionDebug.logEvent(uint8_t type) {
! statLogReceived++;
! if (call MessagePool.empty()) {
return FAIL;
+ } else {
+ message_t* msg = call MessagePool.get();
+ CollectionDebugMsg* dbg_msg = call UARTSend.getPayload(msg);
+ memset(dbg_msg, 0, len);
+
+ dbg_msg->type = type;
+ dbg_msg->seqno = statLogReceived;
+
+ if (call SendQueue.enqueue(msg) == SUCCESS) {
+ post sendTask();
+ return SUCCESS;
+ } else {
+ statEnqueueFail++;
+ call MessagePool.put(msg);
+ return FAIL;
+ }
}
}
/* Used for FE_SENT_MSG, FE_RCV_MSG, FE_FWD_MSG, FE_DST_MSG */
command error_t CollectionDebug.logEventMsg(uint8_t type, uint16_t msg_id, am_addr_t origin, am_addr_t node) {
! statLogReceived++;
! if (call MessagePool.empty()) {
return FAIL;
+ } else {
+ message_t* msg = call MessagePool.get();
+ CollectionDebugMsg* dbg_msg = call UARTSend.getPayload(msg);
+ memset(dbg_msg, 0, len);
+
+ dbg_msg->type = type;
+ dbg_msg->data.msg.msg_uid = msg_id;
+ dbg_msg->data.msg.origin = origin;
+ dbg_msg->data.msg.other_node = node;
+ dbg_msg->seqno = statLogReceived;
+
+ if (call SendQueue.enqueue(msg) == SUCCESS) {
+ post sendTask();
+ return SUCCESS;
+ } else {
+ statEnqueueFail++;
+ call MessagePool.put(msg);
+ return FAIL;
+ }
}
}
/* Used for TREE_NEW_PARENT, TREE_ROUTE_INFO */
command error_t CollectionDebug.logEventRoute(uint8_t type, am_addr_t parent, uint8_t hopcount, uint16_t metric) {
! statLogReceived++;
! if (call MessagePool.empty()) {
return FAIL;
+ } else {
+ message_t* msg = call MessagePool.get();
+ CollectionDebugMsg* dbg_msg = call UARTSend.getPayload(msg);
+ memset(dbg_msg, 0, len);
+
+ dbg_msg->type = type;
+ dbg_msg->data.route_info.parent = parent;
+ dbg_msg->data.route_info.hopcount = hopcount;
+ dbg_msg->data.route_info.metric = metric;
+ dbg_msg->seqno = statLogReceived;
+
+ if (call SendQueue.enqueue(msg) == SUCCESS) {
+ post sendTask();
+ return SUCCESS;
+ } else {
+ statEnqueueFail++;
+ call MessagePool.put(msg);
+ return FAIL;
+ }
}
}
/* Used for DBG_1 */
command error_t CollectionDebug.logEventSimple(uint8_t type, uint16_t arg) {
! statLogReceived++;
! if (call MessagePool.empty()) {
return FAIL;
+ } else {
+ message_t* msg = call MessagePool.get();
+ CollectionDebugMsg* dbg_msg = call UARTSend.getPayload(msg);
+ memset(dbg_msg, 0, len);
+
+ dbg_msg->type = type;
+ dbg_msg->data.arg = arg;
+ dbg_msg->seqno = statLogReceived;
+
+ if (call SendQueue.enqueue(msg) == SUCCESS) {
+ post sendTask();
+ return SUCCESS;
+ } else {
+ statEnqueueFail++;
+ call MessagePool.put(msg);
+ return FAIL;
+ }
}
}
/* Used for DBG_2, DBG_3 */
command error_t CollectionDebug.logEventDbg(uint8_t type, uint16_t arg1, uint16_t arg2, uint16_t arg3) {
! statLogReceived++;
! if (call MessagePool.empty()) {
return FAIL;
+ } else {
+ message_t* msg = call MessagePool.get();
+ CollectionDebugMsg* dbg_msg = call UARTSend.getPayload(msg);
+ memset(dbg_msg, 0, len);
+
+ dbg_msg->type = type;
+ dbg_msg->data.dbg.a = arg1;
+ dbg_msg->data.dbg.b = arg2;
+ dbg_msg->data.dbg.c = arg3;
+ dbg_msg->seqno = statLogReceived;
+
+ if (call SendQueue.enqueue(msg) == SUCCESS) {
+ post sendTask();
+ return SUCCESS;
+ } else {
+ statEnqueueFail++;
+ call MessagePool.put(msg);
+ return FAIL;
+ }
}
}
}
More information about the Tinyos-2-commits
mailing list