Hi everyone

I am trying to implement the Oscilloscope application with threads. I am
having some issues with it.
I am sending the code, please help me on this.

event void MainThread.run(void* arg)
{
     while (call RadioStdControl.start() != SUCCESS);
     for (;;)
    {
         if (call BlockingReceive.receive(&recvbuf, 0) == SUCCESS)
        {
              oscilloscope_t *recv_o = (oscilloscope_t *) call
BlockingReceive.getPayload(&recvbuf, sizeof(oscilloscope_t));
              call Leds.led2On();
              if (recv_o->version > local.version)
             {
                    local.version = recv_o->version;
                    local.interval = recv_o->interval;
                    call Leds.led1On();
            }
             if (recv_o->count > local.count)
           {
                    local.count = recv_o->count;
                    suppressCountChange = TRUE;
                    call Leds.led2On();
           }
      }

     if (reading == NREADINGS)
    {
          oscilloscope_t *o = (oscilloscope_t *) call
BlockingSend.getPayload(&sendbuf, sizeof(oscilloscope_t));
          memcpy(o, &local, sizeof(oscilloscope_t));
           if (call BlockingSend.send(&sendbuf, sizeof(oscilloscope_t)) ==
SUCCESS)
          {
                   local.count++;
                   report_sent();
          }
          else
         {
                report_problem();
         }
         //reading = 0;
    }
    if (call BlockingRead.read(&var) == SUCCESS)
    {
        local.readings[reading++] = var;
    }
    call MainThread.sleep(local.interval);
}


Please  chech this out.

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

Reply via email to