This approach will stop increment your counter by receiving messages. If you can skip received messages you will get along this way. -- Diese Nachricht wurde von meinem Android-Mobiltelefon mit K-9 Mail gesendet.
Chan bey <[email protected]> schrieb: 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
