Skip to content

Instantly share code, notes, and snippets.

@pingswept
Created October 20, 2012 00:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pingswept/3921409 to your computer and use it in GitHub Desktop.
Save pingswept/3921409 to your computer and use it in GitHub Desktop.
Python function for sending DMX via the Rascal
def sendDMX(data):
import serial
# Make a DMX packet out of the data
dmxPacket = chr(0x00) + ''.join(chr(element) for element in data)
# To create sync signal (break and mark after break, in DMX-speak),
# slow port down and send a long 0
slow = serial.Serial('/dev/ttyS1', 19200)
slow.write(chr(0x00))
slow.close()
# Sync done; send out the data
fast = serial.Serial('/dev/ttyS1', 250000, stopbits=serial.STOPBITS_TWO)
fast.write(dmxPacket)
fast.close()
# Usage example
#
# >>> import dmx
# >>> dmx.sendDMX([0xAA, 0x55, 0x01, 0x81])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment