Hi everyone,

I am using TOSSIM on tinyos-1.x and simulating for mica2, cricket platform.
I am unable to get a timer to work. I start a timer then have an "event
timer.fired()". I tried to verify this works in tossim using a debug
message. But the debug message inside the timer.fired() event doesnt get
printed out. How can I print it out in tossim?

The timer started message in StdControl.start()  prints out correctly in
tossim. But the message in Timer.fired() isn't printed out.  How can  I
print it out? This also indirectly means that even if i have a Timer.fired()
event in the code its not triggered. But shouldnt it be triggered??!!!!!!


My code is given below
--------------------------------------------------------------------------------------------------------------------

includes IntMsg;
#define SYN1 0x0f
#define data_package 20

module ReceiverM
{
  uses {
    interface StdControl as RadioSubControl;
    //interface StdControl as UartSubControl;
    //interface SendMsg as Send;
    interface BareSendMsg as RadioSend;
    interface ReceiveMsg as Receive;
    interface Leds;
    //interface RadioCoordinator as RadioReceiveCoord;
    //interface UltrasoundControl;

    //new additions
    interface Timer;

  }
  provides {
    interface StdControl;
  }
}



implementation
{
      bool pending=FALSE;
      TOS_Msg data;
      int counter=0;

      // State variable
      uint8_t got_id = 0;
      uint8_t detector_is_on = 0;

      uint16_t us_time = 0;
      uint16_t time[data_package];


      command result_t StdControl.init() {

        atomic pending = FALSE;

        //enable rs-232
        //TOSH_CLR_US_IN_EN_PIN();
        //TOSH_SET_BAT_MON_PIN();

        // Wait until the RS-232 start
        TOSH_uwait(2000);

        call RadioSubControl.init();
       // call UartSubControl.init();

        return SUCCESS;
      }

      command result_t StdControl.start()
      {
        //call UltrasoundControl.SetGain(50);
          //prashan need to reset this to 1ms



        call Timer.start(TIMER_REPEAT,100);
        dbg(DBG_TIME, "Timer started\n");
        call RadioSubControl.start();

        return SUCCESS;
      }


        command result_t StdControl.stop()
      {
        call RadioSubControl.stop();
        dbg(DBG_TIME, "Timer stopped\n");
        call Timer.stop();
        //call UartSubControl.stop();
        return SUCCESS;
      }


      event result_t Timer.fired(){


        dbg(DBG_TIME, "Timer started\n");
        /*
        IntMsg *message = (IntMsg *)data.data;
        counter++;


        call Leds.yellowToggle();


        if (!pending&&counter==10)
          {
        pending = TRUE;

            data.addr = TOS_BCAST_ADDR;
            data.type = SYN1;
            data.length = sizeof(IntMsg);
            message->val = counter;
            message->src = TOS_LOCAL_ADDRESS;

        //message->status=status;
        //message->nodeid=nodeid;
        //message->targetid=targetid;
        //message->first_node=first_node;

        call Leds.yellowToggle();

        if (call RadioSend.send(&data))
        {
          dbg(DBG_TEMP, "Message sent\n");
          return SUCCESS;
        }


        pending = FALSE;
          }
    */

        return SUCCESS;//FAIL;
  }




      task void SendTaskRadio()
      {
            IntMsg *message = (IntMsg *)data.data;

              if(!pending)
        {
            atomic pending = TRUE;


        atomic{
                message->val = us_time;
        }
            data.addr = TOS_BCAST_ADDR;
        data.type = AM_INTMSG;            //prashan why do u need to have
have that
            data.length = sizeof(IntMsg);
        data.group = AM_INTMSG;
            message->src = TOS_LOCAL_ADDRESS;
        message->type = 1;

        if (call RadioSend.send(&data))
            return;

            atomic pending = FALSE;

        }

      }


      event result_t RadioSend.sendDone(TOS_MsgPtr msg, result_t success){
        atomic{
                if (pending && msg == &data)
                  {
                call Leds.redToggle();
                pending = FALSE;
                  }
        }
        return SUCCESS;
      }


       event TOS_MsgPtr Receive.receive(TOS_MsgPtr rdata) {
        dbg(DBG_TEMP, "Message received\n");
        return rdata;
       }

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

Reply via email to