Hi to all,
I have a VERY strange problem with a component variable. 
In a component scope of my application (immediately under the implementation 
keyword) I have defined a uint16_t variable "epochs" that is increased ad each 
firing of a periodic timer.
It is used by the component to clean things up when timeouts expire.
After some strange behavior on testing the code on tmote sky (simulation with 
TOSSIM have always run correctly) I discovered (sending data over the serial) 
that the value of such variable is corrected almost everywhere in the code, 
apart in a LOCAL function (called by another LOCAL function) - used to make 
code simpler to read - where its value is always 0 unless I put the inline 
keyword before the function. How is it possible and why?? Is it because It is 
bad to use local functions?? Should all local functions  be declared inline??

For the sake of clarity, 
here it is an equivalent (pseudo-code) component describing my problem:

module TestModule{
  uses{
    interface Timer<TMilli> as EpochTimeout;
  }
}implementation{
   uint16_t epochs;

  event void EpochTimeout.fired(){
    epochs++; //here the value is correct
  }
  
  command error_t Send.send(message_t* msg){
    processMsg(msg);
  }
  void processMsg(message_t* msg){
     updateTimeouts(msg);
  }
  void updateTimeouts (message_t* msg){
     print(epochs);//here the value of epochs is always 0;
       //However, it is correct if I declare function as inline!!
   }
}

Best regards,
Flavio




_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to