User Tools

Site Tools


doc:appunti:linux:tux:telecomando

Un telecomando per controllare Linux

I programmi

lircd

Il programma lircd è contenuto nel pacchetto Debian Etch lirc. Si tratta di un demone che riceve i codici dal ricevitore infrarosso e li rende disponibili ad altri programmi tramite Unix socket.

Grazie alla disponibilità di numerosi driver può interfacciarsi a svariati dispositivi (su porta seriale, parallela, schede TV, …). A seconda del dispositivo la comunicazione con l'hardware avviene tramite i moduli standard del kernel oppure con moduli kernel da compilare ad-hoc (LIRC kernel modules). Nel secondo caso Debian mette a disposizione il pacchetto lirc-modules-source, con i sorgenti da compilare rispetto al kernel in uso.

irw

Utile per debug: mentre lircd è in esecuzione stampa tutti i comandi ricevuti via Unix socket. Utile soprattutto per vedere il nome esatto del comando, che serve per costruire i file di configurazione di irexec e simili. L'output del comando è qualcosa di simile:

# irw
0000000000000025 00 Chan_Last PinnacleSysPCTVRemote
000000000000003f 00 Chan+Play PinnacleSysPCTVRemote
000000000000001d 00 Menu PinnacleSysPCTVRemote
000000000000003c 00 Mute PinnacleSysPCTVRemote

lircmd

Demone che riceve i codici telecomando da lircd e li converte in azioni del mouse. Può emulare un mouse MouseSystems, IntelliMouse o IMPS/2.

irxevent

Fa parte del pacchetto Debian lirc-x, è simile al programma irexec, ma studiato per funzionare nell'ambiente X-Window.

irexec

Fa parte del pacchetto lirc. Il programma deve essere lanciato come demone, resta in attesa dei codici telecomando ricevuti da lircd e quindi esegue le azioni specificate in un file di configurazione (solitamente $HOME/.lircrc). Dovrebbe essere lanciato dall'utente che esegue l'applicazione da controllare con il telecomando. Probabilmente ogni applicazione ha bisogno di un diverso file di configurazione .lircrc.

Un esempio estratto del file di configurazione per controllare il programma tvtime:

begin
    prog = irexec
    button = POWER
    config = tvtime &
    config = tvtime-command QUIT
end
# Menu navigation.
begin
    prog = irexec
    button = CHANNEL+
    config = tvtime-command UP
    repeat = 1
end
begin
    prog = irexec
    button = VOL+
    config = tvtime-command RIGHT
    repeat = 2
end
...

Come si vede si utilizza un programma di supporto (tvtime-command) che invia il comando opportuno ad una istanza del programma tvtime in esecuzione. Per attivare il tutto si esegue:

irexec -d lircrc.tvtime

irkick

Accessorio di KDE, fa parte del pacchetto Debian Etch kdelirc. Riceve i codici telecomando dal demone lircd e li rende disponibili all'ambiente KDE. Può avviare applicazioni, inviare azioni specifiche ai programmi compatibili, ecc.

L'hardware

Kanam Accent HT-PC IR-100 Remote Control

The Kanam Accent infrared receiver is integrated into the Home Theater PC case (I own the HT200B model). It is based on the AT89C2051-24PI chip, which decodes RC5 based Philips Remote controls.

Kanam HT200B case Kanam Accent IR-100 Remote Control

The power button on the remote, controls the mainboard power switch. The IR receiver must be powered from the 5v standby line of the power supply. The remote keys are delivered to user processes via the serial port, serial communication uses the standard serial port at 1200, 8N1. For some insight on the protocol, see the source code of my LIRC driver (hw_accent.c, plenty of comments).

LIRC does not support this remote control out of the box (as of v.0.8.0). To make it working, I wrote a new driver called accent, based on the pinsys one (Pinnacle Systems PCTV). The first working patch was provided by Landro Dardini.

Here you are the sources of my Kanam Accent driver and here a Debian Testing (Etch) binary package including it: lirc_0.8.0-9_i386.deb. I hope to let include this new driver in the upcoming versions of LIRC.

To use the remote in a Debian system, just configure /etc/lirc/hardware.conf setting DRIVER=“accent” and DEVICE=“/dev/ttyS0”. Then copy lircd.conf.kanam_accent_serial from /usr/share/lirc/remotes/ to /etc/lirc/lircd.conf and restart the lirc service.

To start the lircd from the comman line and see some debugging messages (lircd does not go to the background) use:

/usr/sbin/lircd -n --driver=accent --device=/dev/ttyS0 /etc/lirc/lircd.conf

and check the received codes with irw:

irw
9046426266220900 00 1 kanam_accent_serial
9046422264220900 00 2 kanam_accent_serial
9046426266422600 00 win_key kanam_accent_serial
9046426266094200 00 menu_key kanam_accent_serial
9046422289664200 00 vol- kanam_accent_serial
9046422289664200 01 vol- kanam_accent_serial
9046422289664200 02 vol- kanam_accent_serial
9046426262260900 00 vol+ kanam_accent_serial
9046422266260900 00 esc kanam_accent_serial
9046422299424200 00 left kanam_accent_serial
9046422291664200 00 up kanam_accent_serial
9046422289264200 00 ent kanam_accent_serial
...

Note the repeated vol- key.

Telecomando Pinnacle PCTV Stereo

Telecomando fornito in dotazione alla scheda PCTV Stereo. Il ricevitore infrarosso si collega alla porta seriale. Il driver utilizzato da lircd è pinsys tramite il modulo seriale standard del kernel (non sono richiesti quindi moduli kernel speciali LIRC).

Programmi da telecomandizzare

tvtime

To start searching for stations run tvtime-scanner:

Reading configuration from /etc/tvtime/tvtime.xml
Reading configuration from /home/niccolo/.tvtime/tvtime.xml
Scanning using TV standard PAL.
/home/niccolo/.tvtime/stationlist.xml: No existing PAL station list "Custom".
Scanning from  44.00 MHz to 958.00 MHz.
Found a channel at 166.00 MHz (165.75 - 166.25 MHz), adding to channel list.
Found a channel at 191.50 MHz (190.00 - 193.00 MHz), adding to channel list.
...
Checking 207.25 MHz:  - No signal

Station list is saved into ~/.tvtime/stationlist.xml.

The tvtime web site suggests to use irexec, we will use the KDE applet IRKick instead, because we want a complete integration with other desktop applications.

  1. Right-clicking the IRKick system tray icon, menu Configure…
  2. Add a new mode for the current remote control, call it tvtime.
  3. Add an an action into the default mode: KDE Program Launcher, Execute, /usr/bin/tvtime. Associate it to the remote key hdtv.
  4. For the same remote key hdtv, add the action Switch to tvtime mode, with the option Do actions before.
  5. In the tvtime mode, add all the keys that you need. Each key will execute the program /usr/bin/tvtime-command via KDE Program Launcher. Pass to tvtime-command the argument CHANNEL_1, CHANNEL_2, TOGGLE_FULLSCREEN, LEFT, DOWN, … See the man page for tvtime-command.
  6. In the tvtime mode, add an action Exit from current mode associated to the esc remote key.

xmms

Esiste il pacchetto Debian xmms-lirc, un plug-in per Xmms che dovrebbe abilitare il controllo via infrarossi. Ha bisogno di un file di configurazione standard .lircrc, ma non serve avere irexec in esecuzione.

doc/appunti/linux/tux/telecomando.txt · Last modified: 2007/02/17 18:23 by 127.0.0.1