回复: [Tinyos-help] Problem with TinyOS2- =?gb2312?q?x=20tutorial=20lesson=203, =20BlinkToRadio=20telosb=20led=20is?= not blinking

Renee Azhen azhen_renee at yahoo.com.cn
Mon Jan 14 18:59:27 PST 2008


Two motes are needed.
  each one send signal to the other, then they can flash the leds.
   
  Sam

nisha jain <jain61 at gmail.com> 写道:
    Hi All,
   
  I have used code BlinkToRadio for mote communication.
   
  After programming the motes the led is not blinking
   
  Please let me know what is the problem.
   
  Following is the BlinkToRadioC.nc file
   
    #include <Timer.h>
#include "BlinkToRadio.h"
  module BlinkToRadioC {
  uses interface Boot;
  uses interface Leds;
  uses interface Timer<TMilli> as Timer0;
  uses interface Packet;
  uses interface AMPacket;
  uses interface AMSend;
  uses interface Receive; 
  uses interface SplitControl as AMControl;
}
implementation {
    uint16_t counter;
  message_t pkt;
  bool busy = FALSE;
      event void Boot.booted() {
    call AMControl.start();
  }
    event void AMControl.startDone(error_t err) {
    if (err == SUCCESS) {
        call Timer0.startPeriodic(TIMER_PERIOD_MILLI);
   }
   else {
     call AMControl.start();
   }
 }
   event void AMControl.stopDone(error_t err) {
 }
   event void Timer0.fired() {
   counter++;
   if (!busy) {
     BlinkToRadioMsg* btrpkt =
      (BlinkToRadioMsg*)(call Packet.getPayload(&pkt, NULL));
     btrpkt->nodeid = TOS_NODE_ID;
     btrpkt->counter = counter; 
     if (call AMSend.send(AM_BROADCAST_ADDR,
         &pkt, sizeof(BlinkToRadioMsg)) == SUCCESS) {
       busy = TRUE;
     }
   }
 }
   event void AMSend.sendDone(message_t* msg, error_t err) {
   if (&pkt == msg) {
     busy = FALSE;
   }
 }
   event message_t* Receive.receive(message_t* msg, void* payload, uint8_t l
   if (len == sizeof(BlinkToRadioMsg)) {
     BlinkToRadioMsg* btrpkt = (BlinkToRadioMsg*)payload;
     call Leds.set(btrpkt->counter); 
   }
   return msg;
 }
  } 
   
   
   Regards,
  Nisha
   
   

   
_______________________________________________
Tinyos-help mailing list
Tinyos-help at millennium.berkeley.edu
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

       
---------------------------------
雅虎邮箱传递新年祝福,个性贺卡送亲朋! 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://www.millennium.berkeley.edu/pipermail/tinyos-help/attachments/20080115/88f787b2/attachment.htm


More information about the Tinyos-help mailing list