Files
tecamino-driver-artNet/models/package.go
2025-07-26 07:18:26 +02:00

30 lines
1010 B
Go

package models
import (
"bytes"
"encoding/binary"
)
// Art-Net constants
const (
opCode = 0x5000 // OpDmx (low byte first)
protocolID = "Art-Net\x00"
)
type Package []byte
func NewArtNetPackage(data *DMX) Package {
// Build ArtDMX packet
packet := &bytes.Buffer{}
packet.WriteString(protocolID) // Art-Net ID
binary.Write(packet, binary.LittleEndian, uint16(opCode)) // OpCode (OpDmx)
packet.WriteByte(0x00) // Protocol Version High
packet.WriteByte(14) // Protocol Version Low (14 for Art-Net 4)
packet.WriteByte(0x00) // Sequence
packet.WriteByte(0x00) // Physical
binary.Write(packet, binary.BigEndian, uint16(0)) // Universe (net:subuni, usually 0)
binary.Write(packet, binary.BigEndian, uint16(len(data.Data))) // Length
packet.Write(data.Data)
return packet.Bytes()
}