Created
December 1, 2013 03:29
-
-
Save fdemmer/7728189 to your computer and use it in GitHub Desktop.
send an art-net udp packet (ArtDMX)
This file contains hidden or 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
#!/usr/bin/env perl | |
use IO::Socket::INET; | |
my $sig = 'Art-Net'.pack('x'); | |
my $op = pack('v', 0x5000); | |
my $ver = pack('n', 14); | |
my $seq = pack('x'); | |
my $phy = pack('x'); | |
# "universe" | |
my $port = pack('n', 0); | |
my @channels = (0) x 512; | |
$length = pack('n', scalar @channels); | |
# set some stuff! | |
$channels[11] = 128; | |
$channels[12] = 255; | |
$channels[13] = 255; | |
$channels[15] = 4; | |
$channels[14] = 2; | |
$channels[16] = 0; | |
my $data = pack('C*', @channels); | |
my $message = $sig.$op.$ver.$seq.$phy.$port.$length.$data; | |
my $sock = IO::Socket::INET->new( | |
Proto => 'udp', | |
PeerPort => 6454, | |
PeerAddr => '192.168.10.90', | |
) or die "Could not create socket: $!\n"; | |
$sock->send($message) or die "Send error: $!\n"; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment