Skip to content

92. The seven bytes below an infrared record's class byte are its carrier

The last unread field of a class 1 record, and the one a writer cannot do without. Section 42 read the widths out of the firmware and left the values unnamed: from the record's real start the loader reads a u8, then a u24, then a second u24, which is +0x00 to +0x06, the seven bytes that sit below the class byte at +0x07. Those two u24 values are the infrared carrier, a period and a fifty percent on time, in nanoseconds.

+0x00  u8   zero in all 3387 records here; what it selects is not established
+0x01  u24  carrier period, nanoseconds
+0x04  u24  carrier on time, nanoseconds, the period halved
+0x07  u8   class
+0x08  u24  the record's own start, which is where the loader reads from
+0x0B  u8   how many nine byte pointer groups follow

Why it is the carrier and not some other pair of durations

Four things, and no single one of them would be enough.

The halving. The second value is period >> 1 in every record of the corpus, exactly, to the bit. That is a square wave at fifty percent duty, which is what an infrared carrier is and what almost nothing else is.

The frequencies. Read as nanoseconds, 1e9 / period lands on the frequencies consumer infrared actually uses and on nothing else. Nine values across the corpus, the common ones being 38.0, 36.0, 37.9, 36.4, 36.2, 40.0 and 56.3 kHz. Under any other unit they are not carriers: as tenths of a microsecond, which is what section 42 assumed, every record here would read as 380 Hz.

The truncation, which is the closure. A stored period is floor(1e9 / f) for a frequency in whole hundreds of hertz. 40 kHz divides exactly and is stored as 25000. 38 kHz is 26315.79 and is stored as 26315. 36 kHz is 27777.78 and is stored as 27777, which is 36001 Hz read back, and that is the detail that makes the direction of the arithmetic checkable: the generator truncated rather than rounding, so a writer that rounds emits 27778 and differs from Logitech by one byte per device. The first version of the regression test asserted 27777 was 36 kHz to the hertz and failed, which is how the truncation was noticed at all.

The firmware's own arithmetic. The class 1 arm at 0x17F48 on the Harmony 700, reached from the record loader's dispatch at 0x17F32, clamps the first u24 at 256000 and, when the value no longer fits in sixteen bits, divides it by four and sets the Timer 2 prescaler to four to match. Both are period arithmetic. The clamp is a 3.9 kHz floor under the nanosecond reading and 39 Hz under the tenths of a microsecond one, and the prescaler arm engages below 15.3 kHz, which is exactly where a Timer 2 period register would need help. It then stores the two values as a u16 pair through FSR0, the second one two bytes above the first, which is a period and a duty side by side.

It agrees with a prediction made in section 12, which is the independent route

Section 12 derived the core clock from the software carrier modulator and tested it against a real carrier: 38 kHz is a 26.3 us period, so the config would store 263, and 263 * 4 / 10 is 105 cycles, which at 4 MIPS is 26.25 us. The config stores 26315, and 26315 divided by 100 is 263.15. So the number section 12 predicted from the transmit side is this field scaled from nanoseconds to tenths of a microsecond, and a closure derived years apart in this document from two different directions lands on the same value.

That does not settle where the division by 100 happens. The class 1 arm read here does not do it, and the class 2 arm immediately above it at 0x18002 loads a literal 100 within eight instructions of its own first read, so the scaling is somewhere in the path between this pair and the modulator's 0x08E. Not established, and not needed for a writer, which states the field in the unit the field is in.

Correction: the unit in section 42

Section 42 says the loader reads "a u24 duration in units of 0.1 microseconds". The width is right and the unit is wrong; it was inherited from section 12's prediction about the modulator's input rather than measured on the field, and no value had been read out of the corpus at the time. Corrected here rather than silently, per the house convention. Nothing else in section 42 depends on it: the clamp, the prescaler and the storage are all described correctly.

What it changes

The emitter frames the whole record header now, where it used to copy the eleven bytes in front of the group count. One byte of a record is still unread, the zero at +0x00, and it is carried rather than written as a zero, because asserting a value that is constant across the corpus would turn a container that disagreed into a wrong round trip instead of a loud one.

For a writer this is the field that says what a device's codes are modulated at, and it is per record rather than per config: a Harmony One config in the corpus carries 38 kHz for four of its five infrared groups and 56.3 kHz inside the fifth, alongside 38 kHz, so a group is not a single carrier either. Anything that learns a code has to state a carrier for it, and section 91 is where the measurement of one would come from.

A class 1 record can now be built from timings alone, which is the point of reading it

irBuildBlock and irBuildRecord in packages/codec/src/ir.ts take no container. They take a carrier and a list of marks and spaces in microseconds, which is exactly what a learn session produces and all it produces, and they return the bytes. Every class 1 record in the corpus, across arch 8, arch 12 and arch 14, comes back byte for byte when its own carrier and pulses are fed back through them.

That is worth stating plainly because of what it settles. Section 42 established that Logitech's server chose the encoding class, and section 91 that the classic service which did it is the discontinued one, which raised the question of whether learning a code is possible at all without it. It is: a class 1 record is a raw duration list plus a carrier, nothing in it is a choice the way a picture encoding is, and this codec can make one. What the server added was compression, matching against its database, and a name. Losing it costs the compression, not the capability.

Two things this does not do, and neither is a detail. It does not place a record: start and the block addresses are parameters, because a record's position is implied by everything around it, the same rule section 55 states for pictures. And it does not measure a carrier, which is section 91's open transport question. Building the bytes was the part that could be settled without hardware, and it is settled.


Section 91 | the archive | section 93. Section 92 of the findings archive, which is frozen; the reference holds the current answer. The archive on GitHub.