Andrea,

Your observations are correct. This is the correct behavior of the radio
stack. However, your code does not use the SendMsg interface correctly.

If you check the radio stack sources, you'll notice that once the radio
stack accepts a message for sending, it sets a busy flag. The flag is
cleared when the transmission of the message completes. While this flag
is set, the radio stack will refuse to accept any other messages, i.e.
SendMsg.send will always return FAIL.

As you have observed, sending out three messages in from within the same
task context will never work, since the tasks deep down in the radio
stack will not get a chance to execute (send the first message and then
clear the bTxBusy flag, etc.) while your code is executing. Even if you
use timers, if you want to send out messages too fast, some of them will
fail, since the radio stack doesn't do buffering.

The contract of the SendMsg interface says that SendMsg.send() will
return SUCCESS if the message is _accepted_ for transmission. Notice
that it does _not_ say that SUCCESS means that the message is actually
sent. It is the sendDone event that notifies you that the transmission
has completed (or failed).

It's a good practice to check for the return value of SendMsg.send(). If
a FAIL is returned, don't try to resend it from the same task context,
but use some deferred execution technique, e.g. a task or a timer that
will retry sending.

Notice that on mica2 you won't be able to send a message from the
sendDone event handler, since the radio stack will clear the busy flag
after the sendDone event handler completes. You can do that on the
telos, though. Therefore, if you want to send out a series of radio
messages, the best solution is to post a task from sendDone that will
send the next packet.

Janos



-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Michael Schippling
Sent: Friday, February 03, 2006 5:25 PM
To: [EMAIL PROTECTED]
Cc: TINYOS HELP
Subject: Re: [Tinyos-help] How to send messages in loop ? (tmote sky)

That is not my experience with the mica{2,z}, although I have not tried
immediate sequential sends as you show. In my 'reliability testing' that
I've reported over the last couple months I fire off messages to a
re-Mote
which tries to reply immediately. In that case I can get around 12
request/response pairs per sec on the '2 and 50 on the 'z. Throttling
to those speeds seems to be necessary to minimize lost messages, but
not to .5 second.

I have not tried tmotes (at all) but I believe their radio is very
similar to the micaz.

I wonder if you are having task contention problems or something?

MS

Andrea Pacini wrote:
> I noticed that when you must send , for example, 3 messages, you must 
> put a timer between a send and the following send;
> if I don't do it the following  send cannot be executed. That is, the 
> scheme I used is (for 3 send):
> 
> [...]
> *call Send(...);             *        //  send
> [...]
> 
> [...]
> *event senddone(..)* {
>                    if (<FIRST SEND> or <SECOND SEND>)
>

>           call Timer.start(TIMER_ONE_SHOT,<TIME>);
> }
> [...]
> 
> *Timer.fired()* {
>                     [...]
>                     if (<FIRST SEND> OR <SECOND SEND>))
>

>            call Send(...);
>                     [...]          
> }
> 
> If I don't put the timer (scheduled with <TIME> = 0.4 - 0.5 seconds)  
> send are not executed. Do you confirm this behaviour ?
> 
> Thanks
> Andre
> 
> 
>
------------------------------------------------------------------------
> 
> _______________________________________________
> Tinyos-help mailing list
> [email protected]
>
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-hel
p
_______________________________________________
Tinyos-help mailing list
[email protected]
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-hel
p

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

Reply via email to