Hi,

Im writing a simple application to test send and receive of motes
.AMSend.send command works but AMSend.sendDone event isn't signaled after
sending so the busy flag does'nt change to false. and in the next time the
AMSend.send command does not return SUCCESS .
this is my code :

event void Boot.booted() {
dbg("Boot","Booted at time %s .\n",sim_time_string());
call AMControl.start();
}

event void AMControl.startDone(error_t err)
{
dbg("Control","AMControl started %s .\n",sim_time_string());
  if(err == SUCCESS) {
   if(TOS_NODE_ID == 1 ) {
    dbg("Base","This is the base station...ready for sending packets
%s.\n",sim_time_string());
    call Timer.startPeriodic(TIMER_DELAY);
    }
}
  else
   call AMControl.start();
}

event void AMControl.stopDone(error_t err)
{

}

event void Timer.fired()
{

   if(!busy)
      {


          RbsMsg*  data =  (RbsMsg*) ( call
Packet.getPayload(&pkt,sizeof(RbsMsg)));
          data->count = counter;
           if( call AMSend.send(AM_BROADCAST_ADDR,&pkt,sizeof(RbsMsg)) ==
SUCCESS)
           {
             dbg("Base","Packet sent %s.\n",sim_time_string());
             busy= TRUE;
             counter++;
            }
    else
       dbg("Base","was not SUCCESSFULL %s .\n",sim_time_string());

}

}

--------------------
event void AMSend.sendDone(message_t* bufPtr, error_t error)
{

    if (&pkt == bufPtr) {
      busy = FALSE;
      dbg("Base","send Done %s .\n",sim_time_string());
    }

}

and this is my simulation code with python :

#! /usr/bin/python

import sys
import random
from TOSSIM import *
t = Tossim([])
r = t.radio();

for i in range (0, 3):
 m = t.getNode(i);
 m.bootAtTime(1000 * i+ 1);

r.add(1, 0, -54.0);
r.add(1, 2, -54.0);
r.add(0, 2, -20.0);
r.add(2, 0, -20.0);


t.addChannel("Boot",sys.stdout);
t.addChannel("Base",sys.stdout);
t.addChannel("Receive",sys.stdout);
t.addChannel("Control",sys.stdout);

for i in range(0, 20000):
  t.runNextEvent();


Would you help me please? i really need your helps.

Regards,
-- 
Mojtaba Raznahan
BS of Computer engineering
TMU university
www.raznahan.com
_______________________________________________
Tinyos-help mailing list
Tinyos-help@millennium.berkeley.edu
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to