Difference between revisions of "How to make use of IrDA"

From ThinkWiki
Jump to: navigation, search
(all long fixed - leaving just one that might still be relevent)
(I got LIRC working on a T41 after a bit of experimenting. Cleaning up the documentation)
Line 47: Line 47:
  
 
==LIRC and IrDA==
 
==LIRC and IrDA==
Usually, IrDA ports are not compatible with LIRC, but you may have luck using lirc_sir. For some Laptops it is important, that you never try to load the nsc-ircc. Even when loading fails or you unload the module mode2 will not work.
+
LIRC allows the use of infrared remote controls with Linux. Usually, IrDA ports are not compatible with LIRC, but you may have luck using lirc_sir, as follows;
  
If loading the <tt>lirc_sir</tt> module shows something like the following in {{cmdroot|dmesg}} output, you are lucky and can use LIRC with the IrDA port to remote control your ThinkPad.
+
Go into your BIOS setup, and ensure that Infrared is fully enabled and that resources are assigned. I suggest using IO 2f8 and IRQ 3.
lirc_sir: I/O port 0x02f8, IRQ 3.
 
lirc_sir: Installed.
 
  
You might need to force the io and irq settings. For instance, if in your BIOS your Infrared IO is 0x03f8 and IRQ is 4, do the following when inserting the module:
+
Boot into Linux, and first ensure the setserial program is installed. Running {{cmdroot|/bin/setserial /dev/ttyS1}} should return at this point:
 +
/dev/ttyS1, UART: undefined, Port: 0x02f8, IRQ: 3
 +
If setserial cannot be found, install the setserial package with your distributions package management software
  
  modprobe lirc_sir io=0x03f8 irq=4
+
Then in Linux create a file {{path|/etc/modprobe.d/lirc.conf}} with the following content:
 +
# prevent nsc_ircc from loading (blacklist might not be enough)
 +
# and pass options to lirc_sir to load it on ttyS1
 +
blacklist nsc_ircc
 +
install nsc_ircc /bin/true
 +
  options lirc_sir io=0x2f8 irq=3
 +
install lirc_sir /bin/setserial /dev/ttyS1 uart none port 0 irq 0; /sbin/modprobe --ignore-install lirc_sir
  
If it fails with "Device or resource busy", you may want to install the setserial tool and run it with {{cmdroot|setserial /dev/ttyS0 uart none}} or {{cmdroot|setserial /dev/ttyS1 uart none}}. After that lirc_sir should be loadable.
+
At this point it is best to reboot, to ensure that nsc-ircc was never loaded. Several things can go wrong if the steps are not followed accurately. You might get an error when loading lirc_sir that the device is busy, or your system may even hang.
  
On a Thinkpad R40 running Ubuntu Feisty, I had to disable the nsc-ircc driver to
+
Now do a {{cmdroot|modprobe lirc_sir}} and check {{cmdroot|dmesg}} output. You should see something like this:
give lirc first access to the IR port. I created a file in /etc/modprobe.d with
+
lirc_dev: IR Remote Control driver registered, major 61
 
+
lirc_dev: lirc_register_plugin: sample_rate: 0
blacklist nsc-ircc
+
lirc_sir: I/O port 0x02f8, IRQ 3.
install lirc_sir /bin/setserial /dev/ttyS1 uart none port 0 irq 0; \
+
lirc_sir: Installed.
    /sbin/modprobe --ignore-install lirc_sir
 
 
 
You might also need to {{cmdroot|modprobe actisys-sir}}{{cmdroot|modprobe tekram-sir}}, and {{cmdroot|modprobe lirc-sir}} if you are using the SIR on the thinkpad (modules are from kernel 2.6).
 
  
 +
Now we are ready to start configuring LIRC.
 +
{{Todo|cleanup LIRC config}}
 
Also, do not forget to start the lirc daemon, otherwise no output will be given (you better try running it not as a daemon first, so you can see the output).
 
Also, do not forget to start the lirc daemon, otherwise no output will be given (you better try running it not as a daemon first, so you can see the output).
 
   lircd -d /dev/lirc0 /etc/lircd.conf --nodaemon
 
   lircd -d /dev/lirc0 /etc/lircd.conf --nodaemon

