ADD: added a simple sleep function. Thanks to Mosci

This commit is contained in:
iceman1001 2016-02-23 08:24:01 +01:00
parent cd0bed3c98
commit b9411ebac8

View file

@ -82,8 +82,8 @@ local Utils =
return nil return nil
end, end,
------------ CRC-16 ccitt checksums ------------ CRC-8 Legic checksums
-- Takes a hex string and calculates a crc16 -- Takes a hex string and calculates a crc8
Crc8Legic = function(s) Crc8Legic = function(s)
if s == nil then return nil end if s == nil then return nil end
if #s == 0 then return nil end if #s == 0 then return nil end
@ -301,6 +301,15 @@ local Utils =
return n return n
end, end,
-- a simple implementation of a sleep command. Thanks to Mosci
-- takes number of seconds to sleep
Sleep = function(n)
local clock = os.clock
local t0 = clock()
while clock() - t0 <= n do end
return nil
end,
-- function convertStringToBytes(str) -- function convertStringToBytes(str)
-- local bytes = {} -- local bytes = {}
-- local strLength = string.len(str) -- local strLength = string.len(str)