Caution Most PCs attach USB ports directly to the motherboard and if you make a mistake when building your own device you could destroy it Purchasing a separate PCI board with USB sockets should provide some protection from mishaps

For IR transmission, you need to know the specific control codes of the device you want to control. If you have a standard TV or video, this data is usually available online

(http://lirc.sourceforge.net/remotes/); otherwise, you will also need to purchase or build an IR receiver to teach LIRC the existing codes. Fortunately, if you took the earlier hint and bought a RedRat, you will have a receiver built in that, along with the supplied Windows software or LIRC, can be used to program the codes directly.

LIRC16 is the Linux-standard method for reading and transmitting IR data. It comprises a standard daemon, lircd, and a set of tools to record the input messages and transmit them back again. It adopts a

modular approach to support the wide variety of LIRC devices available. Reproducing an installation guide here would be foolhardy, but suffice to say there are three main types of supported control:

GPIO devices: These are generally supplied with TV cards, such as those from Hauppauge. The modules are usually compiled into the standard daemon build.

Serial port device: This covers a wide range of different devices, including home-brew transmitters, and because they process serial data directly, they don't need any specific driver code. Typical circuits are available from the LIRC web site. If you're unsure about connecting your own electronics onto your PC motherboard, you can buy serial PCI cards, which offer a level of protection against rogue electronics.

Kernel drivers: These, such as the RedRat3 device, require you to build LIRC from source and (in some cases) copy the new driver code into the LIRC directory. From here you can rebuild the setup (data2setup. sh) file and build as normal. These devices will make use of the /dev/lircd device, which should have ugo+rw privileges.

Once built, the drivers can be configured and prepared according to the table at LIRC,17 which also provides sample configuration files for the various devices that describe each button with a human-friendly name and the details of the IR signal to be sent. From here, you can add specific commands to be triggered upon the various button presses within the .lircrc file, which has a format typical of this:

begin prog = mythtv button = Rew config = Left end

Each button on the remote is mapped to a function of the software (prog) in this fashion.

One of the big benefits in using RedRat, and LIRC in general, is its inclusion in many standard media players, mixers, and TV applications. Consequently, if this is your primary purpose of IR, then you have completed your media installation already since those commands can trigger something useful in the existing software!

LIRC also has a network mode whereby you can communicate with an LIRC daemon through a network socket, allowing an external application to act as if it were a local IR remote control. This is useful for testing and as a method of remotely a PC-based media player without writing new code.

For more specific applications, you will need to make use of irexec, as shown here:

begin prog = irexec button = ok config = /usr/bin/someprogram with arguments here end

17 www.lirc.org/html/table .html

In this way, you can use an IR remote to interact with other arbitrary applications, including media players on other machines. Additionally, you can adopt the same ideas as Cosmic (mentioned earlier and covered in Chapter 7) to develop a state-based control mechanism using very cheap IR transmitters.

The Ultimate Computer Repair Guide

The Ultimate Computer Repair Guide

Read how to maintain and repair any desktop and laptop computer. This Ebook has articles with photos and videos that show detailed step by step pc repair and maintenance procedures. There are many links to online videos that explain how you can build, maintain, speed up, clean, and repair your computer yourself. Put the money that you were going to pay the PC Tech in your own pocket.

Get My Free Ebook


Post a comment