add read write lock to dmx data

This commit is contained in:
Adrian Zuercher
2025-07-26 07:18:26 +02:00
parent 05409c2544
commit a503b71fb6
5 changed files with 49 additions and 23 deletions

View File

@@ -16,14 +16,14 @@ 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))) // Length
packet.Write(*data)
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()
}