Thank you Eric for the detailed explanation! I did not use
VirtualizeTimerC directly at first. But I tried it because I had some
strange problems with a timer and thought the reason could be that I
use to much timers at a time. Now I know that it has to be another
reason. By now I have found a workaround that works in my case (
http://www.mail-archive.com/[email protected]/msg22593.html
).

Thanks again

Nicola

2008/7/29 Eric Decker <[EMAIL PROTECTED]>:
>
>
> On Tue, Jul 29, 2008 at 5:52 AM, Nicola Wegner
> <[EMAIL PROTECTED]> wrote:
>>
>> Hi,
>>
>> I am not sure if I got it right.
>
> Close.
>
>>
>> Does it mean that I do not have to
>> care about virtual timers because they will be used automatically by
>> TinyOS?
>
> Yes it means tinyos will handle the virtualization for you.
>
>>
>> If this is the case then the following code would create virtual
>> timers based on another virtual timer. Right?
>
> Not quite.  You don't want to reference VirtualizeTimerC directly.  You
> want to use Timer<TMilli> and let the platform wiring handle the
> virtualization
> for you.
> Take a look at tinyos-2.x/apps/tutorials/BlinkTask/*
> You'll see something like:
> BlinkTaskAppC.nc:
> configuration BlinkTaskAppC
> {
> }
> implementation
> {
>   components MainC, BlinkTaskC, LedsC;
>   components new TimerMilliC() as Timer0;
>   BlinkTaskC -> MainC.Boot;
>   BlinkTaskC.Timer0 -> Timer0;
>   BlinkTaskC.Leds -> LedsC;
> }
>
> And in BlinkTaskC.nc:
> module BlinkTaskC
> {
>   uses interface Timer<TMilli> as Timer0;
>   uses interface Leds;
>   uses interface Boot;
> }
> implementation
> {
>   task void toggle()
>   {
>     call Leds.led0Toggle();
>   }
>   event void Boot.booted()
>   {
>     call Timer0.startPeriodic( 1000 );
>   }
>   event void Timer0.fired()
>   {
>     post toggle();
>   }
> }
>
> So if you wanted to use three timers you would do something like:
> BlinkTaskC.nc (app)
>   uses interface Timer<TMilli> as Timer0;
>   uses interface Timer<TMilli> as Timer1;
>   uses interface Timer<TMilli> as Timer2;
> And in the wiring:
>   components new TimerMilliC() as Timer0;
>   components new TimerMilliC() as Timer1;
>   components new TimerMilliC() as Timer2;
>   BlinkTaskC.Timer0 -> Timer0;
>   BlinkTaskC.Timer1 -> Timer1;
>   BlinkTaskC.Timer2 -> Timer2;
>
> Where this wires into the underlying layers is via the system component
> TimerMilliC which eventually
> causes VirtualizeTimerC to hook up to the underlying platform timer
> hardware.
> Take a look at:
> tinyos-2.x/tos/system/TimerMilliC.nc
> tinyos-2.x/tos/system/TimerMilliP.nc
> tinyos-2.x/tos/chips/msp430/timer/HilTimerMilliC.nc (I build for telosb)
> tinyos-2.x/tos/chips/msp430/timer/AlarmMilli32C.nc
> etc.
> To follow what is happening, build BlinkTask as follows:
> cd tinyos-2.x/apps/tutorials/BlinkTask
> make verbose telosb
> It will show which files are being pulled in.
> eric
> make
>
>>
>> components new TimerMilliC() as BaseTimer;
>> components new VirtualizeTimerC(TMilli, 5);
>>
>> VirtualizeTimerC.TimerFrom -> BaseTimer.Timer;
>> DbgMessengerP.Timer0 -> VirtualizeTimerC.Timer[0];
>> DbgMessengerP.Timer1 -> VirtualizeTimerC.Timer[1];
>> [...]
>
>
>>
>> Thank you,
>>
>> Nicola
>> _______________________________________________
>> Tinyos-help mailing list
>> [email protected]
>> https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
>
>
>
> --
> Eric B. Decker
> Senior (over 50 :-) Researcher
> Autonomous Systems Lab
> Jack Baskin School of Engineering
> UCSC
>
>
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to