[1]Wireless (RF) sensors that attaches to a PC through a serial port. The unit decodes the RF signals and X10 provides software that will control X-10 devices, MP3 players, etc.X10 also makes some combination RF/IR remotes that can sent more than just the typical light commands to the mr26a (example UR47a, UR81a, ...). These map each button of the remote to a signal that is decoded by the mr26a. Below is a little application that read the mr26a and displays the button pressed on the RF remote. (This code is based off the How to read the serial port, and display in hexadezimal example)
# Please send any comments/bug reports to
# Michael Jacobson (mpjacobson2000@yahoo.com)
# tested with Tcl/Tk 8.4b3
### Constants
set baudrate 9600
set parity n
set databits 8
set stopbits 1
set comport com2:
### Button Mapping
set dlable {POWER PC TITLE SUBTITLE DISPLAY RETURN MENU EXIT \
LEFT UP RIGHT DOWN OK PLAY STOP SKIPPREV \
SKIPNEXT REWIND FORWARD PAUSE RECORD RECALL ONE TWO \
THREE FOUR FIVE SIX SEVEN EIGHT NINE ZERO \
ABSWITCH ENTER CHANNELUP CHANNELDOWN VOLUMEUP VOLUMEDOWN MUTE LIGHT1ON \
LIGHT2ON LIGHT3ON LIGHT4ON LIGHT5ON LIGHT6ON LIGHT7ON LIGHT8ON LIGHT1OFF \
LIGHT2OFF LIGHT3OFF LIGHT4OFF LIGHT5OFF LIGHT6OFF LIGHT7OFF LIGHT8OFF ALLLIGHTSON \
ALLLIGHTSOFF}
set dcode {EEF0 EED4 EED6 EED4 EE3A EED8 EEB6 EEC9 \
EED2 EED5 EED1 EED3 EE52 EEB0 EE70 EE00 \
EE00 EE38 EEB8 EE72 EEFF EEF2 EE82 EE42 \
EEC2 EE22 EEA2 EE62 EEE2 EE12 EE92 EE02 \
EEBA EE52 EE40 EEC0 EE60 EEE0 EEA0 6000 \
6010 6008 6018 6040 6050 6048 6058 6020 \
6030 6028 6038 6060 6070 6068 6078 6090 \
6080}
### G U I
text .t1 -width 85 -font {courier 8 } -tabs {3c 6c 9c 13c left}
pack .t1 -side top -anchor nw
button .b1 -text Exit -command exit
pack .b1 -side bottom -anchor nw -fill x -expand true
wm title . "X-10 RF Signal to Hex Convertor ($comport)"
### M A I N
.t1 tag configure underline -underline true
.t1 tag configure bold -font {courier 10 bold}
.t1 tag configure finsih -font {courier 6}
.t1 insert end "\tRead $comport $baudrate, Parity=$parity,\
Databits=$databits, Stopbits=$stopbits\n\n" {underline bold}
### Procedures
set olddata ""
proc rd_chid {chid} {
global olddata oldtime
set newtime [clock clicks -milliseconds]
set msg [read $chid]
.t1 insert @0,0 . ;#data received
if {[string equal $msg $olddata]} {
if {[expr $newtime - $oldtime] < 200} {
set oldtime $newtime
return ;# debounce the button
}
}
set oldtime $newtime
set olddata $msg
set listOfLetters [split $msg {} ]
set serialIPinHex ""
foreach iChar $listOfLetters {
scan $iChar "%c" decimalValue
set serialIPinHex "$serialIPinHex [format "%02X" $decimalValue ]"
}
set out_rfdata "[lindex $serialIPinHex 2][lindex $serialIPinHex 3]"
set result_updaterf [rfdecode $out_rfdata]
.t1 insert @0,0 "rf data sent:\"0x$out_rfdata\", remote code:\"$result_updaterf\"\n"
}
proc rfdecode {data} {
global dlable dcode
set fnd [lsearch $dcode $data]
if {$fnd == -1} {
set output "Code not found : $data"
} else {
set output [lindex $dlable $fnd]
}
return $output
}
proc open_com {} {
global com comport baudrate parity databits stopbits
set com [open $comport r+]
fconfigure $com -mode $baudrate,$parity,$databits,$stopbits \
-blocking 0 -translation binary -buffering none
fileevent $com readable [list rd_chid $com]
}
proc Exit {} {
global com
close $com
exit
}
wm protocol . WM_DELETE_WINDOW {Exit}
open_com
