[Tinyos-help] A table of timers

Philip Levis pal at cs.stanford.edu
Fri Mar 30 07:45:56 PDT 2007


On Mar 30, 2007, at 6:32 AM, Romain Thouvenin wrote:

> Hello,
>
> To implement a routing table, I need a number of timers for each
> entry. I may have missed something obvious, but I am not sure about
> how to do that.
>
> At first, I tried to wire all the parameterized interfaces of
> HilTimerMilliC, with something like :
> MyTable { uses interface Timer[uint8_t id]; }
> and :
> MyTable.Timer -> HilTimerMilliC;
>
> This compiles but doesn't seem to work. And I don't want to wire all
> the timers by hand...
>
> I can't see any trick to do that simply. The only solution I can think
> of is adapting VirtualizeTimerC to my needs so that I could use it
> without all the wirings.
>
> I would be very glad to here some suggestions from you, or being
> reminded an obvious solution.

The reason why you need the wirings is you need to tell the timer  
system how many timers there are. Each wiring calls unique() and the  
timer allocates the number of timers using uniqueCount().

But you can instantiate a VirtualizeTimerC with the number of entries  
you have in your routing table, and just wire to it. You can  
virtualize on top of a single underlying TimerMilliC, something like  
this:


component new TimerMillic() as BaseTimer;
component new VirtualizeTimerC as RoutingTimers(TMilli,  
NUM_ROUTING_ENTRIES);

RoutingTableC.Timer -> RoutingTimers;

Phil


More information about the Tinyos-help mailing list