Artnet Packet Structure

6.2k views Asked by At

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

2

There are 2 answers

0
quick On
[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;
}
2
hoss On

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.