Cannot find the library containing delay()

Discussion to talk about software related topics only.
Post Reply
Lachlanp
Posts: 91
Joined: Tue Jan 29, 2013 4:44 am

Cannot find the library containing delay()

Post 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
SeeCwriter
Posts: 624
Joined: Mon May 12, 2008 10:55 am

Re: Cannot find the library containing delay()

Post 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 );
Lachlanp
Posts: 91
Joined: Tue Jan 29, 2013 4:44 am

Re: Cannot find the library containing delay()

Post 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
SeeCwriter
Posts: 624
Joined: Mon May 12, 2008 10:55 am

Re: Cannot find the library containing delay()

Post 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.
User avatar
TomNB
Posts: 569
Joined: Tue May 10, 2016 8:22 am

Re: Cannot find the library containing delay()

Post 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
Lachlanp
Posts: 91
Joined: Tue Jan 29, 2013 4:44 am

Re: Cannot find the library containing delay()

Post 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
User avatar
TomNB
Posts: 569
Joined: Tue May 10, 2016 8:22 am

Re: Cannot find the library containing delay()

Post by TomNB »

That is correct
Lachlanp
Posts: 91
Joined: Tue Jan 29, 2013 4:44 am

Re: Cannot find the library containing delay()

Post by Lachlanp »

thanks.
works a treat.
Post Reply