[Tinyos-help] async and warnings
Philip Levis
pal at cs.stanford.edu
Thu Jul 5 11:02:16 PDT 2007
On Jul 5, 2007, at 9:36 AM, Jordi Casals wrote:
> Hi,
>
> I have a little problem. My program uses async events (from Uart0
> on micaz, T2) and I change a variable into them. I know that it is
> dangerous and I use the atomic statement when I want to change the
> value in another function... My explanation is very bad, and I put
> an example:
>
> ____________________________________________________
> ...
> uint8_t byteRx;
> ...
>
> async event void Uart.receivedByte(uint8_t byte){
> byteRx = byte;
> post uartReceivedByte();
> }
>
> task void uartReceivedByte(){
> ...
> }
>
> void anotherFunction(){
> atomic anotherVariable = byteRx;
> }
> _______________________________________________________
>
> Well, when I compile, there is a warning:
> warning: non-atomic accesses to shared variable `byteRx'
> refered to the declaration of the variable.
>
> How can I solve this warning??
> (I've tried to do this: atomic uint8_t byteRx; and there is an error)
>
> Thank you!
>
Please read the TinyOS programming manual.
http://www.tinyos.net/tinyos-2.x/doc
Phil
More information about the Tinyos-help
mailing list