[Tinyos-devel] ctp vs other radio clients

Philip Levis pal at cs.stanford.edu
Sat Dec 6 09:15:39 PST 2008


On Dec 6, 2008, at 9:05 AM, Geoffrey Werner-Allen wrote:

> I'm pretty sure there IS one SendState and this was my concern  
> exactly, although Om states it more clearly.
>
> Best,

There is only one instance of StateC, but why does this matter? Let's  
look at the queue code:


         if (current >= numClients) { // queue empty
             error_t err;
             am_id_t amId = call AMPacket.type(msg);
             am_addr_t dest = call AMPacket.destination(msg);

             dbg("AMQueue", "%s: request to send from %hhu (%p): queue  
empty\n", __FUNCTION__, clientId, msg);
             current = clientId;

             err = call AMSend.send[amId](dest, msg, len);
             if (err != SUCCESS) {
                 dbg("AMQueue", "%s: underlying send failed.\n",  
__FUNCTION__);
                 current = numClients;
                 queue[clientId].msg = NULL;

             }
             return err;
         }
         else {
             dbg("AMQueue", "AMQueue: request to send from %hhu (%p):  
queue not empty\n", clientId, msg);
         }
         return SUCCESS;

AMQueueImplP (of which there is a single instance, it uses  
uniqueCount() to scale its state) only calls the lower AMSend if the  
queue is empty. If the queue is not empty, this means there is an  
outstanding send, so it waits for the underlying sendDone.

Phil


More information about the Tinyos-devel mailing list