Sorry, "tab-space" sends on this webmail client. I need to be more careful
about that. Anyone know how to adjust tab to field behavior in Firefox 2?

On Tue, June 5, 2007 5:44 pm, M A said:
> Hi
>
> I have started learning tinyos-2.x and I have a simple question related to
> MultiOscilloscope function in directory
> tinyos-2.x/apps/MultihopOscilloscope.
> In the file MultioscilloscopeC.nc we declare a message buffer " message_t
> uartbuf ".
 Declaring one yourself is the correct action, however you should also have
a pointer:
    message_t * p_uartbuf;

> But I dont understand where is this initialized.
 If you don't initialize it somehow, it won't have anything done to it until
it gets used by part of the radio stack. I believe the stack wipes a buffer
before it uses it.

> We call the
> command SerialSend.getPayload(&uartbuf); in the Recevie.receive() event.
> Thus  basically we are getting the payload from the message stored in
> uartbuf. But I cant figure out where and when a message is being stored in
> uartbuf.

Receive.receive() looks like:
    event message_t* receive(message_t* msg, void* payload, uint8_t len);

msg is a pointer to the buffer that the incoming AM message occupies. This
buffer is a message_t. If you want the whole message, you need to swap
pointers so that your buffer becomes part of the stack, and the one on the
stack you keep.

    message_t * p_tempMsg; //Message for swap
    p_tempMsg = p_uartbuf;
    p_uartbuf = msg; //your buffer is now the incoming message

> I guess when Receive.receive returns it returns a buffer for the stack. Is
> it the same buffer? I am confused. Can anyone explain this to me ?
 Now, here's why you declared p_tempMsg:
    return p_tempMsg;
 This returns your buffer to the receive interface so it has an empty buffer
to use for the next message. This is so you don't have your message
overwritten when your trying to work with it.

 You may also just want the payload. One way to do that is to allocate:
    uint8_t payloadBuffer[DATA_LENGTH]; //I am not 100% sure this is the
const. in 2.x
 Then you can:
    memcpy (&payloadBuffer, payload, len);
 in the receive event. Don't forget to:
    return msg;
 if you memcpy out your data.

 There are, of course, other ways to copy if you have declare a struct for
your data, but this should get you started.


> Thanking You
> John
> _______________________________________________
> Tinyos-help mailing list
> Tinyos-help@Millennium.Berkeley.EDU
> https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

I hope I helped.
-Ben

-- 
The difference between the right word and the almost right word is really a
large matter- it's the difference between a lightning bug and the lightning.
-Twain

_______________________________________________
Tinyos-help mailing list
Tinyos-help@Millennium.Berkeley.EDU
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to