I'd suggest using TOSSIM/gdb.
Phil
On Jul 13, 2009, at 16:19, Xiaohui Liu <[email protected]> wrote:
Hi everyone,
I'm using a queue to buffer received packets and send the head of
queue periodically. But some packets from the queue are different
from what they were when entering the queue. For instance, if you
put packet with sequence number 1 into the queue and pop it out
later, you may find its sequence number changes to 2! Carefully I
list my related code below:
typedef nx_struct queueElement{
nx_uint8_t seqNum;
nx_uint8_t repID;
}queueElement;
uses interface Queue<queueElement*>;
uses interface Pool<queueElement> as heapPool;
event message_t* Receive.receive(message_t* bufPtr, void* payload,
uint8_t len)
{
radioPkt = (RadioMsg*)(call Packet.getPayload(bufPtr,
sizeof(RadioMsg)));
cache_seqNum = radioPkt -> seqNum;
cache_repID = radioPkt->repID;
..........................................
queueEle = call heapPool.get();
if (queueEle == NULL) //no space available
{ return bufPtr; }
//enqueue
queueEle->seqNum = cache_seqNum;
queueEle->repID = cache_repID;
if(call Queue.enqueue(queueEle)==SUCCESS)
{
dbg("DEBUG", "enqueue successful,%d,%d \n ",call
Queue.size(),QUEUE_SIZE);
}
.....
}
event void ForwardRepTimer.fired()
{
if(call Queue.empty()==FALSE) //queue is not empty
{
//dequeue
queueEle = call Queue.head();
qeIn = call heapPool.get();
while (qeIn == NULL) //no space
available, recycle oldest cache elements
{
qeOut = call Cache.dequeue();
if (call heapPool.put(qeOut) != SUCCESS)
dbg("DEBUG", "Put pool error");
qeIn = call heapPool.get();
}
radioPkt = (RadioMsg*)(call
Packet.getPayload(&forwardMsg, sizeof(RadioMsg)));
radioPkt->nodeID = TOS_NODE_ID;
radioPkt->seqNum = queueEle->seqNum;
radioPkt->repID = queueEle->repID;
}
--
Xiaohui Liu
Ph. D. Candidate
Wayne State University
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help