[Tinyos-help] absolute timer

Roberto Pagliari paglia.tinyos at gmail.com
Sat Dec 9 08:13:25 PST 2006


Hi All,
I tried to use absolute timer to substitute a common repeated timer.
Below there is the code but I do not understand why the event
myClock.fired never happens. Thank you

implementation {
   tos_time_t next_time;
   tos_time_t actual_time;

   command result_t StdControl.init() {
      call Leds.init();
      call Leds.yellowOff(); call Leds.redOff(); call Leds.greenOff();
      return SUCCESS;
   }

   command result_t StdControl.start() {
      actual_time = call TimeUtil.create(0, call Time.getLow32());
      next_time = call TimeUtil.add(actual_time, call
TimeUtil.create(0, PERIOD) );
      call myClock.set(next_time);
      return SUCCESS;
   }

   command result_t StdControl.stop() {
      return SUCCESS;
   }

   event result_t myClock.fired() {
      call Leds.greenOn();
      actual_time = call TimeUtil.create(0, call Time.getLow32 ());
      next_time = call TimeUtil.add(actual_time, call
TimeUtil.create(0, PERIOD) );
      call myClock.set(next_time);

      return SUCCESS;
   }
}


More information about the Tinyos-help mailing list