Alex,

There is a limit to the number of tasks you can post (see tos/platform/sched.c), but I don't think that is your problem.  My guess is that your problem is how things are being interleaved.  I think you want it to run like this.

led on
set timer (25ms)
timer fired
led off
set timer (25ms)
timer fired
led on
...etc

what is probably happening is this

ledon
set timer (25ms)
ledon
set timer (25ms) //this writes over the last timer.
ledon
...etc

Instead you should wait until the timer fires before posting the next task.  Also, make sure you wait after turning it on and after turning it off.  You might also want to make your timer a little longer while debugging.  Flashing at 40Hz is getting pretty close to being imperceptible  (and you might not be able to tell how many times if flashed).

If you insist on doing it in a for loop, you could use TOSH_uwait, but nothing else will be able to execute while you are waiting.

Hope this helps,


Jacob Sorber

Computer Science Department
University of Massachusetts, Amherst


On 11/21/05, Alex Mason <[EMAIL PROTECTED]> wrote:
Hi,

Probably a very simple question (as usual!) but I can't seem to find an
understandable answer.

I was creating a small demo with my motes to show radio comms receiving,
performing a task and then acknowledging completion.  In doing this, I
wanted to flash the Leds quickly in succession.  So, I created a task to do
this - for example:

  task void flashGreen()  {
    call Leds.greenOn();
    call greenTimer.start(TIMER_ONE_SHOT, 25);
    }

...

  event result_t greenTimer.fired()  {
    call Leds.greenOff();
    return SUCCESS;
    }

Then, I can just use "post flashGreen" to flash the Led.  However, the
problem I have is that I want to flash the Led 'n' number of times so I
tried:

for (i = 0; i < n; i++)  {
  post flashGreen;
  }

However, this just flashes the Led once, regardless of the value of 'n'.  I
have the feeling the problem is because of the task being posted too many
times in quick succession - but on the other hand I was under the impression
that tasks are processed FIFO, so I'm a little confused.  Of course, this
isn't a major problem (I don't need the Leds to flash in practice) but it
would be nice to know what is causing the problem for future reference.  I
have tried atomic execution also, but this made no difference (unless I am
using it incorrectly).

Cheers,


----------
Alex Mason
Postgraduate Research
RFID & Wireless Sensor Networks
Liverpool John Moores University

Email: [EMAIL PROTECTED]
Phone: +447886389484

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

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

Reply via email to