Hi,
Most compilers will by default align data types to address boundaries
optimal for their target architecture. This is what you see on the PC
platform. The Mica family of motes uses 8-bit micro controllers,
Therefore data is aligned on a 1-byte basis. So no surprises here.
If you use different platforms, it might happen that the compiler
ignores the "__attribute__((packed))" compiler flag. This is for
instance the case for the telosb family of motes (which have a 16-bit
micro controller). For this reason TinyOS 2.x has introduced the nx_*
network types. So if you're using TinyOS 2.x, you should use the nx_*
data types.
Cheers,
Urs
shangzj schrieb:
> Hi,tinyos-help,
>
> I just test gcc/nesc attribute, "__attribute__ ((packed))" .
> When I compile the following struct in PC platform, the struct is not one
> byte alligned. sizeof(struct foo) is 16.
> typedef struct foo{
> uint8_t a;
> uint64_t b;
> };
>
> while in the case of
>
> typedef struct foo{
> uint8_t a;
> uint64_t b;
> }__attribute__ ((packed));
>
> sizeof(struct foo) is 9.
>
> This is easy to understand.
>
> But when I compile the same struct to a mica or micaz flatform. sizeof(struct
> foo) is always 9 regardless __attribute__ ((packed)) is used or not.
>
> Why? Is NesC deal all the structs defination in tinyos as packed format?
>
>
>
>
> Best regards,
>
> Shang
> 2007-08-21
--
TinyOS 2.x
Mote Platforms:
* Tmote Sky
- Default sensors (temperature, humidity, light)
- Built-in programming through USB
* Micaz
- MTS300, MTS310
- MIB510 connected with a USB-serial converter
* Telegesis ETRX1CF
- no sensors
- Kanda AVR USB ISP (only supported on Windows)
PC-Platforms:
* Linux (Gentoo x86)
* Windows XP with Cygwin
* Windows Mobile 5.0
- only as client with the ETRX1CF module
- using IBM J2ME PP
_______________________________________________
Tinyos-help mailing list
[email protected]
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help