TOS_Msg is defined in various AM.h files according to your platform.
I count 44 bytes in the T1 micaz/AM.h definition, however your mileage
may vary on other versions and platforms.

sizeof(TOS_Msg) will always return that number. sizeof(YourStruct)
will always return (according to your count) 34. casting one to the
other will not make any difference, you'll always get the size of the
struct that the compiler thinks it is dealing with. If you post your
code snippet I can probably explain it a bit better...

But I think you may be working under another wrong assumption. It sounds
like you are trying to make your own message structure. If that is the
case then what you want to do is make your payload struct -- 6 4-byte
elements -- and then "overlay" that on the TOS_Msg.data area by casting
or copying. See demo apps like Oscilloscope for an example of how this
is done.

MS

Bhavish Aggarwal wrote:
> Hi,
> 
> I'm trying to ascertain the length of a TOS_Msg variable I've
> typecasted to a self-defined struct.
> 
> The struct I use has 6 variables of 4 bytes each. Thus, the total
> length of the TOS_Msg variable should be 24 + 10(headers) = 34. But
> the length is shown to be 46.
> 
> I'm confused as to how this is so. I'd be thankful for help on this.
> 
> Bhavish
> _______________________________________________
> Tinyos-help mailing list
> [email protected]
> https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

-- 
Platform: WinXP/Cygwin
TinyOS version: 1.x, Boomerang
Programmer: MIB510
Device(s): Mica2, MicaZ, Tmote
Sensor board: homebrew

_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to