14.05.2018, 06:28
Here's a simplified function. Change universe number as needed, sequence and physical parameters can probably be zero. Value is the output channel value ranging from 0 to 255.
Code:
function artnet_dmx(ip, sequence, physical, universe, data)
local cmd = string.char(
-- null byte
0,
-- ARTNET_DMX opcope
0, 0x50,
-- protocol version 14
0, 14,
-- sequence number is used to ensure that ArtDmx packets are used in the correct order
bit.band(sequence, 0xFF),
-- physical input port from which DMX512 data was input.
bit.band(physical, 0xFF),
-- 15 bit Port-Address (universe)
bit.band(universe, 0xFF), bit.rshift(universe, 8),
-- Length
bit.rshift(#data, 8), bit.band(#data, 0xFF)
)
local req = "Art-Net" .. cmd .. string.char(unpack(data))
local sck = require("socket").udp()
sck:sendto(req, ip, 0x1936)
sck:close()
end
ip = '192.168.2.43'
universe = 123
value = 255
artnet_dmx(ip, 0, 0, universe, { value })