Remote Control of Snackamp, via sockets FROM: http://wiki.tcl.tk/864 (imaged on 2009 mar 19) LIRC [www.lirc.org] and WinLIRC [winlirc.sourceforge.net] are two popular programs to connect those infrared/RF remote devices to a computer. It is deceptively easy to connect Tcl to LIRC/WinLIRC to allow the remote controller to interface with Tcl applications. The code below is really all there is too it. It shows an example from snackAmp which will give you the general idea. ## # LIRC Handler for remote controls # namespace eval irc { variable socket 0 variable port $snackAmpSettings(ircPort) variable host $snackAmpSettings(ircHost) } proc irc::Server {args} { variable socket variable port variable host if {[string length [string trim $host]]==0} { set host [info hostname] } catch {close $socket} result if [catch {set socket [socket $host $port]} result] { saLog "Error Establishing Server $::errorInfo" } else { fconfigure $socket -translation auto fileevent $socket readable [list irc::Process $socket] saLog "IRC Server Established on port $port" } } proc irc:Close {args} { variable socket catch {close $socket} result } ######################################################################### # Function : irc::Process # Description : Called from fileevent on a readable input on my port # Author : Tom Wilkason # Date : 1/31/2004 ######################################################################### proc irc::Process {sock} { variable socket ;# If eof or partial line then close up the channel now if {[eof $sock] || [catch {gets $sock line}]} { # end of file or abnormal connection drop close $sock set socket 0 irc::Server } else { # Process the received command line # The fourth param is the remote type e.g. "atiremotewonder" set remote [lindex $line 3] # The third parameter is the ascii command set command [lindex $line 2] switch -- [string tolower $command] { vol_up {bumpLevel 2} vol_down {bumpLevel -2} fastforward {Next} rewind {Prev} 1 - 2 - 3 - 4 - 5 { db::setVal $::TA(currentMF) Rating [string repeat * $command] } pause {Pause} stop {Stop} play {Play} channel_up {bumpScaling .1} channel_down {bumpScaling -.1} mute {Pause} right {macros::skipPlay 10} left {macros::skipPlay -10} record {taExit} default {puts $line} } } ;#end line } irc::Server package provide ircserver 1.0