I'am currently working on tinyos and I Am trying to reset timer lets say to 2 seconds when it is running at 45 seconds but it is not working, i can't figure out why,
can someone help me figure it out
here is the code:
printf("timer before resetting it %ld",call Timer1.getNow());
offset = ((TimeMote_t*) payload)->tdata;
call Timer1.startPeriodic(offset);
printf("timer after resetting it %ld",call Timer1.getNow());
now actually it should have reset the timer to offset but it's not resetting it. both printf statements are giving the same time.
No, it shouldn't. Timer.getNow()
returns absolute time, which can't be changed or reset. Timer
interface can be used to schedule events at a particular moment in the future. Timer.startPeriodic(offset)
starts the timer, meaning that the event Timer.fired()
will be signaled in the future. In this particular example, the event will be signaled offset
units from the call to Timer.startPeriodic
and then repeated every offset
units infinitely or until call to Timer.stop()
. Return value of Timer.getNow()
doesn't change and increases monotonically regardless of whether the timer is started or not.