[Tinyos-help] C mig generated files
Dimas Abreu Dutra
d1ma5 at yahoo.com
Mon Dec 4 03:47:22 PST 2006
Hi,
Thanks for the help, but I had to use a different solution.
Yes, this is correct. The +1 is to skip the first byte of serial
packets which indicates packet kind (0 for active-message packets).
This was already done in tmsg_t *msg = new_tmsg(packet + 1, len - 1);
> From the description it sounds like your ReportMsg_field_get() function
> is expecting to get a pointer to the payload, not the full message.
>
> Unless things are very different in T2, the message payload should
> be at a fixed offset from the beginning of the packet and shouldn't
> vary with payload type (although the actual length might vary). The
> old standby technique is something like:
>
> TOS_Msg *msg = (TOS_Msg*) (packet + 1); // assume +1 skips sync byte?
> tmsg_t *tmsg = (tmsg_t *) msg->data;
The TOS_Msg type in the T2 C support libraries is the tmsg_t. If I tried
payload = &msg->data ;
the compiler complained: deferencing pointer to incomplete type. If I used
payload = (tmsg_t *) tmsg_data(msg) ;
the compiler complained: invalid use of undefined type `struct tmsg'.
After some tries and a few segmentation faults, I found out that
payload = new_tmsg(tmsg_data(msg) + spacket_data_offset(0), spacket_header_length_get(msg));
would make it work, otherwise the bytes inside each field of the ReportMsg would come shuffled randomlly (the same random shuffling always).
~Dimas~
---------------------------------
Novidade no Yahoo! Mail: receba alertas de novas mensagens no seu celular. Registre seu aparelho agora!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.millennium.berkeley.edu/pipermail/tinyos-help/attachments/20061204/9af15926/attachment.html
More information about the Tinyos-help
mailing list