Hey everyone -

I'm working on some radio code for the telosB motes. Specifically, my code
calls AMSend.send(), and via the printf library, I've proved that it returns
SUCCESS.

Unfortunately, the event for sendDone never gets called.

I've heard that this can be caused due to ack issues, so for now, I've
tossed a

#define CC2420_NO_ACKNOWLEDGEMENTS

right after my include statements.

Anyone have any other ideas of what can cause this?

----------- Code Below ---------------
#include "SensorMsg.h"
#include "printf.h"

#define CC2420_NO_ACKNOWLEDGEMENTS

module Uint8_tSenderC{
provides
{
 interface ByteSend;
}

uses{
interface Leds;
 interface AMSend;
interface SplitControl as AMControl;
interface Packet;
 interface AMPacket;
interface Resource as RadioResource;
}
 }

implementation{
bool busy = FALSE;
 uint8_t sendVal;

event void AMSend.sendDone(message_t *msg, error_t error){
 error_t retVal;
 printf("AMSend.sendDone(%p, %u)", msg, error);
 printfflush();
 call Leds.led1On();
 if(error == SUCCESS)
{ call Leds.led2Toggle();
 retVal = call AMControl.stop();
while(!(retVal == SUCCESS || retVal == EALREADY ))
{
 retVal = call AMControl.stop();
}
}
else
 {
call AMSend.send(AM_BROADCAST_ADDR, msg, sizeof(SensorMessage_t));
}
 }

event void AMControl.startDone(error_t error){
error_t retVal;
 message_t msgBuf;
 printf("AMControl.startDone started. Parameter: %u. SendVal:%u\n",error,
sendVal);
 printfflush();
 if(error == SUCCESS)
{

if(!busy)
{
 SensorMessage_t * payload;
 payload  = (SensorMessage_t *) call Packet.getPayload(&msgBuf,
sizeof(SensorMessage_t));
payload->nodeId=TOS_NODE_ID;
 payload->sensorType=0x01;
payload->msgType=0x03;
payload->msgValue= sendVal;
 busy = TRUE;
 printf("Payload of %u packed into message buffer at %p\n", sendVal,
&msgBuf);
 printfflush();
 retVal = call AMSend.send(AM_BROADCAST_ADDR, &msgBuf,
sizeof(SensorMessage_t));
 printf("AMSend.send() returned %u\n", retVal);
printfflush();
 while(retVal != SUCCESS)
{
if(retVal == EBUSY)
 {
call Leds.led1On();
}
if(retVal == FAIL)
 {
call Leds.led1On();
}
 printf("AMSend.send() returned %u\n", retVal);
printfflush();
 retVal = call AMSend.send(AM_BROADCAST_ADDR, &msgBuf,
sizeof(SensorMessage_t));
}
 printf("AMSend.send() returned SUCCESS\n");
printfflush();
 call Leds.led2On();
}
}
else
 {
printf("AMSend.send() restarted!\n");
printfflush();
 call AMControl.start();
}
}

event void RadioResource.granted(){
 error_t retVal;
   retVal = call AMControl.start();
 while(!(retVal == SUCCESS || retVal == EALREADY ))
{
retVal = call AMControl.start();
 }

}

event void AMControl.stopDone(error_t error){
call RadioResource.release();
signal ByteSend.sendDone();
 }

command error_t ByteSend.doSend(uint8_t toSend){
error_t ret;
 if(!busy)
{
  printf("Attempting to send %u\n", toSend);
printfflush();
 sendVal = toSend;
 ret = call RadioResource.request(); //immediateRequest();
  while(ret != SUCCESS)
 {
printf("RadioResource.request() failed with status %u\n", ret);
printfflush();
 ret = call RadioResource.request(); //immediateRequest();
}
printf("RadioResource.request() returned SUCCESS\n");
 printfflush();
call Leds.led0On();
}
 else
{
ret = FALSE;
}
 return ret;
}
}
----------- Code Above ----------------
_______________________________________________
Tinyos-help mailing list
Tinyos-help@millennium.berkeley.edu
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to