You might try putting the sendData() in a separate task. I think fired()
runs in an interrupt context and send... may take a while to run. Also
try it with a fixed and small Timer count value, you may be setting
things in correctly with the Random calculation.

MS

Chao Sun wrote:
Hi,
I'm writing a simple program on a micaz mote, which receive the query from another mote, sense the environment, and transmit the data back to that mote. I used the PhotoTemp module in the tinyos-1.x, and when I wire the ADC interface to Photo, the program works OK. However, when I wire the ADC interface to Temp, it seems that the program receive the query just for the first time. Afterwards, it can not receive any query, and the program is halted.
Could someone help me to solve this problem? Many thanks!

Chao

The core part of my program is as follow:

task void dataTask()
  {
      uint16_t count;
      count = call Random.rand();
      count = (count/65535) * 1000;
      atomic{
          DataPtr->sourceID =  TOS_LOCAL_ADDRESS;
          DataPtr->type = currentDataType;
      }
      call fireTimer.start(TIMER_ONE_SHOT, count);
  }


  event result_t fireTimer.fired()
  {
      if (destID != TOS_LOCAL_ADDRESS)
{ call sendData.send(destID, sizeof(struct DataMsg), &data_packet);
          call Leds.greenToggle();
      }
      return SUCCESS;
  }

  event TOS_MsgPtr recvReq.receive(TOS_MsgPtr m)
  {
      uint16_t temp;
      call Leds.redToggle();
      ReqPtr = (struct ReqMsg*)m->data;
      temp = ReqPtr->seqNo;
      if (temp != lastSeq)
      {
          lastSeq = temp;
          destID = ReqPtr->sourceID;
currentDataType = DT_TEMP; call tempADC.getData();
       }                return m;
  }

  async event result_t tempADC.dataReady(uint16_t data)
  {
       atomic{
          DataPtr = (struct DataMsg*)data_packet.data;
          DataPtr->data = data;
          post dataTask();
   }
      return SUCCESS;
  }
    event result_t sendData.sendDone(TOS_MsgPtr msg, bool success)
  {
          return SUCCESS;
  }

_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

--
Platform: WinXP/Cygwin
TinyOS version: 1.x, Boomerang
Programmer: MIB510
Device(s): Mica2, MicaZ, Tmote
Sensor board: homebrew

_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to