This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Art-Net DMX
#2
here is the Artnet integration script:

Code:
require("socket")

artnet_id = "Art-net" .. string.char(0)  --8 byte
op_codes = {
 ARTNET_POLL = 0x2000,
 ARTNET_REPLY = 0x2100,
 ARTNET_DMX = 0x5000,
 ARTNET_ADDRESS = 0x6000,
 ARTNET_INPUT = 0x7000,
 ARTNET_TODREQUEST = 0x8000,
 ARTNET_TODDATA = 0x8100,
 ARTNET_TODCONTROL = 0x8200,
 ARTNET_RDM = 0x8300,
 ARTNET_VIDEOSTEUP = 0xa010,
 ARTNET_VIDEOPALETTE = 0xa020,
 ARTNET_VIDEODATA = 0xa040,
 ARTNET_MACMASTER = 0xf000,
 ARTNET_MACSLAVE = 0xf100,
 ARTNET_FIRMWAREMASTER = 0xf200,
 ARTNET_FIRMWAREREPLY = 0xf300,
 ARTNET_IPPROG = 0xf800,
 ARTNET_IPREPLY = 0xf900,
 ARTNET_MEDIA = 0x9000,
 ARTNET_MEDIAPATCH = 0x9200,
 ARTNET_MEDIACONTROLREPLY = 0x9300
}
protocol_version = {
 high = 0,
 low = 14
}
priority_codes = {
 DpLow = 0x10,
 DpMed = 0x40,
 DpHigh = 0x80,
 DpCritical = 0xE0,
 DpVolatile = 0xF0
}


function op_code(name)
 local code = op_codes[name]
 local low = bit.band(code, 0x00FF)
 local high = bit.rshift(code, 8)
 return low, high
end

function artnet_poll(address, port, talk_to_me, priority)
 local command = {}

 local opCodeLow, opCodeHigh = op_code("ARTNET_POLL")
 table.insert(command, opCodeLow)
 table.insert(command, opCodeHigh)

 table.insert(command, protocol_version.low)
 table.insert(command, protocol_version.high)

 table.insert(command, talk_to_me)

 table.insert(command, priority_codes[priority])

 command = artnet_id .. string.char(unpack(command))


 local s = socket.udp()
 s:sendto(command, address, port)
 s:close()
end


function artnet_dmx(address, port, sequence, in_port_physical, in_port_address, data)
 local command = {}

 local opCodeLow, opCodeHigh = op_code("ARTNET_DMX")
 table.insert(command, opCodeLow)
 table.insert(command, opCodeHigh)

 table.insert(command, protocol_version.low)
 table.insert(command, protocol_version.high)

--[[
The sequence number is used to ensure that ArtDmx packets are used in the correct order.
When Art-Net is carried over a medium such as the Internet, it is possible that ArtDmx packets will reach the receiver out of order.
This field is incremented in the range 0x01 to 0xff to allow the receiving node to resequence packets.
The Sequence field is set to 0x00 to disable this feature
]]
 sequence = bit.band(sequence, 0xFF)
 table.insert(command, sequence)

--[[
The physical input port from which DMX512 data was input.
This field is for information only. Use Universe for data routing.
]]
 table.insert(command, in_port_physical)

--15 bit Port-Address (universe)
 local address_hi = bit.rshift(in_port_address, 8)
 local address_low = bit.band(in_port_address, 0x00FF)
 table.insert(command, address_hi)
 table.insert(command, address_low)

 --Length
 local l = #data --2 byte
 local LengthHi = bit.rshift(l, 8)
 local LengthLow = bit.band(l, 0x00FF)
 table.insert(command, LengthHi)
 table.insert(command, LengthLow)

 command = artnet_id .. string.char(unpack(command)) .. string.char(unpack(data))

 local s = socket.udp()
 s:sendto(command, address, port)
 s:close()
end

artnet_dmx(ip, port, 0, 0x12, 0x93, {0xA, 0x12, 0xFF})
Reply


Messages In This Thread
Art-Net DMX - by sjfp - 11.05.2018, 12:33
RE: Art-Net DMX - by edgars - 11.05.2018, 13:08
RE: Art-Net DMX - by sjfp - 11.05.2018, 13:20
RE: Art-Net DMX - by admin - 14.05.2018, 06:28
RE: Art-Net DMX - by Erwin van der Zwart - 14.05.2018, 07:53
RE: Art-Net DMX - by sjfp - 14.05.2018, 10:26
RE: Art-Net DMX - by admin - 14.05.2018, 11:02
RE: Art-Net DMX - by Erwin van der Zwart - 14.05.2018, 19:56
RE: Art-Net DMX - by sjfp - 21.05.2018, 17:16
RE: Art-Net DMX - by admin - 15.05.2018, 06:52
RE: Art-Net DMX - by admin - 22.05.2018, 06:00
RE: Art-Net DMX - by sjfp - 22.05.2018, 17:19
RE: Art-Net DMX - by admin - 23.05.2018, 08:35
RE: Art-Net DMX - by sjfp - 23.05.2018, 09:49
RE: Art-Net DMX - by lcrowhurst - 03.02.2020, 03:20
RE: Art-Net DMX - by admin - 03.02.2020, 11:41
RE: Art-Net DMX - by lcrowhurst - 03.02.2020, 12:15
RE: Art-Net DMX - by admin - 03.02.2020, 12:51
RE: Art-Net DMX - by lcrowhurst - 04.02.2020, 12:56
RE: Art-Net DMX - by admin - 04.02.2020, 13:09
RE: Art-Net DMX - by lcrowhurst - 06.02.2020, 01:21
RE: Art-Net DMX - by lcrowhurst - 07.09.2020, 22:49

Forum Jump: