The AIR binary mode turns the Bus Pirate and the IR Toy plank into an infrared capture and transmit device for AnalysIR. It speaks the serial protocol of the A.IR Shield Nano, AnalysIR’s own hardware, so in AnalysIR choose Source, A.IR Shield Nano.

This page documents the protocol for anyone writing their own software. To capture signals with AnalysIR, follow the AnalysIR guide.

Capabilities

  • Receive: marks and spaces in µs, up to 65,535µs each
  • The carrier frequency of each signal, measured with the learner receiver
  • Transmit: signals sent as aIR text, each with its own carrier frequency

Enable AIR mode

Bus Pirate [/dev/ttyS0]
HiZ> binmode

 1. SUMP logic analyzer
 2. BPIO2 flatbuffer interface
 3. Arduino CH32V003 SWIO
 4. Follow along logic analyzer
 5. Legacy Binary Mode for Flashrom and AVRdude
 6. IRMAN IR decoder (LIRC, etc)
 7. AIR capture (AnalysIR, etc)
Select binary mode
x to exit (1) > 7


Binmode selected: AIR capture (AnalysIR, etc)

Binmode active. Terminal locked

Use the binmode command and choose 7. AIR capture (AnalysIR, etc). The Bus Pirate:

  • switches to HiZ mode
  • turns on the 5 volt power supply
  • sets up the pins below
  • locks the terminal

To leave AIR mode, unplug the Bus Pirate and plug it back in.

PinLabelDirectionUse
IO0OutputUsed internally. Leave it unconnected
IO1LERNInput20-60kHz learner, measures the carrier frequency
IO4IRTXOutputIR LEDs, carrier modulated
IO538kInput36-40kHz demodulator, low while IR is received

AIR mode listens with the 36-40kHz demodulator. For the 56kHz demodulator or the barrier receiver, use INFRARED mode.

The protocol runs on the Bus Pirate’s binmode serial port. The baud rate setting is ignored.

Connect

When software opens the binmode port, the Bus Pirate sends an ID string:

\n!BP V310!\n
0a 21 42 50 20 56 33 31 30 21 0a

BP identifies the Bus Pirate, and AnalysIR only reads the characters between the first ! and the space. The digits after the V are version numbers.

Receive

Each signal reaches the host as a list of 5 byte records: one for every mark and every space, in order, then a modulation record with the carrier period if the learner measured one. The Bus Pirate sends the signal once the remote has been quiet for 65,535µs.

Pulse record

ByteContent
0+ (0x2B) for a mark, - (0x2D) for a space
1Record counter. Starts at 0 for every signal and wraps after 255
2Duration in µs, low byte
3Duration in µs, high byte
4\n (0x0A)

Marks and spaces alternate, starting with a mark. A signal ends with a space of 65,535µs (0xFFFF): no IR for 65.5ms, the signal is over.

Modulation record

ByteContent
0M (0x4D)
1Number of periods measured
2Carrier period in ns, low byte
3Carrier period in ns, high byte
4\n (0x0A)

Carrier frequency in Hz = 1,000,000,000 / period. For example, 28,000ns is 35,714Hz.

Example

The 9 key of an RC6 remote, 40 pulse records and the modulation record:

2b 00 62 0a 0a    +  #0     2658µs  mark
2d 01 86 03 0a    -  #1      902µs  space
2b 02 bb 01 0a    +  #2      443µs  mark
2d 03 66 03 0a    -  #3      870µs  space
...
2b 26 7c 03 0a    +  #38     892µs  mark
2d 27 ff ff 0a    -  #39   65535µs  space, end of the signal
4d 01 60 6d 0a    M        28000ns  carrier period, 35,714Hz

Transmit

To transmit, send the signal as aIR text. The Bus Pirate sends it out through the IR LEDs on IO4.

$38:900,1800,900,65535,;
PartMeaning
$Start of the signal
38Carrier frequency in whole kHz
:The timings start here
900,1800,900,65535,Mark, space, mark, space… in µs, from 1 to 65535, starting with a mark. Every value ends with a comma, the last one too
;End of the signal. The Bus Pirate transmits it now
  • The final space can be left out.
  • No spaces or line breaks between the $ and the ;.
  • The receiver is paused while the Bus Pirate transmits, so it doesn’t capture its own signal.
  • There is no reply.

INFRARED mode uses the same aIR text: the RAW protocol prints received signals in this format and the irtx command transmits it. AnalysIR can import it too, see capture in the terminal.