Hi again,

this is what i typed:

***********************************
BlinkToRadioAppC.nc

#include <Timer.h>
#include "BlinkToRadio.h"

configuration BlinkToRadioAppC{
}

implementation{

components MainC;
components LedsC;
components BlinkToRadioC as App;
components new TimerMilliC() as Timer0;
components ActiveMessageC;
components new AMSenderC(AM_BLINKTORADIO);
components new AMReceiverC(AM_BLINKTORADIO);

App.Boot->MainC;
App.Leds->LedsC;
App.Timer0->Timer0;
App.Packet->AmSenderC;
App.AMPacket->AMSenderC;
App.AMSend->AMSenderC;
App.AMControl->ActiveMessageC;
App.Receive->AMReceiverC;

}

*********************************
BlinkToRadio.h

#ifndef BLINKTORADIO_H
#define BLINKTORADIO_H

enum{
    AM_BLINKTORADIO = 6;
    TIMER_PERIOD_MILLI = 250;
};

typedef nx_struct BlinkToRadioMsg{

  nx_uint16_t nodeid;
  nx_uint16_t counter;

}BlinkToRadioMsg;

#endif

****************************************
BlinkToRadioC.nc

#include<Timer.h>
#include "BlinkToRadio.h"

module BlinkToRadioC{

  uses interface Boot;
  uses interface Leds;
  uses interface Timer<Milli> as Timer0;
  uses interface Packet;
  uses interface AMPacket;
  uses interface AMSend;
  uses interface SplitControl as AMControl;
  uses interface Receive;
}

implementation{

  bool busy = FALSE;
  message_t pkt;

  uint16_t counter = 0;

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 AMSend.sendDone(message_t* msg, error_t error){
     if(&pkt == msg){
       busy == FALSE;
     }
   }

   event void timer0.fired(){
     counter++;
     call Leds.set(counter);

     if(!busy){
       BlinkToRadioMsg* btrpkt = (BlinkToRadioMsg*)(call
Packet.getParload(&pkt, NULL));
       btrpkt->nodeid=TOS_NODE_ID;
       btrpkt->counter=counter;
       if(call AMSend.send(AM_BROADCAST_ADDR, &pkt,
sizeof(BlinkToRadioMsg))==SUCCESS){
       busy = TRUE;
       }
     }
   }

   event message_t* Receive.receive(message_t* msg, void* payload, uint8_t
len){
     if(len==sizeof(BlinkToRadioMsg)){
       BlinkToRadioMsg*btrpkt=(BlinkToRadioMsg*)payload;
       call Leds.set(btrpkt->counter);
     }
     return msg;
   }
}





2008/12/16 Miguel Silva <[email protected]>

>
>
>
> Hi, i'm having a problem compiling lesson 3 of the tutorial, as i keep
> getting the  following error:
>
> cp: cannot stat 'build/micaz/main.srec': No such file or directory
>
> make: *** [setid] Error 1
>
> I think i wrote everything according to the tutorial, can anyone help?
>
> Thanks in advance,
>
> Miguel Silva
>
>
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to