I would like to know the difference between
RTIMER_NOW()
and
clock_time()
function.
- Can I store the values they return in an int variable?
- Do they return the time referred to the whole simulation or to the single mote that call them? If a mote starts its main process 5 sec after the first event in the simulation, does these functions return the value of the simulation or the (value of simulation - 5 sec)?
Thank you.
The two functions:
RTIMER_NOW()
- returns the uptime in real-time timer (rtimer
) ticks modulortimer
overflow value. For example, on a platforms whereRTIMER_ARCH_SECOND
is 32768 and the overflow happens every 2 seconds, the value will always be between 0 and 65535, inclusive.clock_time()
- returns the uptime in clock ticks. Unlike the rtimer ticks, these are monotonic (that is, always nondecreasing). By default there are 128 ticks per second (the constantCLOCK_SECOND
defines this).
Your other questions:
Use
uint32_t
, then values will always fit in a 32-bit integer. Otherwise on platforms whereint
is 16 bits, values of typertimer_ticks_t
and/orclock_time_t
might not fit in it.How do you possibly think that would work? What is the vaulue of "simulation time" when the code is executing on real nodes? The answer is no, the emulated nodes in Cooja have no idea about the "simulation time".
来源:https://stackoverflow.com/questions/45717362/contiki-difference-between-rtimer-now-and-clock-time