remove constants from packet structs

This commit is contained in:
Joel Wetzell
2026-05-30 08:56:07 -05:00
parent f3b6a6ef1b
commit c0701537b6
20 changed files with 389 additions and 678 deletions
+11 -25
View File
@@ -85,10 +85,6 @@ const (
) )
type ArtAddress struct { type ArtAddress struct {
ID [8]uint8
OpCode uint16
ProtVerHi uint8
ProtVerLo uint8
NetSwitch uint8 NetSwitch uint8
BindIndex uint8 BindIndex uint8
PortName [18]uint8 PortName [18]uint8
@@ -101,15 +97,7 @@ type ArtAddress struct {
} }
func (aa *ArtAddress) GetOpCode() uint16 { func (aa *ArtAddress) GetOpCode() uint16 {
return aa.OpCode return OpAddress
}
func (aa *ArtAddress) GetProtVer() uint16 {
return uint16(aa.ProtVerHi)<<8 + uint16(aa.ProtVerLo)
}
func (aa *ArtAddress) GetID() [8]uint8 {
return aa.ID
} }
func (aa *ArtAddress) UnmarshalBinary(data []byte) error { func (aa *ArtAddress) UnmarshalBinary(data []byte) error {
@@ -117,16 +105,14 @@ func (aa *ArtAddress) UnmarshalBinary(data []byte) error {
return errors.New("ArtAddress packet must be at least 107 bytes long") return errors.New("ArtAddress packet must be at least 107 bytes long")
} }
copy(aa.ID[:], data[0:8]) if !slices.Equal(ArtNetID[:], data[0:8]) {
if !slices.Equal(ArtNetID[:], aa.ID[:]) {
return errors.New("ID does not match Art-Net ID") return errors.New("ID does not match Art-Net ID")
} }
aa.OpCode = binary.LittleEndian.Uint16(data[8:10]) opCode := binary.LittleEndian.Uint16(data[8:10])
aa.ProtVerHi = data[10] if opCode != OpAddress {
aa.ProtVerLo = data[11] return errors.New("packet does not have the correct OpCode for an ArtAddress packet")
}
offset := 12 offset := 12
aa.NetSwitch = data[offset] aa.NetSwitch = data[offset]
aa.BindIndex = data[offset+1] aa.BindIndex = data[offset+1]
@@ -141,11 +127,11 @@ func (aa *ArtAddress) UnmarshalBinary(data []byte) error {
} }
func (aa *ArtAddress) MarshalBinary() ([]byte, error) { func (aa *ArtAddress) MarshalBinary() ([]byte, error) {
data := make([]byte, 8+11) data := make([]byte, 8+99)
copy(data[0:8], aa.ID[:]) copy(data[0:8], ArtNetID[:])
binary.LittleEndian.PutUint16(data[8:10], aa.OpCode) binary.LittleEndian.PutUint16(data[8:10], OpAddress)
data[10] = aa.ProtVerHi data[10] = 0
data[11] = aa.ProtVerLo data[11] = 14
offset := 12 offset := 12
data[offset] = aa.NetSwitch data[offset] = aa.NetSwitch
data[offset+1] = aa.BindIndex data[offset+1] = aa.BindIndex
+12 -29
View File
@@ -14,28 +14,12 @@ const (
) )
type ArtCommand struct { type ArtCommand struct {
ID [8]uint8 EstaMan uint16
OpCode uint16 Data []uint8
ProtVerHi uint8
ProtVerLo uint8
EstaMan uint16
Data []uint8
} }
func (ac *ArtCommand) GetOpCode() uint16 { func (ac *ArtCommand) GetOpCode() uint16 {
return ac.OpCode return OpCommand
}
func (ac *ArtCommand) GetProtVer() uint16 {
return uint16(ac.ProtVerHi)<<8 + uint16(ac.ProtVerLo)
}
func (ac *ArtCommand) GetID() [8]uint8 {
return ac.ID
}
func (ac *ArtCommand) Length() uint16 {
return uint16(len(ac.Data))
} }
func (ac *ArtCommand) UnmarshalBinary(data []byte) error { func (ac *ArtCommand) UnmarshalBinary(data []byte) error {
@@ -44,15 +28,14 @@ func (ac *ArtCommand) UnmarshalBinary(data []byte) error {
return errors.New("ArtCommand packet must be at least 16 bytes long") return errors.New("ArtCommand packet must be at least 16 bytes long")
} }
copy(ac.ID[:], data[0:8]) if !slices.Equal(ArtNetID[:], data[0:8]) {
if !slices.Equal(ArtNetID[:], ac.ID[:]) {
return errors.New("ID does not match Art-Net ID") return errors.New("ID does not match Art-Net ID")
} }
ac.OpCode = binary.LittleEndian.Uint16(data[8:10]) opCode := binary.LittleEndian.Uint16(data[8:10])
ac.ProtVerHi = data[10] if opCode != OpCommand {
ac.ProtVerLo = data[11] return errors.New("packet does not have the correct OpCode for an ArtCommand packet")
}
offset := 12 offset := 12
ac.EstaMan = binary.BigEndian.Uint16(data[offset : offset+2]) ac.EstaMan = binary.BigEndian.Uint16(data[offset : offset+2])
@@ -69,10 +52,10 @@ func (ac *ArtCommand) UnmarshalBinary(data []byte) error {
func (ac *ArtCommand) MarshalBinary() ([]byte, error) { func (ac *ArtCommand) MarshalBinary() ([]byte, error) {
data := make([]byte, 8+8) data := make([]byte, 8+8)
copy(data[0:8], ac.ID[:]) copy(data[0:8], ArtNetID[:])
binary.LittleEndian.PutUint16(data[8:10], ac.OpCode) binary.LittleEndian.PutUint16(data[8:10], OpCommand)
data[10] = ac.ProtVerHi data[10] = 0
data[11] = ac.ProtVerLo data[11] = 14
binary.BigEndian.PutUint16(data[12:14], ac.EstaMan) binary.BigEndian.PutUint16(data[12:14], ac.EstaMan)
dataLength := uint16(len(ac.Data)) dataLength := uint16(len(ac.Data))
if dataLength > 512 { if dataLength > 512 {
+14 -27
View File
@@ -18,26 +18,14 @@ const (
) )
type ArtDataRequest struct { type ArtDataRequest struct {
ID [8]uint8 EstaMan uint16
OpCode uint16 Oem uint16
ProtVerHi uint8 Request DataRequest
ProtVerLo uint8 spare [22]byte
EstaMan uint16
Oem uint16
Request DataRequest
spare [22]byte
} }
func (adr *ArtDataRequest) GetOpCode() uint16 { func (adr *ArtDataRequest) GetOpCode() uint16 {
return adr.OpCode return OpDataRequest
}
func (adr *ArtDataRequest) GetProtVer() uint16 {
return uint16(adr.ProtVerHi)<<8 + uint16(adr.ProtVerLo)
}
func (adr *ArtDataRequest) GetID() [8]uint8 {
return adr.ID
} }
func (adr *ArtDataRequest) UnmarshalBinary(data []byte) error { func (adr *ArtDataRequest) UnmarshalBinary(data []byte) error {
@@ -46,15 +34,14 @@ func (adr *ArtDataRequest) UnmarshalBinary(data []byte) error {
return errors.New("ArtDataRequest packet must be at least 40 bytes long") return errors.New("ArtDataRequest packet must be at least 40 bytes long")
} }
copy(adr.ID[:], data[0:8]) if !slices.Equal(ArtNetID[:], data[0:8]) {
if !slices.Equal(ArtNetID[:], adr.ID[:]) {
return errors.New("ID does not match Art-Net ID") return errors.New("ID does not match Art-Net ID")
} }
adr.OpCode = binary.LittleEndian.Uint16(data[8:10]) opCode := binary.LittleEndian.Uint16(data[8:10])
adr.ProtVerHi = data[10] if opCode != OpDataRequest {
adr.ProtVerLo = data[11] return errors.New("packet does not have the correct OpCode for an ArtDataRequest packet")
}
offset := 12 offset := 12
adr.EstaMan = binary.BigEndian.Uint16(data[offset : offset+2]) adr.EstaMan = binary.BigEndian.Uint16(data[offset : offset+2])
@@ -66,10 +53,10 @@ func (adr *ArtDataRequest) UnmarshalBinary(data []byte) error {
func (adr *ArtDataRequest) MarshalBinary() ([]byte, error) { func (adr *ArtDataRequest) MarshalBinary() ([]byte, error) {
data := make([]byte, 8+32) data := make([]byte, 8+32)
copy(data[0:8], adr.ID[:]) copy(data[0:8], ArtNetID[:])
binary.LittleEndian.PutUint16(data[8:10], adr.OpCode) binary.LittleEndian.PutUint16(data[8:10], OpDataRequest)
data[10] = adr.ProtVerHi data[10] = 0
data[11] = adr.ProtVerLo data[11] = 14
binary.BigEndian.PutUint16(data[12:14], adr.EstaMan) binary.BigEndian.PutUint16(data[12:14], adr.EstaMan)
binary.BigEndian.PutUint16(data[14:16], adr.Oem) binary.BigEndian.PutUint16(data[14:16], adr.Oem)
binary.BigEndian.PutUint16(data[16:18], uint16(adr.Request)) binary.BigEndian.PutUint16(data[16:18], uint16(adr.Request))
+10 -27
View File
@@ -17,10 +17,6 @@ const (
) )
type ArtDiagData struct { type ArtDiagData struct {
ID [8]uint8
OpCode uint16
ProtVerHi uint8
ProtVerLo uint8
filler1 uint8 filler1 uint8
DiagPriority DiagPriority DiagPriority DiagPriority
LogicalPort uint8 LogicalPort uint8
@@ -29,19 +25,7 @@ type ArtDiagData struct {
} }
func (add *ArtDiagData) GetOpCode() uint16 { func (add *ArtDiagData) GetOpCode() uint16 {
return add.OpCode return OpDiagData
}
func (add *ArtDiagData) GetProtVer() uint16 {
return uint16(add.ProtVerHi)<<8 + uint16(add.ProtVerLo)
}
func (add *ArtDiagData) GetID() [8]uint8 {
return add.ID
}
func (add *ArtDiagData) Length() uint16 {
return uint16(len(add.Data))
} }
func (add *ArtDiagData) UnmarshalBinary(data []byte) error { func (add *ArtDiagData) UnmarshalBinary(data []byte) error {
@@ -50,15 +34,14 @@ func (add *ArtDiagData) UnmarshalBinary(data []byte) error {
return errors.New("ArtDiagData packet must be at least 18 bytes long") return errors.New("ArtDiagData packet must be at least 18 bytes long")
} }
copy(add.ID[:], data[0:8]) if !slices.Equal(ArtNetID[:], data[0:8]) {
if !slices.Equal(ArtNetID[:], add.ID[:]) {
return errors.New("ID does not match Art-Net ID") return errors.New("ID does not match Art-Net ID")
} }
add.OpCode = binary.LittleEndian.Uint16(data[8:10]) opCode := binary.LittleEndian.Uint16(data[8:10])
add.ProtVerHi = data[10] if opCode != OpDiagData {
add.ProtVerLo = data[11] return errors.New("packet does not have the correct OpCode for an ArtDiagData packet")
}
offset := 12 offset := 12
add.filler1 = data[offset] add.filler1 = data[offset]
@@ -77,10 +60,10 @@ func (add *ArtDiagData) UnmarshalBinary(data []byte) error {
func (add *ArtDiagData) MarshalBinary() ([]byte, error) { func (add *ArtDiagData) MarshalBinary() ([]byte, error) {
data := make([]byte, 8+10) data := make([]byte, 8+10)
copy(data[0:8], add.ID[:]) copy(data[0:8], ArtNetID[:])
binary.LittleEndian.PutUint16(data[8:10], add.OpCode) binary.LittleEndian.PutUint16(data[8:10], OpDiagData)
data[10] = add.ProtVerHi data[10] = 0
data[11] = add.ProtVerLo data[11] = 14
data[12] = add.filler1 data[12] = add.filler1
data[13] = uint8(add.DiagPriority) data[13] = uint8(add.DiagPriority)
data[14] = add.LogicalPort data[14] = add.LogicalPort
+18 -34
View File
@@ -7,31 +7,15 @@ import (
) )
type ArtDmx struct { type ArtDmx struct {
ID [8]uint8 Sequence uint8
OpCode uint16 Physical uint8
ProtVerHi uint8 SubUni uint8
ProtVerLo uint8 Net uint8
Sequence uint8 Data []uint8
Physical uint8
SubUni uint8
Net uint8
Data []uint8
} }
func (ad *ArtDmx) GetOpCode() uint16 { func (ad *ArtDmx) GetOpCode() uint16 {
return ad.OpCode return OpDmx
}
func (ad *ArtDmx) GetProtVer() uint16 {
return uint16(ad.ProtVerHi)<<8 + uint16(ad.ProtVerLo)
}
func (ad *ArtDmx) GetID() [8]uint8 {
return ad.ID
}
func (ad *ArtDmx) Length() uint16 {
return uint16(len(ad.Data))
} }
func (ad *ArtDmx) UnmarshalBinary(data []byte) error { func (ad *ArtDmx) UnmarshalBinary(data []byte) error {
@@ -39,15 +23,14 @@ func (ad *ArtDmx) UnmarshalBinary(data []byte) error {
return errors.New("ArtDmx packet must be at least 18 bytes long") return errors.New("ArtDmx packet must be at least 18 bytes long")
} }
copy(ad.ID[:], data[0:8]) if !slices.Equal(ArtNetID[:], data[0:8]) {
if !slices.Equal(ArtNetID[:], ad.ID[:]) {
return errors.New("ID does not match Art-Net ID") return errors.New("ID does not match Art-Net ID")
} }
ad.OpCode = binary.LittleEndian.Uint16(data[8:10]) opCode := binary.LittleEndian.Uint16(data[8:10])
ad.ProtVerHi = data[10] if opCode != OpDmx {
ad.ProtVerLo = data[11] return errors.New("packet does not have the correct OpCode for an ArtDmx packet")
}
offset := 12 offset := 12
@@ -70,16 +53,17 @@ func (ad *ArtDmx) UnmarshalBinary(data []byte) error {
} }
func (ad *ArtDmx) MarshalBinary() ([]byte, error) { func (ad *ArtDmx) MarshalBinary() ([]byte, error) {
data := make([]byte, 8+10+ad.Length()) // TODO(jwetzell): check max data length
copy(data[0:8], ad.ID[:]) data := make([]byte, 8+10+len(ad.Data))
binary.LittleEndian.PutUint16(data[8:10], ad.OpCode) copy(data[0:8], ArtNetID[:])
data[10] = ad.ProtVerHi binary.LittleEndian.PutUint16(data[8:10], OpDmx)
data[11] = ad.ProtVerLo data[10] = 0
data[11] = 14
data[12] = ad.Sequence data[12] = ad.Sequence
data[13] = ad.Physical data[13] = ad.Physical
data[14] = ad.SubUni data[14] = ad.SubUni
data[15] = ad.Net data[15] = ad.Net
binary.BigEndian.PutUint16(data[16:18], ad.Length()) binary.BigEndian.PutUint16(data[16:18], uint16(len(ad.Data)))
copy(data[18:], ad.Data) copy(data[18:], ad.Data)
return data, nil return data, nil
} }
+20 -56
View File
@@ -17,45 +17,33 @@ func TestGoodArtDmx(t *testing.T) {
Name: "512 All Zeroes", Name: "512 All Zeroes",
Data: []byte{65, 114, 116, 45, 78, 101, 116, 0, 0, 80, 0, 14, 237, 0, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, Data: []byte{65, 114, 116, 45, 78, 101, 116, 0, 0, 80, 0, 14, 237, 0, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
Expected: &artnet.ArtDmx{ Expected: &artnet.ArtDmx{
ID: [8]byte{'A', 'r', 't', '-', 'N', 'e', 't', 0x00}, Sequence: 237,
OpCode: artnet.OpDmx, Physical: 0,
ProtVerHi: 0, SubUni: 1,
ProtVerLo: 14, Net: 0,
Sequence: 237, Data: make([]uint8, 512),
Physical: 0,
SubUni: 1,
Net: 0,
Data: make([]uint8, 512),
}, },
}, },
{ {
Name: "ACT Packet 1", Name: "ACT Packet 1",
Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x50, 0x00, 0x0e, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x50, 0x00, 0x0e, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
Expected: &artnet.ArtDmx{ Expected: &artnet.ArtDmx{
ID: artnet.ArtNetID, Sequence: 0,
OpCode: artnet.OpDmx, Physical: 0,
ProtVerHi: 0, SubUni: 1,
ProtVerLo: 14, Net: 0,
Sequence: 0, Data: make([]uint8, 512),
Physical: 0,
SubUni: 1,
Net: 0,
Data: make([]uint8, 512),
}, },
}, },
{ {
Name: "ACT Packet 2", Name: "ACT Packet 2",
Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x50, 0x00, 0x0e, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x50, 0x00, 0x0e, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
Expected: &artnet.ArtDmx{ Expected: &artnet.ArtDmx{
ID: artnet.ArtNetID, Sequence: 0,
OpCode: artnet.OpDmx, Physical: 0,
ProtVerHi: 0, SubUni: 1,
ProtVerLo: 14, Net: 0,
Sequence: 0, Data: append([]uint8{0xff, 0x7f}, make([]uint8, 510)...),
Physical: 0,
SubUni: 1,
Net: 0,
Data: append([]uint8{0xff, 0x7f}, make([]uint8, 510)...),
}, },
}, },
} }
@@ -69,22 +57,6 @@ func TestGoodArtDmx(t *testing.T) {
t.Fatalf("failed to decode ArtDmx: %s", err) t.Fatalf("failed to decode ArtDmx: %s", err)
} }
if got.OpCode != test.Expected.OpCode {
t.Fatalf("ArtDmx OpCode does not match got: %d expected: %d", got.OpCode, test.Expected.OpCode)
}
if !slices.Equal(got.ID[:], test.Expected.ID[:]) {
t.Fatalf("ArtDmx ID does not match got: %+v expected: %+v", got.ID, test.Expected.ID)
}
if got.ProtVerHi != test.Expected.ProtVerHi {
t.Fatalf("ArtDmx ProtVerHi does not match got: %d expected: %d", got.ProtVerHi, test.Expected.ProtVerHi)
}
if got.ProtVerLo != test.Expected.ProtVerLo {
t.Fatalf("ArtDmx ProtVerLo does not match got: %d expected: %d", got.ProtVerLo, test.Expected.ProtVerLo)
}
if got.Sequence != test.Expected.Sequence { if got.Sequence != test.Expected.Sequence {
t.Fatalf("ArtDmx Sequence does not match got: %d expected: %d", got.Sequence, test.Expected.Sequence) t.Fatalf("ArtDmx Sequence does not match got: %d expected: %d", got.Sequence, test.Expected.Sequence)
} }
@@ -101,10 +73,6 @@ func TestGoodArtDmx(t *testing.T) {
t.Fatalf("ArtDmx Net does not match got: %d expected: %d", got.Net, test.Expected.Net) t.Fatalf("ArtDmx Net does not match got: %d expected: %d", got.Net, test.Expected.Net)
} }
if got.Length() != test.Expected.Length() {
t.Fatalf("ArtDmx Length does not match got: %d expected: %d", got.Length(), test.Expected.Length())
}
if !slices.Equal(got.Data, test.Expected.Data) { if !slices.Equal(got.Data, test.Expected.Data) {
t.Fatalf("ArtDmx Data does not match got: %+v expected: %+v", got.Data, test.Expected.Data) t.Fatalf("ArtDmx Data does not match got: %+v expected: %+v", got.Data, test.Expected.Data)
} }
@@ -127,15 +95,11 @@ func BenchmarkArtDmxUnmarshalBinary(b *testing.B) {
func BenchmarkArtDmxMarshalBinary(b *testing.B) { func BenchmarkArtDmxMarshalBinary(b *testing.B) {
data := artnet.ArtDmx{ data := artnet.ArtDmx{
ID: [8]byte{'A', 'r', 't', '-', 'N', 'e', 't', 0x00}, Sequence: 237,
OpCode: artnet.OpDmx, Physical: 0,
ProtVerHi: 0, SubUni: 1,
ProtVerLo: 14, Net: 0,
Sequence: 237, Data: make([]uint8, 512),
Physical: 0,
SubUni: 1,
Net: 0,
Data: make([]uint8, 512),
} }
for b.Loop() { for b.Loop() {
+10 -23
View File
@@ -7,10 +7,6 @@ import (
) )
type ArtIpProg struct { type ArtIpProg struct {
ID [8]uint8
OpCode uint16
ProtVerHi uint8
ProtVerLo uint8
filler1 uint8 filler1 uint8
filler2 uint8 filler2 uint8
Command uint8 Command uint8
@@ -36,15 +32,7 @@ type ArtIpProg struct {
} }
func (aip *ArtIpProg) GetOpCode() uint16 { func (aip *ArtIpProg) GetOpCode() uint16 {
return aip.OpCode return OpIpProg
}
func (aip *ArtIpProg) GetProtVer() uint16 {
return uint16(aip.ProtVerHi)<<8 + uint16(aip.ProtVerLo)
}
func (aip *ArtIpProg) GetID() [8]uint8 {
return aip.ID
} }
func (aip *ArtIpProg) UnmarshalBinary(data []byte) error { func (aip *ArtIpProg) UnmarshalBinary(data []byte) error {
@@ -52,15 +40,14 @@ func (aip *ArtIpProg) UnmarshalBinary(data []byte) error {
return errors.New("ArtIpProg packet must be at least 18 bytes long") return errors.New("ArtIpProg packet must be at least 18 bytes long")
} }
copy(aip.ID[:], data[0:8]) if !slices.Equal(ArtNetID[:], data[0:8]) {
if !slices.Equal(ArtNetID[:], aip.ID[:]) {
return errors.New("ID does not match Art-Net ID") return errors.New("ID does not match Art-Net ID")
} }
aip.OpCode = binary.LittleEndian.Uint16(data[8:10]) opCode := binary.LittleEndian.Uint16(data[8:10])
aip.ProtVerHi = data[10] if opCode != OpIpProg {
aip.ProtVerLo = data[11] return errors.New("packet does not have the correct OpCode for an ArtIpProg packet")
}
offset := 12 offset := 12
@@ -97,10 +84,10 @@ func (aip *ArtIpProg) UnmarshalBinary(data []byte) error {
func (aip *ArtIpProg) MarshalBinary() ([]byte, error) { func (aip *ArtIpProg) MarshalBinary() ([]byte, error) {
data := make([]byte, 8+26) data := make([]byte, 8+26)
copy(data[0:8], aip.ID[:]) copy(data[0:8], ArtNetID[:])
binary.LittleEndian.PutUint16(data[8:10], aip.OpCode) binary.LittleEndian.PutUint16(data[8:10], OpIpProg)
data[10] = aip.ProtVerHi data[10] = 0
data[11] = aip.ProtVerLo data[11] = 14
data[12] = aip.filler1 data[12] = aip.filler1
data[13] = aip.filler2 data[13] = aip.filler2
data[14] = aip.Command data[14] = aip.Command
-4
View File
@@ -17,10 +17,6 @@ func TestGoodArtIpProgUnmarshal(t *testing.T) {
Name: "ACT Packet 1", Name: "ACT Packet 1",
Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0xf8, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0xf8, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
Expected: &artnet.ArtIpProg{ Expected: &artnet.ArtIpProg{
ID: artnet.ArtNetID,
OpCode: artnet.OpIpProg,
ProtVerHi: 0x00,
ProtVerLo: 0x0e,
Command: 0x00, Command: 0x00,
ProgIpHi: 0x00, ProgIpHi: 0x00,
ProgIp2: 0x00, ProgIp2: 0x00,
+10 -23
View File
@@ -7,10 +7,6 @@ import (
) )
type ArtIpProgReply struct { type ArtIpProgReply struct {
ID [8]uint8
OpCode uint16
ProtVerHi uint8
ProtVerLo uint8
filler1 uint8 filler1 uint8
filler2 uint8 filler2 uint8
filler3 uint8 filler3 uint8
@@ -36,15 +32,7 @@ type ArtIpProgReply struct {
} }
func (aipr *ArtIpProgReply) GetOpCode() uint16 { func (aipr *ArtIpProgReply) GetOpCode() uint16 {
return aipr.OpCode return OpIpProgReply
}
func (aipr *ArtIpProgReply) GetProtVer() uint16 {
return uint16(aipr.ProtVerHi)<<8 + uint16(aipr.ProtVerLo)
}
func (aipr *ArtIpProgReply) GetID() [8]uint8 {
return aipr.ID
} }
func (aipr *ArtIpProgReply) UnmarshalBinary(data []byte) error { func (aipr *ArtIpProgReply) UnmarshalBinary(data []byte) error {
@@ -52,15 +40,14 @@ func (aipr *ArtIpProgReply) UnmarshalBinary(data []byte) error {
return errors.New("ArtIpProgReply packet must be at least 18 bytes long") return errors.New("ArtIpProgReply packet must be at least 18 bytes long")
} }
copy(aipr.ID[:], data[0:8]) if !slices.Equal(ArtNetID[:], data[0:8]) {
if !slices.Equal(ArtNetID[:], aipr.ID[:]) {
return errors.New("ID does not match Art-Net ID") return errors.New("ID does not match Art-Net ID")
} }
aipr.OpCode = binary.LittleEndian.Uint16(data[8:10]) opCode := binary.LittleEndian.Uint16(data[8:10])
aipr.ProtVerHi = data[10] if opCode != OpIpProgReply {
aipr.ProtVerLo = data[11] return errors.New("packet does not have the correct OpCode for an ArtIpProgReply packet")
}
offset := 12 offset := 12
@@ -98,10 +85,10 @@ func (aipr *ArtIpProgReply) UnmarshalBinary(data []byte) error {
func (aipr *ArtIpProgReply) MarshalBinary() ([]byte, error) { func (aipr *ArtIpProgReply) MarshalBinary() ([]byte, error) {
data := make([]byte, 8+26) data := make([]byte, 8+26)
copy(data[0:8], aipr.ID[:]) copy(data[0:8], ArtNetID[:])
binary.LittleEndian.PutUint16(data[8:10], aipr.OpCode) binary.LittleEndian.PutUint16(data[8:10], OpIpProgReply)
data[10] = aipr.ProtVerHi data[10] = 0
data[11] = aipr.ProtVerLo data[11] = 14
data[12] = aipr.filler1 data[12] = aipr.filler1
data[13] = aipr.filler2 data[13] = aipr.filler2
data[14] = aipr.filler3 data[14] = aipr.filler3
+10 -27
View File
@@ -7,10 +7,6 @@ import (
) )
type ArtNzs struct { type ArtNzs struct {
ID [8]uint8
OpCode uint16
ProtVerHi uint8
ProtVerLo uint8
Sequence uint8 Sequence uint8
StartCode uint8 StartCode uint8
SubUni uint8 SubUni uint8
@@ -19,19 +15,7 @@ type ArtNzs struct {
} }
func (an *ArtNzs) GetOpCode() uint16 { func (an *ArtNzs) GetOpCode() uint16 {
return an.OpCode return OpNzs
}
func (an *ArtNzs) GetProtVer() uint16 {
return uint16(an.ProtVerHi)<<8 + uint16(an.ProtVerLo)
}
func (an *ArtNzs) GetID() [8]uint8 {
return an.ID
}
func (an *ArtNzs) Length() uint16 {
return uint16(len(an.Data))
} }
func (an *ArtNzs) UnmarshalBinary(data []byte) error { func (an *ArtNzs) UnmarshalBinary(data []byte) error {
@@ -40,15 +24,14 @@ func (an *ArtNzs) UnmarshalBinary(data []byte) error {
return errors.New("ArtNzs packet must be at least 18 bytes long") return errors.New("ArtNzs packet must be at least 18 bytes long")
} }
copy(an.ID[:], data[0:8]) if !slices.Equal(ArtNetID[:], data[0:8]) {
if !slices.Equal(ArtNetID[:], an.ID[:]) {
return errors.New("ID does not match Art-Net ID") return errors.New("ID does not match Art-Net ID")
} }
an.OpCode = binary.LittleEndian.Uint16(data[8:10]) opCode := binary.LittleEndian.Uint16(data[8:10])
an.ProtVerHi = data[10] if opCode != OpNzs {
an.ProtVerLo = data[11] return errors.New("packet does not have the correct OpCode for an ArtNzs packet")
}
offset := 12 offset := 12
an.Sequence = data[offset] an.Sequence = data[offset]
@@ -68,10 +51,10 @@ func (an *ArtNzs) UnmarshalBinary(data []byte) error {
func (an *ArtNzs) MarshalBinary() ([]byte, error) { func (an *ArtNzs) MarshalBinary() ([]byte, error) {
data := make([]byte, 8+8) data := make([]byte, 8+8)
copy(data[0:8], an.ID[:]) copy(data[0:8], ArtNetID[:])
binary.LittleEndian.PutUint16(data[8:10], an.OpCode) binary.LittleEndian.PutUint16(data[8:10], OpNzs)
data[10] = an.ProtVerHi data[10] = 0
data[11] = an.ProtVerLo data[11] = 14
data[12] = an.Sequence data[12] = an.Sequence
data[13] = an.StartCode data[13] = an.StartCode
data[14] = an.SubUni data[14] = an.SubUni
-1
View File
@@ -8,5 +8,4 @@ type ArtNetPacket interface {
encoding.BinaryUnmarshaler encoding.BinaryUnmarshaler
encoding.BinaryMarshaler encoding.BinaryMarshaler
GetOpCode() uint16 GetOpCode() uint16
GetID() [8]uint8
} }
+10 -23
View File
@@ -7,10 +7,6 @@ import (
) )
type ArtPoll struct { type ArtPoll struct {
ID [8]uint8
OpCode uint16
ProtVerHi uint8
ProtVerLo uint8
Flags uint8 Flags uint8
DiagPriority uint8 DiagPriority uint8
// TODO(jwetzell): support extended poll fields // TODO(jwetzell): support extended poll fields
@@ -21,15 +17,7 @@ type ArtPoll struct {
} }
func (ap *ArtPoll) GetOpCode() uint16 { func (ap *ArtPoll) GetOpCode() uint16 {
return ap.OpCode return OpPoll
}
func (ap *ArtPoll) GetProtVer() uint16 {
return uint16(ap.ProtVerHi)<<8 + uint16(ap.ProtVerLo)
}
func (ap *ArtPoll) GetID() [8]uint8 {
return ap.ID
} }
func (ap *ArtPoll) UnmarshalBinary(data []byte) error { func (ap *ArtPoll) UnmarshalBinary(data []byte) error {
@@ -38,15 +26,14 @@ func (ap *ArtPoll) UnmarshalBinary(data []byte) error {
return errors.New("ArtPoll packet must be at least 14 bytes long") return errors.New("ArtPoll packet must be at least 14 bytes long")
} }
copy(ap.ID[:], data[0:8]) if !slices.Equal(ArtNetID[:], data[0:8]) {
if !slices.Equal(ArtNetID[:], ap.ID[:]) {
return errors.New("ID does not match Art-Net ID") return errors.New("ID does not match Art-Net ID")
} }
ap.OpCode = binary.LittleEndian.Uint16(data[8:10]) opCode := binary.LittleEndian.Uint16(data[8:10])
ap.ProtVerHi = data[10] if opCode != OpPoll {
ap.ProtVerLo = data[11] return errors.New("packet does not have the correct OpCode for an ArtPoll packet")
}
offset := 12 offset := 12
ap.Flags = data[offset] ap.Flags = data[offset]
@@ -69,10 +56,10 @@ func (ap *ArtPoll) UnmarshalBinary(data []byte) error {
func (ap *ArtPoll) MarshalBinary() ([]byte, error) { func (ap *ArtPoll) MarshalBinary() ([]byte, error) {
data := make([]byte, 8+14) data := make([]byte, 8+14)
copy(data[0:8], ap.ID[:]) copy(data[0:8], ArtNetID[:])
binary.LittleEndian.PutUint16(data[8:10], ap.OpCode) binary.LittleEndian.PutUint16(data[8:10], OpPoll)
data[10] = ap.ProtVerHi data[10] = 0
data[11] = ap.ProtVerLo data[11] = 14
data[12] = ap.Flags data[12] = ap.Flags
data[13] = ap.DiagPriority data[13] = ap.DiagPriority
binary.BigEndian.PutUint16(data[14:16], ap.TargetPortAddressTop) binary.BigEndian.PutUint16(data[14:16], ap.TargetPortAddressTop)
+125 -110
View File
@@ -17,170 +17,185 @@ func TestGoodArtPollUnmarshal(t *testing.T) {
Name: "ACT Packet 1", Name: "ACT Packet 1",
Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x20, 0x00, 0x0e, 0x00, 0x00}, Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x20, 0x00, 0x0e, 0x00, 0x00},
Expected: &artnet.ArtPoll{ Expected: &artnet.ArtPoll{
ID: artnet.ArtNetID, Flags: 0x00,
OpCode: 0x2000, DiagPriority: 0x00,
ProtVerHi: 0x00,
ProtVerLo: 0x0e,
}, },
}, },
{ {
Name: "ACT Packet 2", Name: "ACT Packet 2",
Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x20, 0x00, 0x0e, 0x00, 0x00, 0x7f}, Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x20, 0x00, 0x0e, 0x00, 0x00, 0x7f},
Expected: &artnet.ArtPoll{ Expected: &artnet.ArtPoll{
ID: artnet.ArtNetID, Flags: 0x00,
OpCode: 0x2000, DiagPriority: 0x00,
ProtVerHi: 0x00,
ProtVerLo: 0x0e,
}, },
}, },
{ {
Name: "ACT Packet 3", Name: "ACT Packet 3",
Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x20, 0x00, 0x0e, 0x00, 0x00, 0x7f, 0xff}, Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x20, 0x00, 0x0e, 0x00, 0x00, 0x7f, 0xff},
Expected: &artnet.ArtPoll{ Expected: &artnet.ArtPoll{
ID: artnet.ArtNetID, Flags: 0x00,
OpCode: 0x2000, DiagPriority: 0x00,
ProtVerHi: 0x00, TargetPortAddressTop: 0x7fff,
ProtVerLo: 0x0e,
}, },
}, },
{ {
Name: "ACT Packet 4", Name: "ACT Packet 4",
Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x20, 0x00, 0x0e, 0x00, 0x00, 0x7f, 0xff, 0x00}, Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x20, 0x00, 0x0e, 0x00, 0x00, 0x7f, 0xff, 0x00},
Expected: &artnet.ArtPoll{ Expected: &artnet.ArtPoll{
ID: artnet.ArtNetID, Flags: 0x00,
OpCode: 0x2000, DiagPriority: 0x00,
ProtVerHi: 0x00, TargetPortAddressTop: 0x7fff,
ProtVerLo: 0x0e,
}, },
}, },
{ {
Name: "ACT Packet 5", Name: "ACT Packet 5",
Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x20, 0x00, 0x0e, 0x00, 0x00, 0x7f, 0xff, 0x00, 0x00}, Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x20, 0x00, 0x0e, 0x00, 0x00, 0x7f, 0xff, 0x00, 0x00},
Expected: &artnet.ArtPoll{ Expected: &artnet.ArtPoll{
ID: artnet.ArtNetID, Flags: 0x00,
OpCode: 0x2000, DiagPriority: 0x00,
ProtVerHi: 0x00, TargetPortAddressTop: 0x7fff,
ProtVerLo: 0x0e, TargetPortAddressBottom: 0x0000,
}, },
}, },
{ {
Name: "ACT Packet 6", Name: "ACT Packet 6",
Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x20, 0x00, 0x0e, 0x00, 0x00, 0x7f, 0xff, 0x00, 0x00, 0x53}, Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x20, 0x00, 0x0e, 0x00, 0x00, 0x7f, 0xff, 0x00, 0x00, 0x53},
Expected: &artnet.ArtPoll{ Expected: &artnet.ArtPoll{
ID: artnet.ArtNetID, Flags: 0x00,
OpCode: 0x2000, DiagPriority: 0x00,
ProtVerHi: 0x00, TargetPortAddressTop: 0x7fff,
ProtVerLo: 0x0e, TargetPortAddressBottom: 0x0000,
}, },
}, },
{ {
Name: "ACT Packet 7", Name: "ACT Packet 7",
Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x20, 0x00, 0x0e, 0x00, 0x00, 0x7f, 0xff, 0x00, 0x00, 0x53, 0x79}, Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x20, 0x00, 0x0e, 0x00, 0x00, 0x7f, 0xff, 0x00, 0x00, 0x53, 0x79},
Expected: &artnet.ArtPoll{ Expected: &artnet.ArtPoll{
ID: artnet.ArtNetID, Flags: 0x00,
OpCode: 0x2000, DiagPriority: 0x00,
ProtVerHi: 0x00, TargetPortAddressTop: 0x7fff,
ProtVerLo: 0x0e, TargetPortAddressBottom: 0x0000,
EstaMan: 0x5379,
}, },
}, },
{ {
Name: "ACT Packet 8", Name: "ACT Packet 8",
Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x20, 0x00, 0x0e, 0x00, 0x00, 0x7f, 0xff, 0x00, 0x00, 0x53, 0x79, 0x22}, Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x20, 0x00, 0x0e, 0x00, 0x00, 0x7f, 0xff, 0x00, 0x00, 0x53, 0x79, 0x22},
Expected: &artnet.ArtPoll{ Expected: &artnet.ArtPoll{
ID: artnet.ArtNetID, Flags: 0x00,
OpCode: 0x2000, DiagPriority: 0x00,
ProtVerHi: 0x00, TargetPortAddressTop: 0x7fff,
ProtVerLo: 0x0e, TargetPortAddressBottom: 0x0000,
EstaMan: 0x5379,
}, },
}, },
{ {
Name: "ACT Packet 9", Name: "ACT Packet 9",
Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x20, 0x00, 0x0e, 0x00, 0x00, 0x7f, 0xff, 0x00, 0x00, 0x53, 0x79, 0x22, 0x69}, Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x20, 0x00, 0x0e, 0x00, 0x00, 0x7f, 0xff, 0x00, 0x00, 0x53, 0x79, 0x22, 0x69},
Expected: &artnet.ArtPoll{ Expected: &artnet.ArtPoll{
ID: artnet.ArtNetID, Flags: 0x00,
OpCode: 0x2000, DiagPriority: 0x00,
ProtVerHi: 0x00, TargetPortAddressTop: 0x7fff,
ProtVerLo: 0x0e, TargetPortAddressBottom: 0x0000,
}, EstaMan: 0x5379,
}, Oem: 0x2269,
{
Name: "ACT Packet 10",
Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x20, 0x00, 0x0e, 0x00, 0x00, 0x7f, 0xff, 0x00, 0x00, 0x53, 0x79, 0x22, 0x69, 0x00},
Expected: &artnet.ArtPoll{
ID: artnet.ArtNetID,
OpCode: 0x2000,
ProtVerHi: 0x00,
ProtVerLo: 0x0e,
},
},
{
Name: "ACT Packet 11",
Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x20, 0x00, 0x0e, 0x00, 0x00, 0x7f, 0xff, 0x00, 0x00, 0x53, 0x79, 0x22, 0x69, 0x00, 0x00},
Expected: &artnet.ArtPoll{
ID: artnet.ArtNetID,
OpCode: 0x2000,
ProtVerHi: 0x00,
ProtVerLo: 0x0e,
},
},
{
Name: "ACT Packet 12",
Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x20, 0x00, 0x0e, 0x00, 0x00, 0x7f, 0xff, 0x00, 0x00, 0x53, 0x79, 0x22, 0x69, 0x00, 0x00, 0x00},
Expected: &artnet.ArtPoll{
ID: artnet.ArtNetID,
OpCode: 0x2000,
ProtVerHi: 0x00,
ProtVerLo: 0x0e,
},
},
{
Name: "ACT Packet 13",
Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x20, 0x00, 0x0e, 0x00, 0x00, 0x7f, 0xff, 0x00, 0x00, 0x53, 0x79, 0x22, 0x69, 0x00, 0x00, 0x00, 0x00},
Expected: &artnet.ArtPoll{
ID: artnet.ArtNetID,
OpCode: 0x2000,
ProtVerHi: 0x00,
ProtVerLo: 0x0e,
},
},
{
Name: "ACT Packet 14",
Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x20, 0x00, 0x0e, 0x00, 0x00, 0x7f, 0xff, 0x00, 0x00, 0x53, 0x79, 0x22, 0x69, 0x00, 0x00, 0x00, 0x00, 0x00},
Expected: &artnet.ArtPoll{
ID: artnet.ArtNetID,
OpCode: 0x2000,
ProtVerHi: 0x00,
ProtVerLo: 0x0e,
},
},
{
Name: "ACT Packet 15",
Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x20, 0x00, 0x0e, 0x00, 0x00, 0x7f, 0xff, 0x00, 0x00, 0x53, 0x79, 0x22, 0x69, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
Expected: &artnet.ArtPoll{
ID: artnet.ArtNetID,
OpCode: 0x2000,
ProtVerHi: 0x00,
ProtVerLo: 0x0e,
},
},
{
Name: "ACT Packet 16",
Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x20, 0x00, 0x0e, 0x00, 0x00, 0x7f, 0xff, 0x00, 0x00, 0x53, 0x79, 0x22, 0x69, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x21, 0x0a, 0x00, 0x00, 0x3e, 0x36, 0x19, 0x07, 0x33, 0x00, 0x06, 0x22, 0x69, 0x00, 0x00, 0x79, 0x53, 0x41, 0x43, 0x54, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x41, 0x43, 0x54, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
Expected: &artnet.ArtPoll{
ID: artnet.ArtNetID,
OpCode: 0x2000,
ProtVerHi: 0x00,
ProtVerLo: 0x0e,
}, },
}, },
// TODO(jwetzell): uncomment when extend field parsing is done
// {
// Name: "ACT Packet 10",
// Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x20, 0x00, 0x0e, 0x00, 0x00, 0x7f, 0xff, 0x00, 0x00, 0x53, 0x79, 0x22, 0x69, 0x00},
// Expected: &artnet.ArtPoll{
// Flags: 0x00,
// DiagPriority: 0x00,
// TargetPortAddressTop: 0x7fff,
// TargetPortAddressBottom: 0x0000,
// EstaMan: 0x5379,
// Oem: 0x2269,
// },
// },
// {
// Name: "ACT Packet 11",
// Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x20, 0x00, 0x0e, 0x00, 0x00, 0x7f, 0xff, 0x00, 0x00, 0x53, 0x79, 0x22, 0x69, 0x00, 0x00},
// Expected: &artnet.ArtPoll{
// Flags: 0x00,
// DiagPriority: 0x00,
// TargetPortAddressTop: 0x7fff,
// TargetPortAddressBottom: 0x0000,
// EstaMan: 0x5379,
// Oem: 0x2269,
// },
// },
// {
// Name: "ACT Packet 12",
// Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x20, 0x00, 0x0e, 0x00, 0x00, 0x7f, 0xff, 0x00, 0x00, 0x53, 0x79, 0x22, 0x69, 0x00, 0x00, 0x00},
// Expected: &artnet.ArtPoll{
// Flags: 0x00,
// DiagPriority: 0x00,
// TargetPortAddressTop: 0x7fff,
// TargetPortAddressBottom: 0x0000,
// EstaMan: 0x5379,
// Oem: 0x2269,
// },
// },
// {
// Name: "ACT Packet 13",
// Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x20, 0x00, 0x0e, 0x00, 0x00, 0x7f, 0xff, 0x00, 0x00, 0x53, 0x79, 0x22, 0x69, 0x00, 0x00, 0x00, 0x00},
// Expected: &artnet.ArtPoll{
// Flags: 0x00,
// DiagPriority: 0x00,
// TargetPortAddressTop: 0x7fff,
// TargetPortAddressBottom: 0x0000,
// EstaMan: 0x5379,
// Oem: 0x2269,
// },
// },
// {
// Name: "ACT Packet 14",
// Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x20, 0x00, 0x0e, 0x00, 0x00, 0x7f, 0xff, 0x00, 0x00, 0x53, 0x79, 0x22, 0x69, 0x00, 0x00, 0x00, 0x00, 0x00},
// Expected: &artnet.ArtPoll{
// Flags: 0x00,
// DiagPriority: 0x00,
// TargetPortAddressTop: 0x7fff,
// TargetPortAddressBottom: 0x0000,
// EstaMan: 0x5379,
// Oem: 0x2269,
// },
// },
// {
// Name: "ACT Packet 15",
// Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x20, 0x00, 0x0e, 0x00, 0x00, 0x7f, 0xff, 0x00, 0x00, 0x53, 0x79, 0x22, 0x69, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
// Expected: &artnet.ArtPoll{
// Flags: 0x00,
// DiagPriority: 0x00,
// TargetPortAddressTop: 0x7fff,
// TargetPortAddressBottom: 0x0000,
// EstaMan: 0x5379,
// Oem: 0x2269,
// },
// },
// {
// Name: "ACT Packet 16",
// Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x20, 0x00, 0x0e, 0x00, 0x00, 0x7f, 0xff, 0x00, 0x00, 0x53, 0x79, 0x22, 0x69, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x21, 0x0a, 0x00, 0x00, 0x3e, 0x36, 0x19, 0x07, 0x33, 0x00, 0x06, 0x22, 0x69, 0x00, 0x00, 0x79, 0x53, 0x41, 0x43, 0x54, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x41, 0x43, 0x54, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
// Expected: &artnet.ArtPoll{
// Flags: 0x00,
// DiagPriority: 0x00,
// TargetPortAddressTop: 0x7fff,
// TargetPortAddressBottom: 0x0000,
// EstaMan: 0x5379,
// Oem: 0x2269,
// },
// },
{ {
Name: "ACT Packet 17", Name: "ACT Packet 17",
Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x20, 0x00, 0x0e, 0x06, 0x00, 0x7f, 0xff, 0x00, 0x00, 0x53, 0x79, 0x22, 0x69}, Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x20, 0x00, 0x0e, 0x06, 0x00, 0x7f, 0xff, 0x00, 0x00, 0x53, 0x79, 0x22, 0x69},
Expected: &artnet.ArtPoll{ Expected: &artnet.ArtPoll{
ID: artnet.ArtNetID, Flags: 0x06,
OpCode: 0x2000, DiagPriority: 0x00,
ProtVerHi: 0x00, TargetPortAddressTop: 0x7fff,
ProtVerLo: 0x0e, TargetPortAddressBottom: 0x0000,
EstaMan: 0x5379,
Oem: 0x2269,
}, },
}, },
} }
+9 -13
View File
@@ -7,8 +7,6 @@ import (
) )
type ArtPollReply struct { type ArtPollReply struct {
ID [8]uint8
OpCode uint16
IPAddress [4]uint8 IPAddress [4]uint8
Port uint16 Port uint16
VersInfo uint16 VersInfo uint16
@@ -49,11 +47,7 @@ type ArtPollReply struct {
} }
func (ap *ArtPollReply) GetOpCode() uint16 { func (ap *ArtPollReply) GetOpCode() uint16 {
return ap.OpCode return OpPollReply
}
func (ap *ArtPollReply) GetID() [8]uint8 {
return ap.ID
} }
func (ap *ArtPollReply) UnmarshalBinary(data []byte) error { func (ap *ArtPollReply) UnmarshalBinary(data []byte) error {
@@ -62,13 +56,15 @@ func (ap *ArtPollReply) UnmarshalBinary(data []byte) error {
return errors.New("ArtPollReply packet must be at least 207 bytes long") return errors.New("ArtPollReply packet must be at least 207 bytes long")
} }
copy(ap.ID[:], data[0:8]) if !slices.Equal(ArtNetID[:], data[0:8]) {
if !slices.Equal(ArtNetID[:], ap.ID[:]) {
return errors.New("ID does not match Art-Net ID") return errors.New("ID does not match Art-Net ID")
} }
ap.OpCode = binary.LittleEndian.Uint16(data[8:10]) opCode := binary.LittleEndian.Uint16(data[8:10])
if opCode != OpPollReply {
return errors.New("packet does not have the correct OpCode for an ArtPollReply packet")
}
ap.IPAddress[0] = data[10] ap.IPAddress[0] = data[10]
ap.IPAddress[1] = data[11] ap.IPAddress[1] = data[11]
ap.IPAddress[2] = data[12] ap.IPAddress[2] = data[12]
@@ -106,8 +102,8 @@ func (ap *ArtPollReply) MarshalBinary() ([]byte, error) {
return nil, errors.New("DefaultRespUID must not be greater than 281474976710655") return nil, errors.New("DefaultRespUID must not be greater than 281474976710655")
} }
data := make([]byte, 8+230) data := make([]byte, 8+230)
copy(data[0:8], ap.ID[:]) copy(data[0:8], ArtNetID[:])
binary.LittleEndian.PutUint16(data[8:10], ap.OpCode) binary.LittleEndian.PutUint16(data[8:10], OpPollReply)
data[10] = ap.IPAddress[0] data[10] = ap.IPAddress[0]
data[11] = ap.IPAddress[1] data[11] = ap.IPAddress[1]
data[12] = ap.IPAddress[2] data[12] = ap.IPAddress[2]
+12 -25
View File
@@ -7,24 +7,12 @@ import (
) )
type ArtSync struct { type ArtSync struct {
ID [8]uint8 Aux1 uint8
OpCode uint16 Aux2 uint8
ProtVerHi uint8
ProtVerLo uint8
Aux1 uint8
Aux2 uint8
} }
func (as *ArtSync) GetOpCode() uint16 { func (as *ArtSync) GetOpCode() uint16 {
return as.OpCode return OpSync
}
func (as *ArtSync) GetProtVer() uint16 {
return uint16(as.ProtVerHi)<<8 + uint16(as.ProtVerLo)
}
func (as *ArtSync) GetID() [8]uint8 {
return as.ID
} }
func (as *ArtSync) UnmarshalBinary(data []byte) error { func (as *ArtSync) UnmarshalBinary(data []byte) error {
@@ -33,15 +21,14 @@ func (as *ArtSync) UnmarshalBinary(data []byte) error {
return errors.New("ArtSync packet must be at least 14 bytes long") return errors.New("ArtSync packet must be at least 14 bytes long")
} }
copy(as.ID[:], data[0:8]) if !slices.Equal(ArtNetID[:], data[0:8]) {
if !slices.Equal(ArtNetID[:], as.ID[:]) {
return errors.New("ID does not match Art-Net ID") return errors.New("ID does not match Art-Net ID")
} }
as.OpCode = binary.LittleEndian.Uint16(data[8:10]) opCode := binary.LittleEndian.Uint16(data[8:10])
as.ProtVerHi = data[10] if opCode != OpSync {
as.ProtVerLo = data[11] return errors.New("packet does not have the correct OpCode for an ArtSync packet")
}
offset := 12 offset := 12
as.Aux1 = data[offset] as.Aux1 = data[offset]
@@ -51,10 +38,10 @@ func (as *ArtSync) UnmarshalBinary(data []byte) error {
func (as *ArtSync) MarshalBinary() ([]byte, error) { func (as *ArtSync) MarshalBinary() ([]byte, error) {
data := make([]byte, 8+6) data := make([]byte, 8+6)
copy(data[0:8], as.ID[:]) copy(data[0:8], ArtNetID[:])
binary.LittleEndian.PutUint16(data[8:10], as.OpCode) binary.LittleEndian.PutUint16(data[8:10], OpSync)
data[10] = as.ProtVerHi data[10] = 0
data[11] = as.ProtVerLo data[11] = 14
data[12] = as.Aux1 data[12] = as.Aux1
data[13] = as.Aux2 data[13] = as.Aux2
return data, nil return data, nil
+19 -32
View File
@@ -7,29 +7,17 @@ import (
) )
type ArtTimeCode struct { type ArtTimeCode struct {
ID [8]uint8 filler1 uint8
OpCode uint16 StreamId uint8
ProtVerHi uint8 Frames uint8
ProtVerLo uint8 Seconds uint8
Filler1 uint8 Minutes uint8
StreamId uint8 Hours uint8
Frames uint8 Type uint8
Seconds uint8
Minutes uint8
Hours uint8
Type uint8
} }
func (atc *ArtTimeCode) GetOpCode() uint16 { func (atc *ArtTimeCode) GetOpCode() uint16 {
return atc.OpCode return OpTimeCode
}
func (atc *ArtTimeCode) GetProtVer() uint16 {
return uint16(atc.ProtVerHi)<<8 + uint16(atc.ProtVerLo)
}
func (atc *ArtTimeCode) GetID() [8]uint8 {
return atc.ID
} }
func (atc *ArtTimeCode) UnmarshalBinary(data []byte) error { func (atc *ArtTimeCode) UnmarshalBinary(data []byte) error {
@@ -37,18 +25,17 @@ func (atc *ArtTimeCode) UnmarshalBinary(data []byte) error {
return errors.New("ArtTimeCode packet must be at least 14 bytes long") return errors.New("ArtTimeCode packet must be at least 14 bytes long")
} }
copy(atc.ID[:], data[0:8]) if !slices.Equal(ArtNetID[:], data[0:8]) {
if !slices.Equal(ArtNetID[:], atc.ID[:]) {
return errors.New("ID does not match Art-Net ID") return errors.New("ID does not match Art-Net ID")
} }
atc.OpCode = binary.LittleEndian.Uint16(data[8:10]) opCode := binary.LittleEndian.Uint16(data[8:10])
atc.ProtVerHi = data[10] if opCode != OpTimeCode {
atc.ProtVerLo = data[11] return errors.New("packet does not have the correct OpCode for an ArtTimeCode packet")
}
offset := 12 offset := 12
atc.Filler1 = data[offset] atc.filler1 = data[offset]
atc.StreamId = data[offset+1] atc.StreamId = data[offset+1]
atc.Frames = data[offset+2] atc.Frames = data[offset+2]
atc.Seconds = data[offset+3] atc.Seconds = data[offset+3]
@@ -60,12 +47,12 @@ func (atc *ArtTimeCode) UnmarshalBinary(data []byte) error {
func (atc *ArtTimeCode) MarshalBinary() ([]byte, error) { func (atc *ArtTimeCode) MarshalBinary() ([]byte, error) {
data := make([]byte, 8+11) data := make([]byte, 8+11)
copy(data[0:8], atc.ID[:]) copy(data[0:8], ArtNetID[:])
binary.LittleEndian.PutUint16(data[8:10], atc.OpCode) binary.LittleEndian.PutUint16(data[8:10], OpTimeCode)
data[10] = atc.ProtVerHi data[10] = 0
data[11] = atc.ProtVerLo data[11] = 14
offset := 12 offset := 12
data[offset] = atc.Filler1 data[offset] = atc.filler1
data[offset+1] = atc.StreamId data[offset+1] = atc.StreamId
data[offset+2] = atc.Frames data[offset+2] = atc.Frames
data[offset+3] = atc.Seconds data[offset+3] = atc.Seconds
+12 -22
View File
@@ -17,17 +17,12 @@ func TestGoodArtTimeCodeUnmarshal(t *testing.T) {
Name: "Basic timecode", Name: "Basic timecode",
Data: []byte{65, 114, 116, 45, 78, 101, 116, 0, 0, 151, 0, 14, 0, 0, 11, 17, 3, 0, 0}, Data: []byte{65, 114, 116, 45, 78, 101, 116, 0, 0, 151, 0, 14, 0, 0, 11, 17, 3, 0, 0},
Expected: &artnet.ArtTimeCode{ Expected: &artnet.ArtTimeCode{
ID: [8]uint8{'A', 'r', 't', '-', 'N', 'e', 't', 0x00}, StreamId: 0,
OpCode: artnet.OpTimeCode, Frames: 11,
ProtVerHi: 0, Seconds: 17,
ProtVerLo: 14, Minutes: 3,
Filler1: 0, Hours: 0,
StreamId: 0, Type: 0,
Frames: 11,
Seconds: 17,
Minutes: 3,
Hours: 0,
Type: 0,
}, },
}, },
} }
@@ -63,17 +58,12 @@ func BenchmarkArtTimeCodeUnmarshalBinary(b *testing.B) {
func BenchmarkArtTimeCodeMarshalBinary(b *testing.B) { func BenchmarkArtTimeCodeMarshalBinary(b *testing.B) {
data := artnet.ArtTimeCode{ data := artnet.ArtTimeCode{
ID: [8]uint8{'A', 'r', 't', '-', 'N', 'e', 't', 0x00}, StreamId: 0,
OpCode: artnet.OpTimeCode, Frames: 11,
ProtVerHi: 0, Seconds: 17,
ProtVerLo: 14, Minutes: 3,
Filler1: 0, Hours: 0,
StreamId: 0, Type: 0,
Frames: 11,
Seconds: 17,
Minutes: 3,
Hours: 0,
Type: 0,
} }
for b.Loop() { for b.Loop() {
+22 -35
View File
@@ -13,34 +13,22 @@ const (
) )
type ArtTodRequest struct { type ArtTodRequest struct {
ID [8]uint8 filler1 uint8
OpCode uint16 filler2 uint8
ProtVerHi uint8 spare1 uint8
ProtVerLo uint8 spare2 uint8
filler1 uint8 spare3 uint8
filler2 uint8 spare4 uint8
spare1 uint8 spare5 uint8
spare2 uint8 spare6 uint8
spare3 uint8 spare7 uint8
spare4 uint8 Net uint8
spare5 uint8 Command TodRequestCommand
spare6 uint8 Address []uint8
spare7 uint8
Net uint8
Command TodRequestCommand
Address []uint8
} }
func (adr *ArtTodRequest) GetOpCode() uint16 { func (adr *ArtTodRequest) GetOpCode() uint16 {
return adr.OpCode return OpTodRequest
}
func (adr *ArtTodRequest) GetProtVer() uint16 {
return uint16(adr.ProtVerHi)<<8 + uint16(adr.ProtVerLo)
}
func (adr *ArtTodRequest) GetID() [8]uint8 {
return adr.ID
} }
func (adr *ArtTodRequest) UnmarshalBinary(data []byte) error { func (adr *ArtTodRequest) UnmarshalBinary(data []byte) error {
@@ -49,15 +37,14 @@ func (adr *ArtTodRequest) UnmarshalBinary(data []byte) error {
return errors.New("ArtTodRequest packet must be at least 32 bytes long") return errors.New("ArtTodRequest packet must be at least 32 bytes long")
} }
copy(adr.ID[:], data[0:8]) if !slices.Equal(ArtNetID[:], data[0:8]) {
if !slices.Equal(ArtNetID[:], adr.ID[:]) {
return errors.New("ID does not match Art-Net ID") return errors.New("ID does not match Art-Net ID")
} }
adr.OpCode = binary.LittleEndian.Uint16(data[8:10]) opCode := binary.LittleEndian.Uint16(data[8:10])
adr.ProtVerHi = data[10] if opCode != OpTodRequest {
adr.ProtVerLo = data[11] return errors.New("packet does not have the correct OpCode for an ArtTodRequest packet")
}
offset := 12 offset := 12
adr.filler1 = data[offset] adr.filler1 = data[offset]
@@ -85,10 +72,10 @@ func (adr *ArtTodRequest) MarshalBinary() ([]byte, error) {
return nil, errors.New("address count must not be greater than 32") return nil, errors.New("address count must not be greater than 32")
} }
data := make([]byte, 8+16+len(adr.Address)) data := make([]byte, 8+16+len(adr.Address))
copy(data[0:8], adr.ID[:]) copy(data[0:8], ArtNetID[:])
binary.LittleEndian.PutUint16(data[8:10], adr.OpCode) binary.LittleEndian.PutUint16(data[8:10], OpTodRequest)
data[10] = adr.ProtVerHi data[10] = 0
data[11] = adr.ProtVerLo data[11] = 14
data[12] = adr.filler1 data[12] = adr.filler1
data[13] = adr.filler2 data[13] = adr.filler2
data[14] = adr.spare1 data[14] = adr.spare1
+54 -126
View File
@@ -17,234 +17,162 @@ func TestGoodArtTodRequestUnmarshal(t *testing.T) {
Name: "ACT Packet 1", Name: "ACT Packet 1",
Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x80, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x80, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
Expected: &artnet.ArtTodRequest{ Expected: &artnet.ArtTodRequest{
ID: artnet.ArtNetID, Command: artnet.TodFull,
OpCode: artnet.OpTodRequest, Net: 0x00,
ProtVerHi: 0x00, Address: []uint8{0x00},
ProtVerLo: 0x0e,
Command: artnet.TodFull,
Net: 0x00,
Address: []uint8{0x00},
}, },
}, },
{ {
Name: "ACT Packet 2", Name: "ACT Packet 2",
Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x80, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x80, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
Expected: &artnet.ArtTodRequest{ Expected: &artnet.ArtTodRequest{
ID: artnet.ArtNetID, Command: artnet.TodFull,
OpCode: artnet.OpTodRequest, Net: 0x00,
ProtVerHi: 0x00, Address: []uint8{0x10},
ProtVerLo: 0x0e,
Command: artnet.TodFull,
Net: 0x00,
Address: []uint8{0x10},
}, },
}, },
{ {
Name: "ACT Packet 3", Name: "ACT Packet 3",
Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x80, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x80, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
Expected: &artnet.ArtTodRequest{ Expected: &artnet.ArtTodRequest{
ID: artnet.ArtNetID, Command: artnet.TodFull,
OpCode: artnet.OpTodRequest, Net: 0x00,
ProtVerHi: 0x00, Address: []uint8{0x10},
ProtVerLo: 0x0e,
Command: artnet.TodFull,
Net: 0x00,
Address: []uint8{0x10},
}, },
}, },
{ {
Name: "ACT Packet 4", Name: "ACT Packet 4",
Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x80, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x80, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
Expected: &artnet.ArtTodRequest{ Expected: &artnet.ArtTodRequest{
ID: artnet.ArtNetID, Command: artnet.TodFull,
OpCode: artnet.OpTodRequest, Net: 0x00,
ProtVerHi: 0x00, Address: []uint8{0x10},
ProtVerLo: 0x0e,
Command: artnet.TodFull,
Net: 0x00,
Address: []uint8{0x10},
}, },
}, },
{ {
Name: "ACT Packet 5", Name: "ACT Packet 5",
Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x80, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x80, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
Expected: &artnet.ArtTodRequest{ Expected: &artnet.ArtTodRequest{
ID: artnet.ArtNetID, Command: artnet.TodFull,
OpCode: artnet.OpTodRequest, Net: 0x00,
ProtVerHi: 0x00, Address: []uint8{0x10},
ProtVerLo: 0x0e,
Command: artnet.TodFull,
Net: 0x00,
Address: []uint8{0x10},
}, },
}, },
{ {
Name: "ACT Packet 6", Name: "ACT Packet 6",
Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x80, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x80, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
Expected: &artnet.ArtTodRequest{ Expected: &artnet.ArtTodRequest{
ID: artnet.ArtNetID, Command: artnet.TodFull,
OpCode: artnet.OpTodRequest, Net: 0x00,
ProtVerHi: 0x00, Address: []uint8{0x10},
ProtVerLo: 0x0e,
Command: artnet.TodFull,
Net: 0x00,
Address: []uint8{0x10},
}, },
}, },
{ {
Name: "ACT Packet 7", Name: "ACT Packet 7",
Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x80, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x80, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
Expected: &artnet.ArtTodRequest{ Expected: &artnet.ArtTodRequest{
ID: artnet.ArtNetID, Command: artnet.TodFull,
OpCode: artnet.OpTodRequest, Net: 0x00,
ProtVerHi: 0x00, Address: []uint8{0x10},
ProtVerLo: 0x0e,
Command: artnet.TodFull,
Net: 0x00,
Address: []uint8{0x10},
}, },
}, },
{ {
Name: "ACT Packet 8", Name: "ACT Packet 8",
Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x80, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x80, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
Expected: &artnet.ArtTodRequest{ Expected: &artnet.ArtTodRequest{
ID: artnet.ArtNetID, Command: artnet.TodFull,
OpCode: artnet.OpTodRequest, Net: 0x00,
ProtVerHi: 0x00, Address: []uint8{0x10},
ProtVerLo: 0x0e,
Command: artnet.TodFull,
Net: 0x00,
Address: []uint8{0x10},
}, },
}, },
{ {
Name: "ACT Packet 9", Name: "ACT Packet 9",
Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x80, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x80, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
Expected: &artnet.ArtTodRequest{ Expected: &artnet.ArtTodRequest{
ID: artnet.ArtNetID, Command: artnet.TodFull,
OpCode: artnet.OpTodRequest, Net: 0x00,
ProtVerHi: 0x00, Address: []uint8{0x10},
ProtVerLo: 0x0e,
Command: artnet.TodFull,
Net: 0x00,
Address: []uint8{0x10},
}, },
}, },
{ {
Name: "ACT Packet 10", Name: "ACT Packet 10",
Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x80, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x80, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
Expected: &artnet.ArtTodRequest{ Expected: &artnet.ArtTodRequest{
ID: artnet.ArtNetID, Command: artnet.TodFull,
OpCode: artnet.OpTodRequest, Net: 0x00,
ProtVerHi: 0x00, Address: []uint8{0x10},
ProtVerLo: 0x0e,
Command: artnet.TodFull,
Net: 0x00,
Address: []uint8{0x10},
}, },
}, },
{ {
Name: "ACT Packet 11", Name: "ACT Packet 11",
Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x80, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x80, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
Expected: &artnet.ArtTodRequest{ Expected: &artnet.ArtTodRequest{
ID: artnet.ArtNetID, Command: artnet.TodFull,
OpCode: artnet.OpTodRequest, Net: 0x00,
ProtVerHi: 0x00, Address: []uint8{0x10},
ProtVerLo: 0x0e,
Command: artnet.TodFull,
Net: 0x00,
Address: []uint8{0x10},
}, },
}, },
{ {
Name: "ACT Packet 12", Name: "ACT Packet 12",
Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x80, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x80, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
Expected: &artnet.ArtTodRequest{ Expected: &artnet.ArtTodRequest{
ID: artnet.ArtNetID, Command: artnet.TodFull,
OpCode: artnet.OpTodRequest, Net: 0x00,
ProtVerHi: 0x00, Address: []uint8{0x10},
ProtVerLo: 0x0e,
Command: artnet.TodFull,
Net: 0x00,
Address: []uint8{0x10},
}, },
}, },
{ {
Name: "ACT Packet 13", Name: "ACT Packet 13",
Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x80, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x80, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
Expected: &artnet.ArtTodRequest{ Expected: &artnet.ArtTodRequest{
ID: artnet.ArtNetID, Command: artnet.TodFull,
OpCode: artnet.OpTodRequest, Net: 0x00,
ProtVerHi: 0x00, Address: []uint8{0x10},
ProtVerLo: 0x0e,
Command: artnet.TodFull,
Net: 0x00,
Address: []uint8{0x10},
}, },
}, },
{ {
Name: "ACT Packet 14", Name: "ACT Packet 14",
Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x80, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x80, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
Expected: &artnet.ArtTodRequest{ Expected: &artnet.ArtTodRequest{
ID: artnet.ArtNetID, Command: artnet.TodFull,
OpCode: artnet.OpTodRequest, Net: 0x00,
ProtVerHi: 0x00, Address: []uint8{0x10},
ProtVerLo: 0x0e,
Command: artnet.TodFull,
Net: 0x00,
Address: []uint8{0x10},
}, },
}, },
{ {
Name: "ACT Packet 15", Name: "ACT Packet 15",
Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x80, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x80, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
Expected: &artnet.ArtTodRequest{ Expected: &artnet.ArtTodRequest{
ID: artnet.ArtNetID, Command: artnet.TodFull,
OpCode: artnet.OpTodRequest, Net: 0x00,
ProtVerHi: 0x00, Address: []uint8{0x10},
ProtVerLo: 0x0e,
Command: artnet.TodFull,
Net: 0x00,
Address: []uint8{0x10},
}, },
}, },
{ {
Name: "ACT Packet 16", Name: "ACT Packet 16",
Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x80, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x80, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
Expected: &artnet.ArtTodRequest{ Expected: &artnet.ArtTodRequest{
ID: artnet.ArtNetID, Command: artnet.TodFull,
OpCode: artnet.OpTodRequest, Net: 0x00,
ProtVerHi: 0x00, Address: []uint8{0x10},
ProtVerLo: 0x0e,
Command: artnet.TodFull,
Net: 0x00,
Address: []uint8{0x10},
}, },
}, },
{ {
Name: "ACT Packet 17", Name: "ACT Packet 17",
Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x80, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x80, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
Expected: &artnet.ArtTodRequest{ Expected: &artnet.ArtTodRequest{
ID: artnet.ArtNetID, Command: artnet.TodFull,
OpCode: artnet.OpTodRequest, Net: 0x00,
ProtVerHi: 0x00, Address: []uint8{0x10},
ProtVerLo: 0x0e,
Command: artnet.TodFull,
Net: 0x00,
Address: []uint8{0x10},
}, },
}, },
{ {
Name: "ACT Packet 18", Name: "ACT Packet 18",
Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x80, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x80, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
Expected: &artnet.ArtTodRequest{ Expected: &artnet.ArtTodRequest{
ID: artnet.ArtNetID, Command: artnet.TodFull,
OpCode: artnet.OpTodRequest, Net: 0x00,
ProtVerHi: 0x00, Address: []uint8{0x10},
ProtVerLo: 0x0e,
Command: artnet.TodFull,
Net: 0x00,
Address: []uint8{0x10},
}, },
}, },
} }
+11 -16
View File
@@ -16,8 +16,8 @@ const (
) )
type ArtTrigger struct { type ArtTrigger struct {
ID [8]uint8 id [8]uint8
OpCode uint16 opCode uint16
ProtVerHi uint8 ProtVerHi uint8
ProtVerLo uint8 ProtVerLo uint8
filler1 uint8 filler1 uint8
@@ -29,15 +29,7 @@ type ArtTrigger struct {
} }
func (at *ArtTrigger) GetOpCode() uint16 { func (at *ArtTrigger) GetOpCode() uint16 {
return at.OpCode return OpTrigger
}
func (at *ArtTrigger) GetProtVer() uint16 {
return uint16(at.ProtVerHi)<<8 + uint16(at.ProtVerLo)
}
func (at *ArtTrigger) GetID() [8]uint8 {
return at.ID
} }
func (at *ArtTrigger) UnmarshalBinary(data []byte) error { func (at *ArtTrigger) UnmarshalBinary(data []byte) error {
@@ -46,13 +38,16 @@ func (at *ArtTrigger) UnmarshalBinary(data []byte) error {
return errors.New("ArtTrigger packet must be at least 18 bytes long") return errors.New("ArtTrigger packet must be at least 18 bytes long")
} }
copy(at.ID[:], data[0:8]) copy(at.id[:], data[0:8])
if !slices.Equal(ArtNetID[:], at.ID[:]) { if !slices.Equal(ArtNetID[:], at.id[:]) {
return errors.New("ID does not match Art-Net ID") return errors.New("ID does not match Art-Net ID")
} }
at.OpCode = binary.LittleEndian.Uint16(data[8:10]) at.opCode = binary.LittleEndian.Uint16(data[8:10])
if at.opCode != OpTrigger {
return errors.New("packet does not have the correct OpCode for an ArtTrigger packet")
}
at.ProtVerHi = data[10] at.ProtVerHi = data[10]
at.ProtVerLo = data[11] at.ProtVerLo = data[11]
@@ -69,8 +64,8 @@ func (at *ArtTrigger) UnmarshalBinary(data []byte) error {
func (at *ArtTrigger) MarshalBinary() ([]byte, error) { func (at *ArtTrigger) MarshalBinary() ([]byte, error) {
data := make([]byte, 8+10) data := make([]byte, 8+10)
copy(data[0:8], at.ID[:]) copy(data[0:8], at.id[:])
binary.LittleEndian.PutUint16(data[8:10], at.OpCode) binary.LittleEndian.PutUint16(data[8:10], at.opCode)
data[10] = at.ProtVerHi data[10] = at.ProtVerHi
data[11] = at.ProtVerLo data[11] = at.ProtVerLo
data[12] = at.filler1 data[12] = at.filler1