Listing 1.
cm17_no_hardware.pl
Home Automation: The X10 Nitty-Gritty
The Perl Journal, Spring 2000
 
#!/usr/bin/perl -w

require 'SerialStub.pl';        # emulate port hardware 

package main;
use ControlX10::CM17;
use strict;

my $serial_object = SerialStub->new (); # creates object

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;

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

The program's output will be something like this:

| Turning address A1 ON
| Turning address A1 OFF
| 
| Repeat same toggle with debugging:
| Turning address A1 ON
| CM17: SerialStub=HASH(0x804a9c4) house=A code=1J
| CM17: Sending: 1101010110101010011000000000000010101101 done
| Turning address A1 OFF
| CM17: SerialStub=HASH(0x804a9c4) house=A code=1K
| CM17: Sending: 1101010110101010011000000010000010101101 done