While I was waiting for my HDMI to RS232 converter to do it’s thing, I did some more googling and discovered this forum post (big thanks qwerty_UK for posting!) of Yamaha/NEC IR codes for my Yamaha RX-V767 AV receiver. The scans listed several of the codes I was after, but I had no way to covert them to LIRC format. Since I already knew some of the AV receiver IR codes in LIRC format from irrecord, I thought I’d have a look at converting between the two.

The Yamaha/NEC (YN) codes come in 4 types:

  • xx-xx (eg 7E-2A)
  • xx-xxxx (eg 7A-532C)
  • xxxx-xx (eg 7F01-5A)
  • xxxx-xxxx (eg 7F01-5E21)

LIRC required a 32bit number for the Yamaha IR codes. When you match them up, it doesn’t make a lot of sense:

  • KEY_POWER: 0x7E8154AB  ->  7E-2A
  • KEY_AV1: 0x5EA1CA34  ->  7A-532C
  • KEY_1: 0xFE808A75  ->  7F01-5A
  • KEY_PRESET-: 0xFE807A84  ->  7F01-5E21

In binary however, patterns start to emerge (the xxxx’s are explained later, and the colon is just to split the 32bit number for ease of reading):

  • KEY_POWER: 0111 1110 xxxx xxxx : 0101 0100 xxxx xxxx    ->   0111 1110 – 0010 1010
  • KEY_AV1: 0101 1110 xxxx xxxx : 1100 1010 0011 0100  ->  0111 1010 – 0101 0011 0010 1100
  • KEY_1: 1111 1110 1000 0000 : 1000 1010 xxxx xxxx  -> 0111 1111 0000 0001 – 0101 1010
  • KEY_PRESET-: 1111 1110 1000 0000 : 0111 1010 1000 0100  ->  0111 1111 0000 0001 – 0101 1110 0010 0001

So from this, some rules can be deduced.

For the YN 16bit codes (xx-xx):

  • LIRC Byte 1 is YN Byte 1 with nibbles swapped, and nibble bit orders reversed
  • LIRC Byte 2 is 0xFF – LIRC Byte 1
  • LIRC Byte 3 is YN Byte 2 with nibbles swapped, and nibble bit orders reversed
  • LIRC Byte 4 is 0xFF – LIRC Byte 3

For the 2-4 YN 24bit codes (xx-xxxx):

  • LIRC Byte 1 is YN Byte 1 with nibbles swapped, and nibble bit orders reversed
  • LIRC Byte 2 is 0xFF – LIRC Byte 1
  • LIRC Byte 3 is YN Byte 2 with nibbles swapped, and nibble bit orders reversed
  • LIRC Byte 4 is YN Byte 3 with nibbles swapped, and nibble bit orders reversed

For the 4-2 YN 24bit codes (xxxx-xx):

  • LIRC Byte 1 is YN Byte 1 with nibbles swapped, and nibble bit orders reversed
  • LIRC Byte 2 is YN Byte 2 with nibbles swapped, and nibble bit orders reversed
  • LIRC Byte 3 is YN Byte 3 with nibbles swapped, and nibble bit orders reversed
  • LIRC Byte 4 is 0xFF – LIRC Byte 3

For the YN 32bit codes (xxxx-xxxx):

  • LIRC Byte 1 is YN Byte 1 with nibbles swapped, and nibble bit orders reversed
  • LIRC Byte 2 is YN Byte 2 with nibbles swapped, and nibble bit orders reversed
  • LIRC Byte 3 is YN Byte 3 with nibbles swapped, and nibble bit orders reversed
  • LIRC Byte 3 is YN Byte 4 with nibbles swapped, and nibble bit orders reversed

Unfortunately the post is a jpeg scan of a service manual, so I had to enter the codes manually. After a lot of typing, here is the resulting CSV file. To the end of the file I added some extra codes I’d found from my testing.

With the translation figured out, and the codes entered, it was a simple matter to dodgy up some python to generate LIRC codes from the Yamaha/NEC codes.

The program generates a separate LIRC “remote” for each of the zones supported by the chosen receiver, plus an ALL “remote” for codes that don’t apply to specific zone.

Invoking the script is done as follows:

python yamahanec2lirc.py <infile> <device> <product> <id_code> > <output_file>

where:

  • infile is the CSV file containing the Yamaha/NEC codes
  • device is used to filter the codes for a specific system. Most codes apply to RECEIVER
  • product is the receiver to filter the codes for. Valid options are 667, 767, 867, 1067, 2067, 3067
  • id_code is the code set to generate (either 1 or 2). The default is 1. The receiver can be configured to accept either the ID1 or ID2 code set, which would allow 2 receivers to work alongside each other without interference.

The generated remote definitions are printed to stdout, and it’s a simple matter to pipe them into a file. For example:

python yamahanec2lirc.py yamaha_rxv.csv RECEIVER 767 1 > yamaha_rxv767.lircd

The resulting output file can be seen here. This is then included into the lircd configuration file (usually /etc/lirc/lircd.conf):

include "/home/nobbin/yamaha_rxv767.lircd"

After restarting lircd, you can use irsend to send these codes to your receiver:

irsend SEND_ONCE RECEIVER_767_MAIN POWER_POWER_ON

Enjoy…

Notes:

The codes have been tested for the RX-V767. The other supported receivers are the RX-V667, RX-V867, RX-V1067, RX-V2067, RX-V3067. However as I don’t have access to any of these, I haven’t tested them.

The ID2 codes haven’t been tested either.

The last column (Export Comment) in the CSV file allows comments to be added to the generated LIRC config file, any text here will appear as a LIRC comment on the line preceding the remote code. If the “export comment” column entry is prefixed with “#”, then the actual remote code will be commented out in the LIRC config file. This allows potentially dangerous codes, like the “self test mode” code, to be commented out, so they can’t be sent accidentally.

The python script contains functions to convert from lirc format into Yamaha/NEC format. Checkout the source if that interests you.

Advertisements