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
#24
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
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 tomnord - 07.05.2024, 12:54
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
RE: Art-Net DMX - by admin - 07.05.2024, 13:07
RE: Art-Net DMX - by tomnord - 07.05.2024, 13:17
RE: Art-Net DMX - by admin - 07.05.2024, 13:20
RE: Art-Net DMX - by tomnord - 07.05.2024, 13:21
RE: Art-Net DMX - by admin - 07.05.2024, 13:42

Forum Jump: