[Tinyos-devel] purpose of the Packet.clear() function

Razvan Musaloiu-E. razvanm at cs.jhu.edu
Mon Oct 8 03:00:02 PDT 2007


Hi!

On Mon, 8 Oct 2007, Miklos Maroti wrote:

> Hi Andreas,
>
>> How many protocols and function calls did you design? In how many cases
>> were you safe to rely on (other!) users to ensure your preconditions,
>> especially when you did not express them? Because that is the case here.
>
> I have designed many interfaces, and know what you talk about.
>
>> AMSend does express preconditions, but mentions no meta data that the
>> user must set properly. So the protocol stack must make sure that it
>> works and gives reliable results even if the fields in the meta data
>> contain rubbish.
>
> AMSend is not properly documented in my opinion. At least it should
> say that if you have received a message buffer from another protocol
> stack (e.g. serial), then you should call Packet.clear() to set up the
> default settings.

How about the case when you receive a packet from the serial and want to 
send it to the radio? In this case you will want to avoid clearing the 
data but clear the header and metadata, right? The Packet.clear() clears 
everything so it will not be useful...

>> Once the user stops to think about what he intended, he can express it.
>
> Yes, exactly, but only with Packet.clear()! So this just proves my
> point that the Packet.clear() command is needed. Just because it is
> not used currently, it does not mean that it is not needed. People
> will realize that in certain situations they need to clear the packet,
> and instead of getting rid of that command we should educate the
> users.

I think the fact that the command is not implemented on CC2420 it's a 
strong indication of the ambiguity (and potential lack of use) of this 
command.

--
Razvan ME


More information about the Tinyos-devel mailing list