This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

While Do loop with delay
#1
Hello.

Since the code below floods my KNX bus, i want to have a delay between each loop. The os.sleep in the code below does not work. Can anyone explaine how i can delay this loop?


while Variable1 == true
do
  Variable2 :write(true)
  os.sleep (10)
end
BR
Kai-Roger
Reply
#2
Use sleep(1) with no space between sleep and ().




Sent from my IN2023 using Tapatalk
Reply
#3
(02.04.2021, 11:49)Tim Wrote: Use  sleep(1) with no space between sleep and ().




Sent from my IN2023 using Tapatalk

Hi.

No that did not work. But i see there is a difference between having no os.sleep and having a os.sleep with any number in the parentheses.
Even if i write os.sleep(10000000), the scrips still writes several telegrams to the bus each second.
BR
Kai-Roger
Reply
#4
What's triggering the script?
All event scripts can run in parallel as many times as they are triggered.
Also it's not os.sleep() just sleep()


Sent from my IN2023 using Tapatalk
Reply
#5
You probably have several instances of the same event script running. Please post the whole script code.
Reply
#6
(02.04.2021, 12:19)Tim Wrote: What's triggering the script?
All event scripts can run in parallel as many times as they are triggered.
Also it's not os.sleep() just sleep()


Sent from my IN2023 using Tapatalk

Hi.

I just made a new small test script, and now i see it is working as it should. I think i had made an event loop that retriggered the script constantly. Thanks for replies. I will see how i can change the way of triggering the script.
BR
Kai-Roger
Reply
#7
No problem

Sent from my IN2023 using Tapatalk
Reply
#8
Is there a difference between os.sleep and sleep? I see os.sleep is used by Erwin in the forum.
BR
Kai-Roger
Reply
#9
I doubt it, probably just aliases.
Tested them now, they seem to work the same way.

Sent from my IN2023 using Tapatalk
Reply
#10
(02.04.2021, 12:37)Tim Wrote: I doubt it, probably just aliases.
Tested them now, they seem to work the same way.

Sent from my IN2023 using Tapatalk

Ok. Thanks.
BR
Kai-Roger
Reply


Forum Jump: