特殊:Badtitle/NS100:InstallLirc/Feisty:修订间差异

来自Ubuntu中文
跳到导航跳到搜索
Wikibot留言 | 贡献
无编辑摘要
Wikibot留言 | 贡献
无编辑摘要
第2行: 第2行:
{{Languages|UbuntuHelp:InstallLirc/Feisty}}
{{Languages|UbuntuHelp:InstallLirc/Feisty}}
<<Include([[UbuntuHelp:Install_Lirc_Header|Install_Lirc_Header]])>>
<<Include([[UbuntuHelp:Install_Lirc_Header|Install_Lirc_Header]])>>
<<Include(Tag/Unsupported)>>
== Lirc Installation & Maintenance ==
== Lirc Installation & Maintenance ==
Lirc can be used for IR and RF sending and receiving for many IR and RF remote controls and senders (blasters).
Lirc can be used for IR and RF sending and receiving for many IR and RF remote controls and senders (blasters).

2008年12月16日 (二) 19:01的版本

{{#ifexist: :InstallLirc/Feisty/zh | | {{#ifexist: InstallLirc/Feisty/zh | | {{#ifeq: {{#titleparts:InstallLirc/Feisty|1|-1|}} | zh | | }} }} }} {{#ifeq: {{#titleparts:InstallLirc/Feisty|1|-1|}} | zh | | }}

<<Include(Install_Lirc_Header)>> <<Include(Tag/Unsupported)>>

Lirc Installation & Maintenance

Lirc can be used for IR and RF sending and receiving for many IR and RF remote controls and senders (blasters). As installed, the default Lirc init scripts are properly setup to handle a single device, but the driver build scripts can handle multiple devices. If you are looking to set up a transmitter and a receiver, multiple transmitters, or multiple receivers, set up a Single Device first and verify functionality. Afterwords, continue on to the setting up multiple devices section.

Setting up a Single Device

Throughout this howto, the lirc_mceusb driver will be used for examples. It's not necessary to build the lirc_mceusb driver if you are using a different receiver. It is just for examples sake. Also, note that some devices, such as the USB-UIRT, have full support built-in to the kernel and the lirc package and thus the lirc-modules-source package is not needed. See Lirc_USB-UIRT for more info.

Setup Repositories

In order to install lirc, you will need to have universe, and multiverse enabled. See Ubuntu documentation for more information on enabling|these repositories.

Install Lirc

You will only need to install lirc once, however, the kernel modules will need to be rebuilt after every kernel update.

$ sudo apt-get install lirc lirc-modules-source module-assistant
  • NOTE: Some i2c remotes are supported directly by the kernel. If you are using a remote that would have used the i2c driver, check out the Managed I2C devices link below to use this instead.

Configure lirc-modules-source

During the configuration of lirc-modules-source, you will choose the type of lirc device you are setting up.

$ sudo dpkg-reconfigure lirc-modules-source
Feisty?action=AttachFile&do=get&target=reconfigure1_1.png You will be provided a screen with a lot of information. Choose the okay button to move on.
Feisty?action=AttachFile&do=get&target=choose.png Choose your module(s) that you will need. Some modules will need additional information about the device, such as serial transmitters or serial port adapters.
PVR-150 on-card blaster/receiver: you will want to build the i2c and pvr150 modules
PVR-150 USB blaster/receiver: you will want to build either the mceusb or mceusb2 module
To use the serial infrared port that is present on many laptops, select sir. On the next page, you will then be asked what type of adapter you have; unless you have one of the specific types listed, you should select "other".
To use the home-brew serial receiver (Igor Cesko's variation) select serial. On the next page, you will then be asked what type of adapter you have; you should select "other".
Snapstream Firefly RF: you will want to build the atiusb module
Feisty?action=AttachFile&do=get&target=build.png You will be given an option to build the modules. Be sure not to build the modules here.
Feisty?action=AttachFile&do=get&target=maintainer.png You may be given an option to replace with a new version. Be sure to choose to Install the package maintainer's version.
Home-brew serial receiver

For the home-brew serial receiver (Igor Cesko's variation) modify file /etc/lirc/lirc-modules-source.conf

$ sudo nano /etc/lirc/lirc-modules-source.conf

and add -DLIRC_SERIAL_IGOR to line LIRC_SERIAL_CFLAGS, it should look like this after modification:

LIRC_SERIAL_CFLAGS=" -DLIRC_SERIAL_SOFTCARRIER -DLIRC_SERIAL_IGOR"

If you want to play with additional lirc serial settings, take a look in config.h from lirc-x.x.x.tar.bz package.

Modify /etc/lirc/hardware.conf

Modify /etc/lirc/hardware.conf.

$ sudo nano /etc/lirc/hardware.conf
Feisty?action=AttachFile&do=get&target=hardware.png Modify LOAD_MODULES=false to be LOAD_MODULES=true. Also, add your module to the line that is MODULES="". Your module is the name of the module you chose previously to build prefixed by lirc_:
mceusb:>>MODULES="lirc_mceusb"
PVR-150/350 on-card blaster/receiver:>>LIRCD_ARGS="--device=/dev/lirc0">MODULES="lirc_pvr150"
Snapstream Firefly RF:>>MODULES="lirc_atiusb"
home-brew serial receiver :>>MODULES="lirc_dev lirc_serial"

Build Lirc Modules

The lirc modules will need to be rebuilt every time that you update your kernel. Just follow these build steps every time you boot into a newer kernel for the first time.

  • This step will grab the necessary headers to build the kernel modules:
$ sudo m-a update,prepare
  • This will clean out any old lirc module builds:
$ sudo rm /usr/src/lirc*deb
$ sudo m-a clean lirc
  • This will build the kernel/install modules:
$ sudo m-a a-i -f lirc
  • Update the modules list
$ sudo depmod -a

Create a lircd.conf

You have two options for how to create a lircd.conf. You may be able to find one already made for your device, or you may generate one yourself.

Using a premade lircd.conf
$ wget "<download link>" -O lircd.conf

Replace /etc/lirc/lircd.conf with this lircd.conf that you have found:

$ sudo cp <name of downloaded.conf> /etc/lirc
  • NOTE: Please make sure the file is saved as a unix file and NOT a mac or dos text file format. This will stop it from being read.

If you have found a remote, skip the next section. Otherwise, continue, and you will record a remote using irrecord.

Recording a Remote

Insert the module that you have just built and intend to record from. Example:

$ sudo modprobe lirc_mceusb

If you are using a serial infrared port (the lirc_sir module) you must disable the use of the infrared unit as a serial port before you insert the module. To do this, issue a command like the below to disable the serial port first. Please note that you will not be able to use LIRC and infrared serial communication at the same time.

$ sudo apt-get install setserial
$ sudo setserial /dev/ttyS0 uart none
$ sudo setserial /dev/ttyS1 uart none

If you don't disable the serial port use of the infrared unit, you will receive a message like the below:

FATAL: Error inserting lirc_sir (/lib/modules/2.6.20-x-y/misc/lirc_sir.ko): Device or resource busy

Once you have LIRC, up and running, see the section "Serial Receiver / Transmitter" below for how to permanently disable the infrared serial port in favour of LIRC. If inserting the module still fails (this applies to all modules), it might be because the m-a ignored the special i2c module. Force it to load, then try the modprobe command again:

$ sudo dpkg -i /usr/src/lirc-modules-2.6.*.deb
  • Record the remote using irrecord
$ sudo irrecord -d /dev/lirc0 lircd.conf
  • Once you have completed your configuration, move this lircd.conf to /etc/lirc/lircd.conf
$ sudo mv lircd.conf /etc/lirc

Start Lirc & Test

The modules will load when you start lirc, if they aren't already loaded.

$ sudo /etc/init.d/lirc start
$ irw

The terminal should 'appear' to hang, (not return a command prompt). Press buttons on your remote, you should see key presses then come up on the terminal. When your done, testing press <crtl> + 'c' to quit. If irw returns immediately, and gives you another command prompt some of your modules aren't loading correctly. Try rebooting your computer. If this doesn't work check dmesg for clues as to which module isn't loading.

 $ dmesg | grep -i lirc

if you get:

sweet_user_name@ubuntu:~$ sudo /etc/init.d/lirc start
Password:

You haven't created replaced the default lircd.conf read the above section on creating|lircd.conf

Create a .lircrc file

Automated Method

The web tool LIRC Config creates customized .lircrc files for MythTV, Xine, and Mplayer from a web browser.

  • NOTE: Please make sure the file is saved as a unix file and NOT a mac or dos text file format. This will stop it from being read.
Standard Method

If you are intending on using lirc for only IR transmitting, you don't need to create a ~/.lircrc file. If you are going to use it for IR receiving, you will need to create a ~/.lircrc file describing what each of the buttons does for each application you will use lirc in. The basic syntax is as follows:

begin
    prog = PROGRAM
    button = REMOTE_BUTTON
    config = ACTION
end

Where: PROGRAM is the program you are recording buttons for. Some examples for PROGRAM are mythtv, mplayer, xine, vlc, and irexec. REMOTE_BUTTON is the name of the button in accordance with what is listed in your /etc/lirc/lircd.conf. ACTION is the action that will be performed when this button is pressed. You can find a list of actions in the attached .lircrc example file.

For a mceusb2 remote, you might need to change the button names from "chan-", "chan+", "vol-", "vol+" to "chandown", "chanup", "voldown", "volup".

Alternate configuration method - IRKick

If you're a KDE user, you may find it more convenient to set up functionality using irkick. This requires you already have your lircd.conf and hardware.conf set up, but you won't need an lircrc file if you take this approach. First, you'll need to install a couple packages:

$ sudo apt-get install lirc-x kdelirc

Next, start up IRKick - It's in the Utilities menu. IRKick contains extensions to easily setup the remotes functions with Amarok, Kaffeine, Noatun, and Konqueror, but can be made to perform any terminal command or dcop call. To add functionality for a button - just click add (on the right-hand side). To add a new mode for the remote, click on the left add and give it an appropriate name. Note: when adding a new mode, you'll also need to assign a button to switch to that mode. This allows you to have buttons do different things in different modes. Select the mode on the left before adding new functions for buttons. Click apply when you're done making changes, and that's it, no configuration files to play with :)

Specific Application lircrc Notes

Multiple applications can be listed in the .lircrc file, but you will need a seperate begin and end block for each button in each application.

If you are using this for mythtv, you will either need to create a standalone lircrc for mythtv in ~/.mythtv/lircrc or create a symbolic link to this file and place all the lircrc related content in /.lircrc.

  • Creating a symbolic link. [ All mythtv buttons will need to be placed in ~/.lircrc with the rest of the applications you use lirc for ]
$ ln -s ~/.lircrc ~/.mythtv/lircrc

irexec is able to interpret keypresses and launch applications when the keys are pressed. The syntax is:

begin
    prog = irexec
    button = REMOTE_BUTTON
    config = APPLICATION
end

APPLICATION is simply the path and name of a file marked executable.

  • NOTE: IRexec is installed with lirc, it is not started by default however. You can have it start by adding it to your login "session".

Setting up two or more devices

After you have proven LIRC works with a single device, you can modify your scripts to include support for multiple devices. The first thing you will have to make sure you have kernel modules for the additional devices. If during the single device setup, you built modules for all the devices you thought you would need, you can skip the next step.

Build Additional Modules

  • Clear our any old module builds
$ sudo rm /usr/src/lirc*deb
$ sudo m-a clean lirc
  • Stop lirc & unload any loaded modules.
$ sudo /etc/init.d/lirc stop
$ sudo rmmod LOADED_LIRC_MODULES
  • Replace LOADED_LIRC_MODULES with any lirc modules you have loaded.
  • Reconfigure lirc-modules-source. Choose all modules you will need (including those previously chosen)
$ sudo dpkg-reconfigure lirc-modules-source
  • Build/install the kernel modules
$ sudo m-a a-i lirc
  • If you get a message that it won't reinstall an already installed version, you can force installation.
$ sudo dpkg -i /usr/src/lirc*deb

Modify Init Scripts

  • Modify /etc/lirc/hardware.conf
  • Make sure that all of your modules are now added to the list of MODULES="". Take note of the order you provide these modules. This will be the order that lirc recognizes the devices, and important if you are going to need to differentiate between different lirc devices.
  • Modify LIRCD_ARGS="" to match
LIRCD_ARGS="-d /dev/lirc0 --output=/dev/lircd --listen"
LIRCD2_ARGS="-d /dev/lirc1 --output=/dev/lircd1 --connect=localhost:8765 --pidfile=/var/run/lircd2.pid"
  • Modify /etc/init.d/lirc
  • Change this block:
      LIRCD_ARGS=`build_args $LIRCD_ARGS`
      start-stop-daemon --start --quiet --exec /usr/sbin/lircd -- $LIRCD_ARGS \
                < /dev/null

To be:

      LIRCD_ARGS=`build_args $LIRCD_ARGS`
      LIRCD2_ARGS=`build_args $LIRCD2_ARGS`
      start-stop-daemon --start --quiet --exec /usr/sbin/lircd -- $LIRCD_ARGS \
                < /dev/null
      /usr/sbin/lircd $LIRCD2_ARGS \
               < /dev/null
  • If you have more then 2 LIRC devices, you will need to add additional blocks to /etc/lirc/hardware.conf and /etc/init.d/lirc to connect to the main lirc process.

Testing Lirc

  • Start lirc
$ sudo /etc/init.d/lirc start
  • You should have two lircd processes running. You will need to provide a parameter to any lirc process trying to interact with lircd now to indicate which lircd you want to interact with.

Additional Information

Supported Transmitting Devices

The following drivers have support for IR transmission:

  • lirc_pvr150
  • lirc_serial
  • lirc_mceusb2
  • lirc_cmdir

CommandIR IR Receiver and Quadruple-Transmitter

One site has automated the above procedure for their CommandIR Mini transceiver, which has a remote receiver and 4 IR blasters. The device's emitters allow control of multiple devices and do not require different codesets since each emitter can be individually selected for transmitting using irsend set_transmitters. It is possible to use their script to setup LIRC on Ubuntu for CommandIR then make minor modifications for other hardware.

PVR-150 IR Transmitter

firmware and codesets

You need to download the Hauppauge firmware and add the appropriate codeset to your lircd.conf for the device you want to control. The firmware can be found here. Download it and put it in ~+`/lib/firmware`+~ The codesets can be found here. This file contains the codesets for every device in the database. You will need to extract the information for the device you want to control, and append it to your /etc/lirc/lircd.conf -- but for now, just save it someplace safe. When you have downloaded and moved the firmware and have the codeset file, Reboot before continuing.

Adding the blaster codeset

You will need to determine the codeset of your device. To help you determine the possible codeset, consult the list here: here. Note that finding the correct codeset for your device can be tricky- but the master list can usually help you track them down by process of elimination. Once you have determined a codeset, you need to extract those codes from the master file you downloaded and add them to your /etc/lirc/lircd.conf as another remote. For example, to blast a Power Button a Motorola DCT6200 series cable box, you would use the POWER button raw code from codeset 85. If you are linking it to a key on your remote, you want to change the button name to the name reported by irw.

$ sudo nano /etc/lirc/lircd.conf

First, add the blaster header:

begin remote

  name          blaster
  bits          32
  flags         RAW_CODES
  eps           0
  aeps          0
  plead         0
  gap           333333
  repeat_bit    0
  begin raw_codes

Next, find the power button in codeset 85- since this is a cable box, it is prefixed in the master file as 0_85:

    name 0_85_KEY_POWER
    5570570

then make it conform to how irw reports the keypress- in this case, irw reports it as POWER, so that is what to name it:

   name POWER
   5570570

Keep adding your buttons (only the ones you want to control with the blaster). When you are finished, add:

end raw_codes
end remote

to close out that remote definition. In this example, the entire remote definition for the power button only looks like:

begin remote

  name          blaster
  bits          32
  flags         RAW_CODES
  eps           0
  aeps          0
  plead         0
  gap           333333
  repeat_bit    0
  begin raw_codes
  name 0_85_KEY_POWER
  5570570
 end raw_codes
end remote

After saving the new lircd.conf, restart lirc:

$ sudo /etc/init.d/lirc restart

and test it. In the example the command:

$ irsend SEND_ONCE blaster POWEROFF

turns the DCT6200 cable box on and off. Even if it does not control the device as intended, you should see the blaster flashing. Troubleshooting codeset selection, blaster placement, etc. is beyond the scope of this guide. A wealth of information is readily available via Google

MCEUSB2 IR Transmitter

Feisty packages include support for the mceusb2 IR transmitter. Usage is the same as standard serial transmitters. For information on setting up this blaster with a Motorola DCT700 cable box: See Motorola_DCT700_Channel_Change_Script

Serial Receiver / Transmitter

If you are running the lirc_serial driver either for a transmitter or receiver, you will need to disable kernel serial support. There are two ways this can be achieved: Both ways depend on setserial, so install that first

$ sudo apt-get install setserial

First Method

  • Credit to TechnoPenguin & TrubbleMaker from the forums, usring modprobe.conf

This can be achieved by editting /etc/modprobe.conf and adding the following:

alias char-major-61 lirc_serial
options lirc_serial irq=4 io=0x3f8
install lirc_serial /bin/setserial /dev/ttyS0 uart none ;\
    /sbin/modprobe --ignore-install lirc_serial

This is for a typical machine using the primary serial port (/dev/ttyS0) and the standard IRQ and IO ports. If you are running on the secondary serial port, replace the device to be /dev/ttyS1 and the appropriate IRQ & IO ports.

Second Method

  • Using the setserial debian configuration
$ sudo dpkg-reconfigure setserial
  • Choose manual
  • Modify /var/lib/setserial/autoserial.conf
  • Add (or modify if its there already) (switch to ttyS1 if your using that instead)
/dev/ttyS0 uart none
  • Copy that script to /etc/serial.conf
$ sudo cp /var/lib/setserial/autoserial.conf /etc/serial.conf

Managed I2C Devices

Ubuntu Edgy introduces support in the kernel to directly manage some remotes via the i2c bus. For remotes like this, the kernel is deprecating the use (and requirement) of lirc. You should be able to press keys on the remote and have them recognized as ordinary keyboard keys. If you don't like the way that the keypresses that are recognized for certain buttons on the remote, their behavior can be changed using Xmodmap. Alternatively, if you would like to still use lirc to manage your i2c device, hexion has written a howto explaining how to install lirc from source and replace the ir_common module in the kernel causing this behavior. See his howto here: HOWTO: Lirc in Edgy.

Rebuild Modules

If you ever need to rebuild your lirc modules for a new kernel version, here are the correct steps to follow:

$ sudo dpkg -r lirc-modules-`uname -r` 
$ sudo rm /usr/src/lirc*deb
$ sudo m-a clean lirc
$ sudo m-a update,prepare
$ sudo m-a a-i lirc
$ sudo depmod -a

You probably want to restart the lirc service afterwards:

$ sudo /etc/init.d/lirc restart