On Tue, 2006-01-17 at 17:20 +0800, fiasco wrote:
> Maybe I did not express clearly, since English is not my native
> language. :)
> 
> Of cource we can ensure there is no conflict in application level,
> such as 
> we do not call SendMsg.send() until we get sendDone() . 
> 
> But I am not sure whether it is enough to guarantee there is no
> conflict
> in system level.
> 
> For instance, back to the previous code,
> 
> if(!call SendSensorsData.send(TOS_BCAST_ADDR,sizeof
> (SensorsMsg ),&gMsgBuffer)) 
> {
>         call Leds.set(7);
> }
> 
> In a surge-like application, when a mote receives a bcast message, it
> has two messages to
> send out. One is the bcast message, since it is required to
> rebroadcast it. The other is the 
> sensoring-data, which will be sent using up-code. 
>  
> Is it possible that these two send() conflict each other, which cause
> sending failed? 
>  
> If so, how can we aovid it, these two actions are in different level,
> one is in application level, the other is in library level.


Two ways: used QueuedSendC and make sure you don't fill the queue, or 
use the sendDone() event of GenericComm:

configuration GenericComm
{
  provides {
    interface StdControl as Control;

    // The interface are as parameterised by the active message id
    interface SendMsg[uint8_t id];
    interface ReceiveMsg[uint8_t id];

    // How many packets were received in the past second
    command uint16_t activity();
  }
  uses {
    // signaled after every send completion for components which wish to
    // retry failed sends
    event result_t sendDone();
  }
}

E.g.:

result_t tryToSend() {
  if (state == SENDING) {
    return FAIL;
  }
  if (call SendMsg.send(...) == FAIL) {
    state = WAITING_TO_SEND;
  }
  else {
    state = SENDING;
  }
}

event result_t SendMsg.sendDone(...) {
  state = IDLE;
}

event result_t sendDone() {
  if (state == WAITING_TO_SEND) {
    tryToSend();
  }
}

Phil


_______________________________________________
Tinyos-help mailing list
[email protected]
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to