10 Jun 2014. By William Manley.

TL;DR version:
stb-tester reqires a LIRC config file to know how to translate key names into IR pulses. irrecord can be used to create them by recording IR signals but can have difficulty sometimes. In those cases you can provide additional information to make recording succeed which can be determined from the output of mode2 and xmode2 and by consulting the lirc config file documentation.

This is part 1 of a 2 part blog post. It focuses on how stb-tester uses LIRC to produce IR signals and how recording works in theory. Part 2 will apply this understanding to successfully record remote control codes where irrecord fails by default.

Overview of stb-tester and IR

stb-tester uses LIRC (Linux Infrared Remote Control) to send IR signals to control the set-top-boxes and smart-tvs under test. The test scripts refer to key names like “KEY_0” and “MENU”, but the IR blaster has to send out the pulses of IR light that the set-top-box/TV will understand.

LIRC does this conversion from key names to pulses based on a configuration file you provide it that describes the IR protocol to be used and what the valid key values are. You can use the lirc command irrecord to create a configuration file by pressing buttons on the remote.

Unfortunately this doesn’t always work perfectly. To see why let’s look a little more in detail at how lirc calculates what pulses to send:

The codes section of the config file describes how to map a key name (such as “KEY_1” or “KEY_MENU” to a number. This number will be encoded into a series of pulses and spaces. In the case in the diagram above 1s are encoded as long pulses and 0s as short pulses.

Recording IR codes

irrecord works in reverse: it will record the signals from your remote control and create a config file for lircd:

  1. It first tries to derive the encoding parameters and the codes by getting the user to press lots of different buttons and analysing the pulse/space timings.
  2. It then works out the code mapping by getting the user to enter the name of a button and then pressing the button on the remote.

Creating the code mapping is very easy to do once you know the encoding, but automatically working out the encoding parameters is more difficult and so can be unreliable. When this happens irrecord may fail to produce a config file or the config file it does produce may be ineffective.

irrecord will often succeed where it had failed before if you give it a helping-hand by deriving the encoder parameters for it. In the next blog post I describe how I determined the encoding parameters for a SONY Bravia smart TV remote control, and thus was able to create a full lirc config for this remote control.