Listing 2.
cm17_bit_toggle.pl
Home Automation: The X10 Nitty-Gritty
The Perl Journal, Spring 2000
 
#!/usr/bin/perl -w
# cm17_bit_toggle.pl
# USAGE: perl cm17_bit_toggle.pl [ PORT ]
# PORT defaults to COM1 on Win32 and /dev/ttyS0 on linux
# any command line parameter overrides the default
# you'll need to specify which port to use on other OS

require 'start_port.pl';        # initialization for real ports

use ControlX10::CM17;
use strict;

my $serial_object = open_port (@ARGV); 
    # returns newly created object
        # for example, PORT is just passed through if specified

print "Turning address A1 ON\n";
send_cm17($serial_object, 'A1J');
print "Turning address A1 OFF\n\n";
send_cm17($serial_object, 'A1K');

print "Repeat same toggle with debugging:\n";
$ControlX10::CM17::DEBUG = 1;

sleep 1;
print "Turning address A1 ON\n";
send_cm17($serial_object, 'A1J');
sleep 1;
print "Turning address A1 OFF\n";
send_cm17($serial_object, 'A1K');