[Tinyos-help] Behaviour of CntToLeds

mala rangarajan maalaa at gmail.com
Thu Mar 17 01:25:26 PST 2005


Hi,

I tried some tests to understand the behaviour of nesC events signalling.

For this I modified the good old CntToLeds and the associated libraries.
I made a counterTest.nc, which is equivalent to counter.nc.   Here
instead of incremeting the variable state in Timer.fired event, I
incremented it in the  IntOutput.outputComplete.

  event result_t Timer.fired()
  {
    if (call IntOutput.output(state))
    {
      //state++;                      //COMMENTED OUT
    }
    return SUCCESS;
  }


  event result_t IntOutput.outputComplete(result_t success) 
  {

    state++;                      // ADDED THIS STATEMENT HERE
    if(success == 0) state --;
    return SUCCESS;
  }


In count to Leds I did the same as before

  CounterTest.IntOutput -> IntToLeds;


This worked as expected.  The counter incremented 1,2,3.....

The next changed I tried is to connect CounterTest.IntOutput to IntToLeds twice.
  CounterTest.IntOutput -> IntToLeds;
  CounterTest.IntOutput -> IntToLeds;
Here I expected the counter to increment 1,3,5,7 etc..., as I will be
getting back two outputComplete events.  But what happened is that the
counter incremented 1, 5, 9, 13.... (INCREMENTED BY 4 instead of 2).

Can anybody explain this?  I went into app.c and checked the code that
gets actually generated.  It is as follows:


result_t CounterTest$IntOutput$outputComplete(result_t success)
{

  CounterTest$state++;
  if (success == 0) {
#line 86
    CounterTest$state--;
    }
#line 87
  return SUCCESS;
}

inline static  result_t IntToLedsM$IntOutput$outputComplete(result_t
arg_0xa551c90){
#line 65
  unsigned char result;
#line 65

#line 65
  result = CounterTest$IntOutput$outputComplete(arg_0xa551c90);
#line 65
  result = rcombine(result,
CounterTest$IntOutput$outputComplete(arg_0xa551c90));
#line 65

#line 65
  return result;
#line 65
}

I dont see anything out of ordinary here that can explain why the
variable state is getting incremented by 4 instead of 2.  If anyone
else understands this, kindly explain.

Regards,
Mala


More information about the Tinyos-help mailing list