martedì 25 dicembre 2007

Twinhan Tech Remote Control with linux !!

Per chi come me possiede una scheda dvb con telecomando e ricevitore usb ad infrarossi questo howto puo' risultare utile :)
Per poter usare il telecomando basta avere un kernel che supporti le periferiche usb HID, infatti attaccando il ricevitore ad infrarossi si puo' notare che il telecomando viene riconosciuto come se fosse una semplice tastiera USB. Per poter pero' sfruttare appieno tutti i tasti e' necessario avere installato lirc.

Step 1:
colleghiamo il ricevitore usb al pc

Step 2:
verifichiamo dove viene mappato:
[root@localhost miki]# cat /proc/bus/input/devices
[...]
I: Bus=0003 Vendor=6253 Product=0100 Version=0110
N: Name="Twinhan Tech Remote Control"
P: Phys=usb-0000:00:1d.0-1/input0
S: Sysfs=/class/input/input9
U: Uniq=1111111
H: Handlers=kbd event9
B: EV=120003
B: KEY=800000 0 e0b0ffdf 1cfffff ffffffff fffffffe
B: LED=1f

I: Bus=0003 Vendor=6253 Product=0100 Version=0110
N: Name="Twinhan Tech Remote Control"
P: Phys=usb-0000:00:1d.0-1/input1
S: Sysfs=/class/input/input10
U: Uniq=1111111
H: Handlers=mouse3 event10
B: EV=7
B: KEY=70000 0 0 0 0 0 0 0 0
B: REL=3

A noi interessa la riga: Sysfs
Possiamo notare subito che vengono creati due device nodes:
S: Sysfs=/class/input/input9
S: Sysfs=/class/input/input10
A noi interessa il primo.
Bisogna fare attenzione, dal momento che potrebbero cambiare ad ogni avvio della macchina.
Dipende dal numero di periferiche usb connesse alla macchina o dalla sequenza di inserimento.
Quindi sorge un problema, come facciamo a fare in modo che venga riconosciuto in maniera
univoca ed indipendente dal numero di periferiche connesse? Per fortuna ci viene in aiuto udev!! :)

Step 3:
[root@localhost miki]# udevinfo -a -p /class/input/input9
output molto prolisso, a noi interessa la prima linea {modalias}
[..]
looking at device '/class/input/input9':
KERNEL=="input9"
SUBSYSTEM=="input"
DRIVER==""
ATTR{modalias}=="input:b0003v6253p0100e0110-e0,1,11,14,k74,75,77,7D,7E,7F,B7,raml0,1,2,3,4,sfw"
ATTR{uniq}=="1111111"
ATTR{phys}=="usb-0000:00:1d.0-1/input0"
ATTR{name}=="Twinhan Tech Remote Control"
[..]

Creamo una nuova regola per udev :
[root@localhost miki]# gedit /etc/udev/rules.d/10-local.rules
e mettiamo dentro:

KERNEL=="event*",ATTRS{modalias}=="input:b0003v6253p0100e0110
-e0,1,11,14,k74,75,77,7D,7E,7F,B7,raml0,1,2,3,4,sfw",SYMLINK="input/irremote"

Step 4:
Scolleghiamo il ricevitore usb ad infrarossi, proviamo a ricollegarlo e verifichiamo se viene
creato il device: /dev/input/irremote

Step 5:
Testiamo se sta funzionando:
[root@localhost miki]# hexdump -C /dev/input/irremote
cliccando alcuni tasti del telecomando dovremmo vedere delle stringhe nel terminale.
Se vengono fuori il telecomando sta funzionado :)
clicchiamo control+c per uscire.

Step 6:
file di configurazione per Lirc:

Per configurare lirc dobbiamo modificare due file presenti in /etc/lirc:
  • hardware.conf
  • lircd.conf
vediamo il primo:

# cat /etc/lirc/hardware.conf

# /etc/lirc/hardware.conf for the TwinHan remote control
# See http://www.doctort.org/adam/wp-admin/post.php?action=edit&post=181
#

# Arguments which will be used when launching lircd
LIRCD_ARGS=""

#Don't start lircmd even if there seems to be a good config file
START_LIRCMD=false

#Try to load appropriate kernel modules
LOAD_MODULES=true

# Run "lircd --driver=help" for a list of supported drivers.
DRIVER="dev/input"

# If DEVICE is set to /dev/lirc and devfs is in use /dev/lirc/0 will be
# automatically used instead
DEVICE="/dev/input/irremote"
MODULES=""

# Default configuration files for your hardware if any
LIRCD_CONF=""
LIRCMD_CONF=""

vediamo il secondo:

# cat /etc/lirc/lircd.conf

# LIRC configuration for the TwinHan remote control.
# See http://www.doctort.org/adam/wp-admin/post.php?action=edit&post=181
#

begin remote
name TwinHan
bits 32
begin codes
FULLSCREEN 0x1002c
REC 0x10066
FAVOURITE 0x1002f
REWIND 0x10017
FASTFORWARD 0x10031
CH+ 0x10068
VOL- 0x1006c
PLAY 0x1001c
VOL+ 0x10067
CH- 0x1006d
RECALL 0x1002e
STOP 0x1006b
PAUSE 0x10014
MUTE 0x10032
CANCEL 0x10001
CAPTURE 0x10019
PREVIEW 0x10025
EPG 0x10012
RECORDLIST 0x10026
TAB 0x1000f
TELETEXT 0x1001e
0 0x1000b
1 0x10002
2 0x10003
3 0x10004
4 0x10005
5 0x10006
6 0x10007
7 0x10008
8 0x10009
9 0x1000a
end codes
end remote

1 commento:

miobio ha detto...

GRANDE!!!

è proprio quello che cercavo! ma ke dongle USB hai usato? C'è il suo telecomando apposta?