[Tinyos-help] Simple Question on CC2420PacketP Implementation
Stephen Dawson-Haggerty
stevedh at eecs.berkeley.edu
Tue Jan 6 16:25:51 PST 2009
TEP111 has a lot of detail on message_t's; basically it's because messages
are shared across different stacks and so the cc2420_header_t might actually
be smaller then a message_header_t. TEP111 specifies the alignment of data
& headers, and so you have to do this computation to find where the header
should begin.
Steve
On Tue, Jan 6, 2009 at 6:21 PM, Ali Shah <caffein at gmail.com> wrote:
> Hi list, CC2420PacketP defines this command:
>
> async command cc2420_header_t * ONE CC2420PacketBody.getHeader(
> message_t* ONE msg ) {
> return TCAST(cc2420_header_t* ONE, (uint8_t *)msg + offsetof(message_t,
> data) - sizeof( cc2420_header_t ));
> }
> My question is: why use the offsetof() macro when we know where the header
> begins as message_t has a field devoted exactly for the message header:
>
> tos/types/message.h:
> typedef nx_struct message_t {
> nx_uint8_t header[sizeof(message_header_t)];
> nx_uint8_t data[TOSH_DATA_LENGTH];
> nx_uint8_t footer[sizeof(message_footer_t)];
> nx_uint8_t metadata[sizeof(message_metadata_t)];
> } message_t;
>
> Thanks,
> Ali
>
> _______________________________________________
> Tinyos-help mailing list
> Tinyos-help at millennium.berkeley.edu
> https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://www.millennium.berkeley.edu/pipermail/tinyos-help/attachments/20090106/ed81383e/attachment.htm
More information about the Tinyos-help
mailing list