07.05.2024, 13:17
(07.05.2024, 13:07)admin Wrote: Try this:
Code:if not server then mapping = { [1] = '32/1/1', [2] = '32/1/2', [3] = '32/1/3', } server = require('socket').udp() server:settimeout(1) server:setsockname('*', 0x1936) header = 'Art-Net' .. string.char(0, 0, 0x50) values = {} function parse(data) local count, value if #data < 19 or data:sub(1, #header) ~= header then return end local univlo, univhi = data:byte(15, 16) local universe = univhi * 256 + univlo if universe ~= 3 then return end count = #data - 18 for i = 1, count do value = data:byte(i + 18) if value ~= values[ i ] then values[ i ] = value if mapping[ i ] then grp.update(mapping[ i ], value) end end end end end data = server:receive() if data then parse(data) end
When logging the "server" variable i get this status: udp{unconnected}: 0xb6e42ac0