X-Git-Url: https://oss.titaniummirror.com/gitweb/?a=blobdiff_plain;f=tos%2Fsystem%2FAMQueueImplP.nc;h=a4c4eaf5ec0be268ffeac5339cb28dcdc5f9ef7f;hb=HEAD;hp=8ea5c7aa1c5444dbfe7b142204d95bb3e7dfa8ce;hpb=48e7ce9859df7a0878f5a97f39f1942636bd7cb2;p=tinyos-2.x.git diff --git a/tos/system/AMQueueImplP.nc b/tos/system/AMQueueImplP.nc index 8ea5c7aa..a4c4eaf5 100644 --- a/tos/system/AMQueueImplP.nc +++ b/tos/system/AMQueueImplP.nc @@ -34,7 +34,7 @@ #include "AM.h" -generic module AMQueueImplP(int numClients) { +generic module AMQueueImplP(int numClients) @safe() { provides interface Send[uint8_t client]; uses{ interface AMSend[am_id_t id]; @@ -45,7 +45,7 @@ generic module AMQueueImplP(int numClients) { implementation { typedef struct { - message_t* msg; + message_t* ONE_NOK msg; } queue_entry_t; uint8_t current = numClients; // mark as empty @@ -152,7 +152,7 @@ implementation { } } - void sendDone(uint8_t last, message_t *msg, error_t err) { + void sendDone(uint8_t last, message_t * ONE msg, error_t err) { queue[last].msg = NULL; tryToSend(); signal Send.sendDone[last](msg, err); @@ -179,24 +179,35 @@ implementation { } event void AMSend.sendDone[am_id_t id](message_t* msg, error_t err) { - if(queue[current].msg == msg) { - sendDone(current, msg, err); - } - else { - dbg("PointerBug", "%s received send done for %p, signaling for %p.\n", - __FUNCTION__, msg, queue[current].msg); - } + // Bug fix from John Regehr: if the underlying radio mixes things + // up, we don't want to read memory incorrectly. This can occur + // on the mica2. + // Note that since all AM packets go through this queue, this + // means that the radio has a problem. -pal + if (current >= numClients) { + return; + } + if(queue[current].msg == msg) { + sendDone(current, msg, err); + } + else { + dbg("PointerBug", "%s received send done for %p, signaling for %p.\n", + __FUNCTION__, msg, queue[current].msg); + } } command uint8_t Send.maxPayloadLength[uint8_t id]() { return call AMSend.maxPayloadLength[0](); } - command void* Send.getPayload[uint8_t id](message_t* m) { - return call AMSend.getPayload[0](m); + command void* Send.getPayload[uint8_t id](message_t* m, uint8_t len) { + return call AMSend.getPayload[0](m, len); } default event void Send.sendDone[uint8_t id](message_t* msg, error_t err) { // Do nothing } + default command error_t AMSend.send[uint8_t id](am_addr_t am_id, message_t* msg, uint8_t len) { + return FAIL; + } }