[Tinyos-help] [Help] An endiian problem in telosb motes that use MSP430

Hejun Wu whjnn at ust.hk
Mon Dec 18 02:10:27 PST 2006


Hi,

I am using telosb motes and I think that there is a problem of the MSP430 compiler:  

Suppose we have the following program:

typedef struct {int a; int b; int c;}TMP;   
typedef struct {int x; int y;}POS;
TMP tmp; 
POS * pPos;
tmp.a = 1;
tmp.b = 1;
tmp.c = 1;
pPos = (POS*) ((char*)&tmp + sizeof(int));

pPos->x = 1;

Then, the value of pPos->y will be 0x0100, but pPos->x will be 0x0001 (lower byte of pPos->x is 0x01 and the higher byte is 0x00).  

How can I fix this problem?  Thanks!

Best regards,
Hejun
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.millennium.berkeley.edu/pipermail/tinyos-help/attachments/20061218/ff3b1e6e/attachment.htm


More information about the Tinyos-help mailing list