Revision as of 13:53, 20 March 2009

The purpose of this document is to get the IrDA hardware in your ThinkPad operational, setting up communication to other devices is not covered. However, the external links section can prove useful for this.

Serial IR (SIR)

SIR is limited to serial datarates up to 115.2Kb/s

On modern distributions all configuration might be taken care of automatically by starting the irda service # service irda start. If not try the following;

To use it, run # irattach /dev/ttyS1 -s; modprobe ircomm-tty

Then turn on your IrDA-capable device and put it within range, and point your software (e.g., minicom) to /dev/irda0.

Kernel configuration

Edit /etc/modprobe.conf and add the following lines

alias tty-ldisc-11 irtty-sir
alias char-major-161 ircomm-tty

Fast IR (FIR)

FIR is the preferred mode of IrDA operation and operates at a maximum bandwidth of 4 Mbps

On modern distributions this should all be automatically handled by simply starting the idra service # service irda start. If not try the following;

Kernel configuration

Edit /etc/modprobe.conf and add the following lines

alias irda0 nsc-ircc

Make sure that setserial is in right directory (e.g not in /usr/bin/setserial).After that if irdadump still gives nothing try:

echo 1 > /proc/sys/net/irda/discovery

Known problems

  • If you read something like "ttyS1: LSR safety check engaged!" and "irattach: tcgetattr: Input/output error" in the system log, try limiting the FIR max baud rate (echo 57600 > /proc/sys/net/irda/max_baud_rate). This did the trick for me when I was trying to synchronize my Ericsson T39m with my Thinkpad R51 (multisync, evolution-2.8, KDE 3.5.5, openSUSE 10.2).

Some other things you might want to do with IrDA

  • add fast PPP support:
# modprobe irnet
  • if needed, limit further the size of the transmit window
# echo 1 > /proc/sys/net/irda/max_tx_window
  • set the connection speed to 4Mbit in FIR mode:
# echo 4000000 > /proc/sys/net/irda/max_baud_rate

LIRC and IrDA

LIRC allows the use of infrared remote controls with Linux. Usually, IrDA ports are not compatible with LIRC, but you may have luck using lirc_sir, as follows;

Go into your BIOS setup, and ensure that Infrared is fully enabled and that resources are assigned. I suggest using IO 2f8 and IRQ 3.

Boot into Linux, and first ensure the setserial program is installed. Running # /bin/setserial /dev/ttyS1 should return at this point:

/dev/ttyS1, UART: undefined, Port: 0x02f8, IRQ: 3

If setserial cannot be found, install the setserial package with your distributions package management software

Then in Linux create a file /etc/modprobe.d/lirc.conf with the following content:

# prevent nsc_ircc from loading (blacklist might not be enough)
# and pass options to lirc_sir to load it on ttyS1
blacklist nsc_ircc
install nsc_ircc /bin/true
options lirc_sir io=0x2f8 irq=3
install lirc_sir /bin/setserial /dev/ttyS1 uart none port 0 irq 0; /sbin/modprobe --ignore-install lirc_sir

At this point it is best to reboot, to ensure that nsc-ircc was never loaded. Several things can go wrong if the steps are not followed accurately. You might get an error when loading lirc_sir that the device is busy, or your system may even hang.

Now do a # modprobe lirc_sir and check # dmesg output. You should see something like this:

lirc_dev: IR Remote Control driver registered, major 61
lirc_dev: lirc_register_plugin: sample_rate: 0
lirc_sir: I/O port 0x02f8, IRQ 3.
lirc_sir: Installed.

Now we are ready to start configuring LIRC.

TODO
cleanup LIRC config

Also, do not forget to start the lirc daemon, otherwise no output will be given (you better try running it not as a daemon first, so you can see the output).

 lircd -d /dev/lirc0 /etc/lircd.conf --nodaemon

You should see:

 lircd: lircd(serial) ready

This means you are good to start # irrecord or # xmode2 and check for input.

Once that shows a good output you can configure your remote control. then use it in applications like mplayer, xine, or KDE's remote controls server.

External Sources