2

Even though I have found so many Libraries that allows programmers to use the Artnet/ArtnetDMX protocol I haven't found the correct structure to send out Artnet in code (To a socket).

The structure is given but, I just can't figure out in what order bytes should be send. Do i send a byte to a universe One by One, or do I need to send a Byte array with all the values?

Doesn anyone have experience in sending Artnet over UDP?

This the structure given on wikipedia: https://i.stack.imgur.com/wUjzd.png

JasonMArcher
  • 14,195
  • 22
  • 56
  • 52
user2354108
  • 21
  • 1
  • 3

2 Answers2

2

I use the following struct for Art-Net v2

typedef struct {
    char ID[8];         //"Art-Net"
    UInt16 OpCode;      // See Doc. Table 1 - OpCodes eg. 0x5000 OpOutput / OpDmx
    UInt16 version;     // 0x0e00 (aka 14)
    UInt8  seq;         // monotonic counter
    UInt8  physical;    // 0x00
    UInt8  subUni;      // low universe (0-255)
    UInt8  net;         // high universe (not used)
    UInt16 length;      // data length (2 - 512)
    uint8_t data[512];  // universe data
} ArtnetDmx;

If you want to write an Art-Net application you should really read the documentation located on Artistic Licence.

I would follow the version 2 (14) specification as that version 3 is quite rare in the wild.

hoss
  • 2,430
  • 1
  • 27
  • 42
  • Physical, Sub Universe and Net can all be extrapolated from the IP address. It's pretty handy to write a constructor for this that takes in the IP of the controller you're addressing as 4 bytes. – aj.toulan Aug 28 '18 at 14:47
  • 1
    @aj.toulan is right by the specification you can use the IP to figure out the packet paramiters, however, most controllers don't follow this part of the specification. For example a shared computer that is on DHCP that happens to be outputting Art-Net can still be received my clients even though it's IP is not according to the spec. – hoss Aug 28 '18 at 21:17
0
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct Artnet
{
    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 8)]
    public string id;
    public short opCode;
    public byte protocolHi;
    public byte protocolLo;
    public byte sequence;
    public byte physical;
    public short universe;
    public short length;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 512)]
    public byte[] data;
}
quick
  • 1