Hello,

I am trying to simulate message communication in a network of > 100 nodes.

I have the following code:

...
event void Receive.receive(){
    Timer.startOneShot(x);
}

Timer.fired(){
    Send.send(counter);
}
...

The question is if a node receives another message before Timer fires, will
the Timer start again? Will the node cancel previous send command?

for example,
counter=0;
..
event void Receive.receive(){
    counter++;
    Timer.startOneShot(PERIOD);
}

Timer.fired(){
    Send.send(counter);
}

if a node receives a message the counter is incremented to 1 and the Timer
will be started. Assume that another message is received at time < PERIOD.
Will the node send 1 or 2?

And what should I do to not cancel sending 1? Does the following code solve it?


bool stop=FALSE;
counter=0;
..
event void Receive.receive(){
    if(!stop){
      counter++;
      Timer.startOneShot(PERIOD);
      stop=TRUE;
    }

}

Tevent void Timer.fired(){
    Send.send(counter);
    stop=FALSE;
}


...


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

Reply via email to