11311 questions

13473 answers


31499 members

0 votes
93 views 0 comments

I'm running a shell script to catch changes in DIN1 pin and then executing some commands.

The catching of the changes need to be rather responsive so I would like to poll the pin about 10 times per second.

So I have a while loop with reading from the gpio.

In most shells I would use

   $ sleep 0.1

somewhere in the loop.  However it seem only to take integer seconds which is way too much.

I need some other mean of creating a pause that does not take all the resources.

If not, I will have to let it run at full speed. But that causes the load average go way above 1.0 which I do not like in the long run.

I can nice it and the load stays at 1.0. But then the responsiveness can be bad when other loads on the RUT are heavy.

So is there an alternative to "sleep" for making a delay?



1 Answer

0 votes
Install coreutils-sleep, you'll have the full-featured GNU sleep. From a ssh or CLI console;

opkg update

opkg install coreutils-sleep.

Best answer