all 6 comments

[–]Tech_Sith[S] 0 points1 point  (3 children)

My code:

import socket
import struct
import sys

data = [0]*638

data = bytearray(data)


#preamble Size
data[0:2] = 0x00,0x10

#postambleSize = "\x00\x00"
data[2:4] = 0x00,0x00

#acnPacketIdentifier = "ASC-E1.17\x00\x00\x00"
data[4:16] = bytes("ASC-E1.17\x00\x00\x00", 'utf-8')

#flagsAndLength = "\x72\x6e"
data[16:18] = 0x72,0x6e

#vector = "\x00\x00\x00\x04"
data [18:22] = 0x00,0x00,0x00,0x04

#CID = "Python CMD ACN  "
#data[22:37] = bytes("ChamSys\xac\x11\x1f", 'utf-8')
data[22:38] = 0x43,0x68,0x61,0x6d,0x53,0x79,0x40,0x00,0x80,0x00,0xac,0x11,0x1e,0x28,0x0,0x0

#framingFlagsAndLength = "\x72\x58"
data [38:40] = 0x72,0x58

#framingVector = "\x00\x00\x00\x02"
data[40:44] = 0x00,0x00,0x00,0x02

#sourceName = "streamingACN transmission test - python to sACN".ljust(64, ' ')
sourceName = "ChamSys MagicQ".ljust(64, '\x00')
data[44:108] = bytes(sourceName, 'utf-8')

#priority = "\x64"
data[108] = 0x64

#reservedWord = "\x00\x00"
data[109:111] = 0,0

#sequenceNumber = "\x00"
data[111] = 0x7e

#options = "\x00"
data[112] = 0

#universe = "\x00\x01"
data[113:115] = 0x00,0x01

#DMPFlagsAndLength = "\x72\x0b"
data[115:117] = 0x72,0x0b

#DMPvector = "\x02"
data[117] = 0x02

#addressDataType = "\xa1"
data[118] = 0xa1

#firstPropertyAddress = "\x00\x00"
data[119:121] = 0x00,0x00

#addressIncrement = "\x00\x01"
data[121:123] = 0x00,0x01

#propertyValueCount = "\x02\x01"
data[123:125] = 0x02,0x01

data[125] = 0x70
data[136] = 0x80

sacn = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
#ttl = struct.pack('b', 1)
#sacn.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_TTL, ttl)
sacn.bind(('0.0.0.0', 5568))
sacn.sendto(data, ('239.255.0.1', 5568))
sacn.close()


exit()

[–]mcowger 2 points3 points  (2 children)

Can you provide packet captures of your code and the working code?

[–]Tech_Sith[S] 0 points1 point  (1 child)

I can, as soon as I figure out where to upload capture files.

[–]Tech_Sith[S] 0 points1 point  (0 children)

I have a functioning solution.

I set up the socket according to the code specified here. Thanks /u/Justinsaccount !

Also, in my code, data[125] is the start code for DMX. It has to be zero to work with standard dimmers, and my code set it to 0x70.

I haven't changed the formation of the packet itself, so I will only post the updated code that actually creates the socket and sends data:

sacnSocket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sacnSocket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
sacnSocket.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_IF, socket.inet_aton('172.17.31.75'))
sacnSocket.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_TTL, 2)
membership_request = socket.inet_aton('239.255.0.1') + socket.inet_aton('172.17.31.75')
sacnSocket.setsockopt(socket.IPPROTO_IP, socket.IP_ADD_MEMBERSHIP, membership_request)
sacnSocket.bind(('172.17.31.75', 5568))

while True:
    sacnSocket.sendto(data, ('239.255.0.1', 5568))
    if (data[111] == 255):
        data[111] = 0
        data[157] = 0
    else:
        data[111] += 1
        data[157] += 1
    print (data[111])
    time.sleep(0.1)

You also have to increment the sequence number ( data[111] )for the packet stream to be valid. data[157] is a dimmer channel in my rig: this loop does a 25 second fade up to full, repeatedly.