Remote Control Configuration and usage in Linux

Source: Internet
Author: User

Have you ever imagined that you could sit on a couch or lie in bed and operate your computer like a TV with a remote control? You may have seen computer remote controls on the market, but they are all based on windows. In fact, through some configuration, even if a general remote control is used on the Linux platform, we can also control the computer.

The remote control configuration in Linux mainly involves the Linux infrared driver. Lirc (Linux infrared remoter control) is a program dedicated to controlling and processing infrared remote control signals in Linux. It contains infrared drivers for various interfaces, multiple applications, and lirc libraries. This article mainly discusses the application in the control of the PC by the Home Appliance Remote Control.

The source of infrared signals can be serial port, parallel port, IRDA, and Ethernet. The serial port infrared driver under lirc is called lirc_serial. By default, it detects the DCD signal line of the serial port, then measures various time parameters, and transmits them to the upper-layer applications. At the same time, lirc comes with many application tools. For example, xmode2 uses the X11 graphical interface to draw the Rectangular Pulse on DCD. irexec can correspond the remote control buttons to a command on the command line, irrecord obtains the new configuration file lircd. conf.

 

L install the lirc driver

$ Cd ~ /

$ Mkdir lirc

$ CD lirc

$ Sudo apt-Get source lirc # download lirc-0.7.1pre2

$ Lirc-0.7.1pre2 CD

$ Sudo./setup. Sh

Then, select the serial, IRQ, and Io addresses in the other serial port device based on the corresponding remote control. The default values are used here. This step is also important, otherwise it will not work properly. After the selection is complete, select Save and configure, and then run configure, and then execute:

$ Sudo make; make install

After installation, the kernel module is compiled and installed under/lib/modules/2.6.8.1-epia1/Misc. Modules vary depending on different hardware. Here are lirc_dev.ko and lirc_serial.ko.

 

L insert Module

$ Sudo apt-Get install setserial

$ Sudo setserial/dev/ttys1 UART none

$ Sudo modprobe lirc_serial IRQ = 3 IO = 0x2f8

 

L use the mode2 program for testing

$ Sudo mode2 # Console Command

(If USB mount is installed (udev is used), the location of the device node will change. Use mode2-D/dev/lirc0 for testing .) Press the remote control to check whether the screen is responding. For example:

Space 1471423
Pulse 3149
Space 2905
Pulse 687
Space 1334
Pulse 686

This indicates that the installation is correct.

 

L configure remote control

Because this is not a famous brand Remote Control (you can http://www.lirc.org/download someone else has prepared the configuration file), you need to use the irrecord command to generate.

$ Sudo irrecord new. conf # at this time, lircd cannot run

Follow the prompts to complete step by step. Note that the key time should not be too short or too long. According to the prompt, each key must be displayed 1 ~ 10 points. Even in this way, some keys may not be available for the last configuration. In this case, it is a good practice to look for a regular pattern to see under what circumstances the keys can be used, repeat the configuration multiple times and extract the keys that can be used each time to form a configuration file.

$ Sudo CP new. CONF/etc/lircd. conf # copy the generated file to/etc and rename it lircd. conf.

$ Sudo lircd # If the device node location changes, add the-D/dev/lirc0 parameter.

Run the irw command to check whether the configuration file is correct and whether the key is found.

$ Sudo irw

If you press the power key, the screen displays:

0000000000000001 00 power new. conf

If the information displayed by each key is the same as that in the configuration file, the configuration is successful.

 

Next, write lirc_serial IRQ = 3 IO = 0x2f8 to/etc/modules.

 

L configure the. lircrc File

. Lircrc is the application configuration file of lirc. The typical field configuration is as follows:

Begin

Prog = lirckeyd

Remote = new. conf

Button = power

Repeat = 0

Config = power

End

Where:

Begin ~ End indicates an independent configuration block.

The value of the prog field indicates the program name that uses the configuration block.

The value of remote indicates the name of the remote control used (see the definition in lircd. conf ).

The value of the button indicates the name of the remote control button (see the definition in lircd. conf ).

The repeat value indicates the number of repeat buttons.

The Config value indicates the string corresponding to the key, which can be obtained by the application defined by Prog.

Note that the value of remote must be the same as that of lircd. the name values in conf are consistent. For example, in the configuration generated by irrecord above, the name is new. conf, the remote value here must be new. conf.

 


L map remote control buttons to X events

Next, we need to match the buttons of the remote control with our desired operations. At this time, you need to compile a certain ing program based on the interface provided by the lirc library. The specific implementation process will be discussed in other articles


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.