Lua Socekt must be use in order to call sleep function in milliseconds.
An example to install Lua Socket to OpenWRT
opkg update
opkg install luasocket
|
An example to sleep 10 milliseconds
require "socket"
socket.sleep(0.010)
|
Lua can only sleep/wait in seconds (not milliseconds) without install Lua Socket. Code below shows the sleep funciton.
function delay_s(delay)
delay = delay or 1
local time_to = os.time() + delay while os.time() < time_to do end end
|
Example to sleep 5 seconds
delay_s(5) |