[Tinyos-help] AMSend, T2 tutorial 3, K&R C,
nesC language questions
Daniel Widyanto
danielw at wireless-people.com
Mon Jul 9 19:45:49 PDT 2007
Hi,
getPayload() will return (void *), which means that it will point to array of memories.
By casting it into structure pointer, it'll be easier to access the field inside the structure.
Here's a little illustration :
(void *) AMSend.getPayload(&pkt) = 0x00 0x01 0x00 0x05
(BlinkToRadioMsg*) AMSend.getPayload(&pkt) = 0x0001 | 0x0005
(BlinkToRadioMsg*) AMSend.getPayload(&pkt) = nodeid | counter
It's the concept of how C arranging the structures into plain array of memories
(thus it's the basic of how to structure the plain array of memories into fields).
I think K&R have explained it.
Regards,
-daniel
-------- Original Message --------
> From: John Griessen <john at ecosensory.com>
> What is the meaning of
> (BlinkToRadioMsg*) (call AMSend.getPayload(&pkt));
> in the top line? Is this the syntax for coercing to type BlinkToRadioMsg*?
> Where in the docs is this syntax defined?
>
> It's not like K&R C...where
> you would declare *btrpkt to get a pointer you could use as btrpkt->nodeid
>
>
> John Griessen
>
> Ecosensory
More information about the Tinyos-help
mailing list