[Tinyos-help] [TinyOS-2.x] CollectionSenderC.send() command is not working

Peizhao Hu peizhao at itee.uq.edu.au
Sat Jun 9 01:11:17 PDT 2007


Sorry to re-post again,

in addition to previous question, i tried to modify my application with 
checking package size before enter send command.

regdata_t regdata;
message_t regMsg;

void registration()
  {
    if(regCount > 0)
      {
        if(!sendbusy && sizeof(regdata) <= call 
SensDataRoot.maxPayloadLength())
        {
           /* send out registration */
           regdata_t *regData = (regdata_t*)call 
SensDataRoot.getPayload(&regMsg);
           regData->id = TOS_NODE_ID;
           //regData->count = regCount;
           if(call SensDataRoot.send(&regMsg, sizeof(regdata)) != SUCCESS)
                errorLed();
           else
           {
                sendbusy = TRUE;
                regCount--;
           }
        }
        regCount--;
      }
    else
      {
        call Leds.led2On();
        /* goto sleep mode */
        op_commands.operate = OP_MODE_SLEEP;
        op_commands.op_interval = SLEEP_INTERVAL;
        startTimer();
      }
  }


// message type of regdata_t
  typedef nx_struct regdata {
    nx_uint16_t id;
  } regdata_t;

why regdata is big than the max payload of SensDataRoot ()
sizeof(regdata) <= call SensDataRoot.maxPayloadLength()

  components new CollectionSenderC(COL_SENSDATA) as SensDataSender;
  NRCMSNodeC.SensDataRoot -> SensDataSender;

I also tried to increase the message size by MSG_SIZE=50 as well, but it 
doesn't work.



Peizhao Hu wrote:
> Dear TinyOS developers,
>
> I followed the AntiTheft and TestCollection examples provided by 
> TinyOS 2.0.1 to create my own application.
>
> I have a timer, which triggers the following registration function in 
> some intervals. I have verified that the code basic triggering is 
> working. however, when I added the sending codes, the error led is 
> toggled at every timer fired. so it does mean the send command didn't 
> return SUCCESS.
>
> void registration()
>  {
>    if(regCount > 0)
>      {
>        if(!sendbusy)
>        {
>           /* send out registration */
>           sensdata_t *regData = (sensdata_t*)call 
> SensDataRoot.getPayload(&sensdataMsg);
>           regData->nodeid = TOS_NODE_ID;
>           regData->count = regCount;
>           if(call SensDataRoot.send(&sensdataMsg, sizeof(sensdata)) != 
> SUCCESS)
>                errorLed();
>           else
>           {
>                sendbusy = TRUE;
>                regCount--;
>           }
>        }
>      }
>    else
>      {
>        call Leds.led2On();
>        /* goto sleep mode */
>        op_commands.operate = OP_MODE_SLEEP;
>        op_commands.op_interval = SLEEP_INTERVAL;
>        startTimer();
>      }
>
>
> the Configuration part, where COL_SENSDATA=11:
>
>  /* Collection */
>  components CollectionC;
>  NRCMSNodeC.CollectionControl -> CollectionC;
>
>  components new CollectionSenderC(COL_SENSDATA) as SensDataSender;
>  NRCMSNodeC.SensDataRoot -> SensDataSender;
>
> My deployment platform is Ubuntu + TinyOS 2.x (ubuntu package).
>
> any idea?
>

-- 
regards;

Peizhao



More information about the Tinyos-help mailing list