[Tinyos-help] Bits operations
Benjamin Madore
bcmadore at cs.pitt.edu
Tue Apr 17 14:32:26 PDT 2007
On Tue, April 17, 2007 5:08 pm, Jose A. said:
> Hi.
> In my Tiny OS application I´m trying to obtain the first eight bits of
> a variable that take up 2 bytes of space but i don´t know how I can do
> it.
>
> Any idea?.
>
> Thank you very much.
>
> _______________________________________________
> Tinyos-help mailing list
> Tinyos-help at Millennium.Berkeley.EDU
> https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
>
typedef union _byte_word {
struct byte {
uint8_t byteA, byteB;
};
uint16_t word;
} byteword;
byteword x;
x.word = (byteword) variable;
...
uint8_t whatIwant = x.byte.byteA;
Now, I'm sure I didn't do that right. I'm also sure I don't know the endian
format of the transmitter. byteB may be first but last. (Don't try to
understand that. Endian problems are difficult.)
--
The difference between the right word and the almost right word is really a
large matter- it's the difference between a lightning bug and the lightning.
-Twain
More information about the Tinyos-help
mailing list