hi,everyone
    Recently, i have been examining the channel switching time of the telosb. i 
get the switching time is 1.2ms, while the time in the specification is 250us. 
From the paper, i learned that someone measured that the switching time is 
0.34ms. My method is like this, I conducted two sets of experiments, one is of 
no channel switching and the other switches the channel for every packet 
transmission. 1000 packets are transmitted for each set and measure the switch 
time by calculating the difference between these two sets. I don't know where  
the fault is.
Does anyone know how to measure the channel switching time? thank you in 
advance.
My code with switching channel is as followed.
module RadioCountToLedsC @safe() {
  uses {
    interface Leds;
    interface Boot;
    interface Receive;
    interface AMSend;
    interface CC2420Config;
    interface Timer<TMilli> as MilliTimer;
    interface Timer<TMilli> as Timer;
    interface SplitControl as AMControl;
    interface Packet;
  }
}
implementation {
  task void send();
  message_t packet;

  uint16_t counter = 0;
  uint8_t t=20;
  uint16_t id;
  uint16_t dd1, dd2;
  event void Boot.booted() {
    call AMControl.start();
    id = TOS_NODE_ID;
  }

  event void AMControl.startDone(error_t err) {
    if (err == SUCCESS) {
      if(id == 0)
      call MilliTimer.startOneShot(10000);

    }
    else {
      call AMControl.start();
    }
  }

  event void AMControl.stopDone(error_t err) {
    // do nothing
  }

  event void MilliTimer.fired(){
    dd1 = call Timer.getNow();
    post send();
  }

  task void send(){
    radio_count_msg_t* rcm = (radio_count_msg_t*)call 
Packet.getPayload(&packet, sizeof(radio_count_msg_t));
      rcm->counter = counter;
    call AMSend.send(AM_BROADCAST_ADDR, &packet, sizeof(radio_count_msg_t));
}
  
  event message_t* Receive.receive(message_t* bufPtr, 
                   void* payload, uint8_t len) {
    dbg("RadioCountToLedsC", "Received packet of length %hhu.\n", len);
    if (len != sizeof(radio_count_msg_t)) {return bufPtr;}
    else {
//      radio_count_msg_t* rcm = (radio_count_msg_t*)payload;
    call Leds.led2Toggle();
      return bufPtr;
    }
  }

  event void AMSend.sendDone(message_t* bufPtr, error_t error) {
      if(error == SUCCESS){
    call Leds.led0Toggle(); 

      call CC2420Config.setChannel(t);
      call CC2420Config.sync();
    }
    else
    post send();
    counter++;
  }

  event void CC2420Config.syncDone(error_t error){

      if (counter == 1000) {
    dd2 = call Timer.getNow();
    printf("d:%d\n",dd2-dd1);
        printfflush(); 
    return;
      }

      if(t==20)
        t=21;
      else
        t=20;
    post send();
 }
  event void Timer.fired(){}
}
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to