[Tinyos-help] SendMsg.Send & GenericComm

Michael Schippling schip at santafe.edu
Thu Nov 1 10:25:15 PDT 2007


I thought this would be simple, but I'm finding some inconsistent
usages in the demo apps and some of my own code...Anyway the working
examples (say, Oscilloscope) that I have for T1 do this:

In the config file:
   OscilloscopeM.CommControl -> GenericComm;

Init the Comm system in the main Module:
   command result_t StdControl.init()
   {
     ...
     call CommControl.init();
     ...
   }

Otherwise your code looks like it should work fine.

You can also try putting a dbg line in timer.fired() to see if it works.

MS



Antonio C wrote:
> Hi all,
> i was trying to implement an application that uses SendMsg interface.
> I have looked previous posts (especially Event SendMsg.sendDone, may 2005)
> and i have copied and pasted the code inside my application
> Now, when i execute the application, it seems like to be in an infinite 
> loop, with an output like this
> 
> 
> 2: CLOCK: Setting clock rate to interval 231, scale 3
> 2: malloc data entry for clock event: 0xa05fbd0
> 2: UART initialized.
> 2: RANDOM_LFSR initialized.
> 2: malloc channel mon event.
> 2: malloc Channel Mon event data.
> 2: AM Module initialized
> 2: LEDS: initialized.
> 2: CLOCK: Setting clock rate to interval 231, scale 3
> 2: malloc data entry for clock event: 0xa05fc48
> 2: UART started.
> 2: Popping event for mote 2 with time 0:0:1.89305375.
> 2: Setting TOS_LOCAL_ADDRESS to 2
> 2: RADIO: Channel Mon event handled for mote 2 at 0:0:1.89305375 with 
> interval of 200.
> 2: RFM: Mote 2 got bit 0
> 2: Popping event for mote 2 with time 0:0:1.89470375.
> 2: Setting TOS_LOCAL_ADDRESS to 2
> 2: RADIO: Channel Mon event handled for mote 2 at 0:0:1.89470375 with 
> interval o
> f 200.
> 2: RFM: Mote 2 got bit 0
> 2: Popping event for mote 2 with time 0:0:1.89475375.
> 2: Setting TOS_LOCAL_ADDRESS to 2
> 2: RADIO: Channel Mon event handled for mote 2 at 0:0:1.89475375 with 
> interval o
> f 200.
> 2: RFM: Mote 2 got bit 0
> etc etc
> 
> So, even if in the code there is a timer which calls the event 
> timer.fired(), this event  never happens and so SendMsg.Send is never 
> called!!!!
> However, i have found the problem: if i delete the line
> Main.StdControl->Comm.Control
> in test.nc everything works, but the event SendMsg.sendDone isn't throw, 
> and i don't want it!!!
> What can i do?
> Below i post the code of the appication
> 
> thanks
> Antonio
> 
> //----------
> //test.h
> //----------
> enum
> {
>   AM_TEST=38
> };
> 
> typedef struct testMsg
> {
>  
>  uint16_t addr; //address of the mote that has to answer
>   uint16_t cnt; //counter
>   uint16_t src; // source address
> } testMsg;
> 
> //-----------
> // end test.h
> //-----------
> 
> 
> //--------------
> //testM.nc
> //--------------
> includes test;
> 
> module testM {
>        provides interface StdControl;
> 
>        uses interface SendMsg;
>        uses interface ReceiveMsg;
>        uses interface Timer;
>        uses interface Leds;
> }
> implementation {
>         struct TOS_Msg local_msg;
>         int counter;
> 
>         task void SendPacket(){
>             testMsg *message = (testMsg *)local_msg.data;
>              message->addr = TOS_BCAST_ADDR;
>              message->cnt = counter;
>              atomic {
>                message->src = TOS_LOCAL_ADDRESS;
>              }
>              if (call SendMsg.send(TOS_BCAST_ADDR, sizeof(testMsg), 
> &local_msg))
>              {
>                
>  dbg(DBG_USR1, "Send Packet\n");
>                 call Leds.redToggle();
>              }
>         }
> 
>         command result_t StdControl.init() {
>                 call Leds.init();
>                 return SUCCESS;
>         }
> 
>         command result_t StdControl.start() {
>                  call Timer.start( TIMER_REPEAT, 1000 );
>                  return SUCCESS;
>         }
> 
>         command result_t StdControl.stop() {
>                  call Timer.stop();
>                  return SUCCESS;
>         }
> 
>         event result_t Timer.fired() {
>               counter++;
>               post SendPacket();
>               return SUCCESS;
>         }
> 
>         event TOS_MsgPtr ReceiveMsg.receive( TOS_MsgPtr msg ) {
>               atomic {
>                       dbg(DBG_USR1, "Packed Received\n");
>               }
>               return msg;
>         }
> 
>         event result_t SendMsg.sendDone(TOS_MsgPtr sent,
>  result_t success) {
>                        dbg(DBG_USR1, "Packet Send Done\n");
>           return SUCCESS;
>         }
> 
> }
> //-----------------
> // end testM.nc
> //---------------
> 
> //----------
> // test.nc
> //----------
> includes test;
> 
> configuration test {
> 
> }
> implementation {
>         components Main, testM, GenericComm as Comm, TimerC, LedsC;
> 
>         Main.StdControl -> testM.StdControl;
>         Main.StdControl -> TimerC.StdControl;
> 
>         testM.SendMsg -> Comm.SendMsg[AM_TEST];
>         testM.ReceiveMsg -> Comm.ReceiveMsg[AM_TEST];
>         testM.Timer -> TimerC.Timer[unique("Timer")];
>         testM.Leds -> LedsC;
> } 
> 
> 
> ------------------------------------------------------------------------
> ------------------------------------------------------------------------
> L'email della prossima generazione? Puoi averla con la nuova Yahoo! Mail 
> <http://us.rd.yahoo.com/mail/it/taglines/hotmail/nowyoucan/nextgen/*http://it.docs.yahoo.com/nowyoucan.html> 
> 
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Tinyos-help mailing list
> Tinyos-help at Millennium.Berkeley.EDU
> https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help


More information about the Tinyos-help mailing list