Full documentation at

http://people.ece.cornell.edu/land/courses/ece4760...

The receiver circuit is shown in the picture. The RC circuit acts a low-pass filter on the power to surpress spike noise and improve receiver performance. The RC circuit should be close to the receiver. The range with a 100 ohm resistor is at least 3 meters with the transmitter roughly pointing at the receiver, and a packet loss of less then 0.1 percent. To manage burst length limitations there is a short pause between characters, and only 7-bit characters are sent, with two stop bits. The 7-bit limit means that you can send all of the printing characters on the US keyboard, but no extended ASCII. All data is therefore sent as printable strings, NOT as raw hexidecimal.

Packet Format and error codes

A packet consists of :

  1. A start character, which defaults to '#', but can be changed with a define directive.
    No other character in the packet is allowed to match the start character.
  2. A one-character transmitter id number which the receiver will check against a number it expects, when using ir_rec_packet.
    The transmitter id should be in the ASCII character range '0' to 'z' (ASCII 0x30 to 0x7a, excluding the two start/stop characters).
    The ir_rec_packet routine will return error code 3 if the id does not match.
    The routine ir_rec_any_packet does not check the transmitter id, but returns the transmitter id (>=0x30) if the packet is valid and an error code if it is not valid.
  3. An arbitrary length, printable string (ASCII codes 0x20 to 0x7f, excluding the two start/stop characters), which of course, must fit into the size of the defined transmit/receive buffers.
  4. A one character checksum, which is calculated as the bitwise XOR of all the characters in the packet payload. The checksum is actually transmitted as two 4-bit values in the low 4 bits, ORed with 0x10 to form two 7-bit characters. This seemingly roundabout encoding was necessary to avoid burst length problems. A checksum mismatch will result in error code 4.
  5. An end character, which defaults to '%', but can be changed with a define directive.
    No other character in the packet is allowed to match the end character.
  6. The receiving functions do not block, but just grab what is asynchronously built in the receive buffer.
    An inconplete or missing packet at the time the receive function is called will result in error code 1.
  7. A buffer overrun will result in error code 2.

Loopback and point-to-point code is given on the page above.