From: Wally K. <ki...@fn...> - 2001-02-26 20:38:50
|
A while back there was some discussion about the problem of having so many transceivers. (one for each house code used). I got a MR26A from x10.com (only $9.99 after my gift voucher) and tried some testing. My interest is simply in basic on/off control. (actually, 32 "triggers" per house code) The biggest problem with the MR26A is it's limited range. (~30') Fine in our control room area, but not so good for most "house" applications. Test code included. - Wally ---------------------------------------------------------------------------------------- # Category=test # serial connection to a MR26A RF -> serial device from x10.com # can decode all house and unit codes for on and off # (dimming not supported in this test prog) # biggest problem with the MR26A is it's limited range # serial1 # baud rate = 9600 # datatype = raw # handshake = none $rf = new Serial_Item(undef, undef, 'serial1'); my $data; my $limit; my $hc = $2; my $uc = $3; # table to map the hex values of house code my %house = ('A' => '6','B' => '7','C' => '4','D' => '5','E' => '8','F' => '9','G' => 'A','H' => 'B','I' => 'E','J' => 'F','K' => 'C','L' => 'D','M' => '0','N' => '1','O' => '2','P' => '3'); # table to map the unit codes. my %unit = ( '1on' => '000', '2on' => '010', '3on' => '008', '4on' => '018', '5on' => '040', '6on' => '050', '7on' => '048', '8on' => '058', '9on' => '400', '10on' => '410', '11on' => '408', '12on' => '418', '13on' => '440', '14on' => '450', '15on' => '448', '16on' => '458', '1off' => '020', '2off' => '030', '3off' => '028', '4off' => '038', '5off' => '060', '6off' => '070', '7off' => '068', '8off' => '078', '9off' => '420', '10off' => '430', '11off' => '428', '12off' => '438', '13off' => '460', '14off' => '470', '15off' => '468', '16off' => '478'); if ($data = said $rf) { # incoming frames appear to be 5 bytes in size # convert incoming bytes to hexidecimal (2 chars/byte) my $hex = unpack "H10", $data; # acknowledge commands only once if (active $limit) { print_log "timer retrigger"; set $limit 1; return; } else # one second timeout { $limit = new Timer; set $limit 1; } print_log "\nData = $hex"; # # data appears to be a common 2 byte header # with 2 bytes of data # and a 1 byte trailer # (shown as hexidecimal) # like D5AAxyyyAA # where D5AA is the header, AA is the trailer # x is the "house info" and # yyy is the "unit info" # check for common header data if ($hex =~ /d5aa/) { # extract the house and unit info $hex =~ m/^(....)(.)(...)/; print_log "code= $2 $3"; $hc = $2; $uc = $3; # check for specific house and unit code # # house code if ($hc eq $house{'A'}) { if ($uc eq $unit{'1on'}){speak "A1 on";} elsif ($uc eq $unit{'1off'}){speak "A1 off";} elsif ($uc eq $unit{'2on'}){speak "A2 on";} elsif ($uc eq $unit{'2off'}){speak "A2 off";} } # other house codes elsif ($hc eq $house{'B'}) { if ($uc eq $unit{'4on'}){print_log "B4 on";} elsif ($uc eq $unit{'4off'}){print_log "B4 off";} } } # end header match } # end said from serial |