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!
_______________________________________________
Tinyos-help mailing list
[email protected]
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to