Perl

Perl is a language for easily manipulating text, files, and processes that is also included in Mac OS X. Here is a short program to monitor the automation bus. Open a terminal windows, type the command /usr/bin/perl -w , copy and paste the lines below, and type using the keyboard Control-D for the program to run:


panare:~ panare$ /usr/bin/perl -w 

# program starts next line

use strict; 

use IO::Socket::INET; 

my $mh200ip = "10.0.1.82"; 

my $ownport = "20000"; 

my $frames ; 

my $socket = IO::Socket::INET ->new ( 

PeerAddr => $mh200ip, 

PeerPort => $ownport, 

Proto => "tcp", 

Type => SOCK_STREAM 

); 

die "Could not create socket: $!\n" unless $socket; 

$socket->send("*99*1##"); # Sending OPEN ACK 

while (1) { 

$socket->recv($frames,128); 

if($frames ne '') 

print "$frames\n"; 

my $data = ($frames); 

my @values = split ('##',$data); 

if($data eq "*1*0*58##") 

`say "light off"`; 

if($data eq "*1*1*58##") 

`say "light on"`; 

else 

print "server closed connection"; 

exit 1; 

# program ends on previous line

# below starts the output of the program after pressing control-D

*#*1##

*#*1##

*1*0*53##

*1*1*53##

*1*0*53##

*#13**22*21*24*34*000*03*29*10*2014##


Contact Us & Help                                                        Site Map                                              © Andres Albanese 2012