Created
October 20, 2012 00:22
-
-
Save pingswept/3921409 to your computer and use it in GitHub Desktop.
Python function for sending DMX via the Rascal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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