use strict; use POSIX; use lib 'lib'; use Interface6051::LinuxHack; my $interface = new Interface6051::LinuxHack; print "Signal Configurator 1.0\n"; my $test = 0; if (@ARGV && $ARGV[0] eq 'test') { $test = 1; shift @ARGV; } my $valid = 1; my @ids = (); foreach (@ARGV) { $valid &&= m/^(\d+)$/os and $1 >= 0 and $1 <= 256; push (@ids, 0+$_); } unless (@ARGV and $valid) { print "Usage: $0 [test] ID1 [ID2 [ID3 ...]]\n...where IDs are the IDs of the signals (integer 1..256)\n"; exit; } $interface->stop(); print "Connect brown cable to digital ground and yellow cable to digital signal.\n"; my $done = 0; local $SIG{INT} = sub { $done += 1; }; unless ($test) { print "Put signal in packaging. Press ^C when done.\n"; while (not $done) { } sleep 1; print "Commencing programming...\n"; $interface->start(); sleep 1; $done = 0; print "Check power is enabled. Press ^C when done.\n"; while (not $done) { } sleep 1; my $lastID = 0; foreach (@ids) { print "Should be blinking...\n"; sleep 2; if ($_ == 0) { print "Transmitting address $lastID red...\n"; $interface->transmit(33, $lastID == 256 ? 0 : $lastID); } else { print "Transmitting address $_ green...\n"; $interface->transmit(33, $_ == 256 ? 0 : $_); $lastID = $_; } sleep 2; print "Transmitting clear signal...\n"; $interface->transmit(32); sleep 2; print "Stand by...\n"; sleep 2; } print "Finishing...\n"; sleep 5; print "Programming complete.\n"; $interface->stop(); $done = 0; print "Remove signal from packaging. Press ^C when done.\n"; while (not $done) { } } print "Testing signal....\n"; $interface->start(); sleep 2; $done = 0; print "Press ^C when done.\n"; sleep 2; test: while (not $done) { foreach (@ids) { print "$_ green...\n"; $interface->transmit(33, $_ == 256 ? 0 : $_); sleep 1; $interface->transmit(32); sleep 1; last test if $done; print "$_ red...\n"; $interface->transmit(34, $_ == 256 ? 0 : $_); sleep 1; $interface->transmit(32); sleep 1; last test if $done; } } print "Shutting down...\n"; $interface->stop(); print "Done.\n";