Page 1 of 1
Cannot find the library containing delay()
Posted: Tue Apr 11, 2017 6:59 am
by Lachlanp
page 297 of the Runtime Libraries manual indicates a function delay() that gives a precise task delay in the sub-microseconds. It is in section 23 of the manual under the heading of HiResTimer.
I am using Netburner IDE 2.8.2 and #include <HiResTimer.h> doesnt work (neither does #include <delay.h>)
what library do I need to include to get delay() working ?
thanks
Re: Cannot find the library containing delay()
Posted: Tue Apr 11, 2017 7:34 am
by SeeCwriter
You only need to include HiResTimer.h. Are you sure you are using it correctly?
Code: Select all
HiResTimer *hrt;
hrt = HiResTimer::getHiResTimer(0);
hrt->init();
hrt->delay( delayTime );
Re: Cannot find the library containing delay()
Posted: Tue Apr 11, 2017 7:50 am
by Lachlanp
I don't want to use the HiResTimer. I want to use the delay().
This is defined in section 23.12 of the Runtime Library Manual on page 297.
The usage is delay(x) where x seconds, and it is a double and should be in the range of around 0.0002 - 0.05 (after that OSTimeDly() can be used)
Lachlan
Re: Cannot find the library containing delay()
Posted: Tue Apr 11, 2017 8:11 am
by SeeCwriter
We must be looking at different manuals. The Runtime Library manual from v2.8.2 that I have has no section 23.12, and on page 297 is section 24.20 AsciiToIp.
And a search of the manual shows only one delay function, the one in the HiResTimer.
Re: Cannot find the library containing delay()
Posted: Tue Apr 11, 2017 8:47 am
by TomNB
Hello Lachlanp,
You might need to read the hires timer section again. SeeCwriter is correct, I do not see the function you are referring to on that page. The hires timer is a C++ class with a member function called delay() if that is what you are referring to. But you have to use it as part of a hires timer object. In C++ you can't just call a member function without the object.
There is an example in \nburn\examples\StandardStack\utils\HiResTimerDemo
Re: Cannot find the library containing delay()
Posted: Tue Apr 11, 2017 9:12 am
by Lachlanp
OK. That's clear.
Just confirming that:
- the delay function is only blocking on the current task and does not block other tasks?
- we can have delays that are less than the system tick? e.g 0.01 = 10mS
Thanks
Lachlan
Re: Cannot find the library containing delay()
Posted: Tue Apr 11, 2017 11:21 am
by TomNB
That is correct
Re: Cannot find the library containing delay()
Posted: Tue Apr 11, 2017 11:43 am
by Lachlanp
thanks.
works a treat.