15.05.2018, 06:52
Here's a rudimentary server example (resident script, sleep time = 0). Only DMX command is supported, sequences are not supported, universe number is ignored.
Code:
if not server then
mapping = { '32/1/1', '32/1/2', '32/1/3' }
cache = {}
header = 'Art-Net' .. string.char(0, 0, 0x50, 0, 14)
function parse(data)
if #data < 19 then
return
end
if data:sub(1, #header) ~= header then
return
end
local values = data:sub(19)
for i = 1, #values do
local value = values:byte(i)
if mapping[ i ] and cache[ i ] ~= value then
cache[ i ] = value
grp.write(mapping[ i ], value, dt.uint8)
end
end
end
server = require('socket').udp()
server:settimeout(3)
server:setsockname('*', 0x1936)
end
data, err = server:receive()
if data then
parse(data)
end