Imp.wakeup() behaviour

Hi guys,

We’re trying to resolve a stubbing issue with our imp.wakeup() test harness and just wished to clarify the behaviour. In the documentation it states that the timer supports durations up to 2^30 centiseconds, however I don’t believe this is possible at centisecond accuracy with a 32-bit float?

Are you able to provide an indication of the under-the-hood behaviour so that we can mimic this as best as possible in our test harness?

Many thanks

You are correct, it is not centisecond-accurate for very large time offsets, due to the limited precision of 32-bit floats.

In current releases, the timeout in Squirrel’s imp.wakeup(n,…) on the device is given in centiseconds by the C expression ceilf((float)n*100)+1, except that it’s 0cs if n=0, and it’s capped at 2^30cs.

On the agent the timeout in centiseconds is given by the C expression max(2,(double)n*100).

The rounding to centiseconds is for historical reasons (early improm versions used a RTOS where that was the finest timer resolution available) but is hard now to change without breaking existing code.

Peter

1 Like