[Tinyos-help] [TmoteInvent] static local loses context, or does it?

shane at ee.columbia.edu shane at ee.columbia.edu
Sun Feb 18 18:33:28 PST 2007


I have an event handler for async event void ADC.dataReady() where the ADC 
interface is wired to the VoltageC configuration reading the internal voltage 
and compiling for the Tmote Invent platform.

The implementation of the event handler is like
async event result_t ADC.dataReady() {
   static uint8_t myVar = 0;
   ...
   myVar++;
   ...
   myArray[myVar] = 0;
   ...
   return SUCCESS;
}

I am getting compiler complaints about non-atomic access to shared variable 
myVar. I saw in the archives that static locals are treated as globals for 
nido, but i see no mention of that for tmoteinvent. Further, a study of app.c 
finds nothing out of the ordinary (myVar is showing as local, not 
MyModule$ADC$dataReady$myVar), and that there are no other instances of 'myVar' 
present anywhere but local to ADC.dataReady().

I have confirmed that if i make myVar a simple local variable then the warnings 
disappear, but that changing the name of myVar has no effect.

It is notable that i have connected the exact same handler above to a different 
sensor configuration (e.g., InternalTempC and PhotoDriverC) and have NOT had 
the same problem. However, i can't make the connection as to why this would be 
the case.

Any thoughts?

My versions:
------------
TinyOS 1.1.15
Boomerang 2.0.2 (Nothing in the changelog since then seems to apply)
ncc: 1.2alpha5
nescc: 1.2.4
msp430-gcc (GCC) 3.2.3
gcc (GCC) 3.4.6 (Ubuntu 3.4.6-1ubuntu2)

-shane

------------------------------------
http://www.comet.columbia.edu/~shane


More information about the Tinyos-help mailing list