Home | News | Products | Support | Download | Sales | library | Guests | Contact | WebCam | Links
CDS Logo LanBox-Talk mail archive
 

By date: Prev | Next | Index By thread: Prev | Next | Index

Subject[LCtalk] AppleScripting the LanBox with perl
FromFokko van Duin
DateFri, 17 Jun 2005 15:45:19 +0300


Hello all,

From time to time I get the question whether you can use AppleScript to control a LanBox. As LCedit+ is not scriptable, Matthijs made a small perl script which can be invoked with AppleScript in order to send a LanBox command. (also as webserver cgi?)

What do you need:
1. A computer running OSX, or Linux for the perl only script (maybe perl also runs on Windows).
2. A LanBox connected via a serial/USB port, or connected to Ethernet network.
3. The perl shell command script below saved as a file called cmdwrite.pl
4. The LC+ reference manual for all LanBox commands (see inside the manuals folder in the LCedit+ folder).


In AppleScript if you do this:
do shell script "perl ~/Desktop/cmdwrite.pl 192.168.1.77 777 '*00050000#'"

It will return the string *F8FD00CD#> which is the type and version of your Lanbox.


In AppleScript if you do this: do shell script "perl ~/Desktop/cmdwrite.pl 192.168.1.77 777 '*5601000A01#'"

Your LanBox will go instant to cue 10.1 in layer A :-)


BTW you may replace the IP with a DNS name like demo.lanbox.com


For serial ports you can use the USB modem name instead of the IP + port: do shell script "perl ~/Desktop/cmdwrite.pl usbmodem18111 '*00050000#'"

To get a list of serial ports:
do shell script "ls /dev/cu.*"


Save the plain text between ### as cmdwrite.pl on your desktop:

###
#!/usr/bin/perl

use strict;
use warnings;

use IO::Handle;

my $path = shift  or die "Usage: $0 <target> <commands>\n";
my $fh;

STDOUT->autoflush;

sub doread {
	while (sysread $fh, my $buf, 256) {
		print $buf;
		$fh->blocking(0);
	}
	$fh->blocking(1);
	print "\n";
}

if (-e $path or -e "/dev/cu.$path") {
	$path = "/dev/cu.$path"  if -e "/dev/cu.$path";
	open $fh, '+<', $path  or die "$path: $!\n";
	$fh->blocking(0);
	until (sysread $fh, my $buf, 1) {
		print $fh " #\n";
		select(undef, undef, undef, 0.1);
	}
} else {
	require IO::Socket::INET;
	$fh = new IO::Socket::INET PeerAddr => $path, PeerPort => 777
		or die "$path: $@\n";
	doread;
}

$fh->autoflush;

while (@ARGV) {
	print $fh shift, "\n";
	select(undef, undef, undef, 0.1);
	doread;
}
###


Have fun,

Fokko van Duin,                     Creators of the LanBox-LC
CDS advanced technology bv,         DMX lighting controller.
http://www.cds.nl/                  http://www.lanbox.com/

Member of MIDI Manufacturers Association, MMA
  • (- current message -), Fokko van Duin

By date: Prev | Next | Index By thread: Prev | Next | Index