IguanaIR send and receive
Today I've been playing with the IguanaWorks USB IR transceiver I wrote about previously. I managed to record a few codes transmitted by remote controls that were lying around the room and also control devices by re-transmitting the codes. As details of this operation were not completely obvious to me from the documentation available, here's a short tutorial.
For basic receive and transmit you need just the iguanaIR package (igdaemon and igclient). There is no need for lirc.
For reception, use the following command:
$ igclient --receiver-on --sleep 10 received 1 signal(s): space: 57344 received 6 signal(s): space: 2901 pulse: 2389 space: 576 pulse: 1194 space: 554 pulse: 597
This gives you 10 seconds to point any device that is transmitting IR codes to the Iguana receiver. The receiver demodulates the amplitude modulation and prints out lengths of interchanging silence and carrier signal intervals (in microseconds) to standard output. received ... signal(s) lines can be ignored as they appear to only tell you how the data was divided into chunks when it was sent from the daemon to the client.
As far as I know, there is now way to determine the carrier frequency.
Signals recorded this way can be translated into a raw, unsigned, 8-bit data stream with 1 MHz sample rate using the following Python script.
import sys
for line in sys.stdin:
f = line.strip().split()
if len(f) != 2:
continue
s = f[0]
l = int(f[1])
if s.startswith('pulse'):
sys.stdout.write('\xff' * l)
elif s.startswith('space'):
sys.stdout.write('\x00' * l)
This can be handy for viewing or editing signals, for instance in Audacity.
To transmit a signal, use the following:
$ igclient --send path-to-file send: success
path-to-file should in this case point to a file that has a similar, but not quite the same format as the receiver output above:
pulse 2389 space 576 pulse 1194 space 554 pulse 597
Apart from missing colons this format is also a bit stricter regarding the sequence of pulse/space lines. The file should always start with a pulse (not space) and the client won't allow for multiple consecutive pulse or space lines (i.e. you should consolidate them into a single line). It also appears that if the sequence described by the file is too long, you will get a timeout error from the client, even though the sequence will actually be transmitted by the USB dongle.
You can set the carrier frequency using igclient --set-carrier.
To get this format from a raw file that was produced by the Python script above, use this snippet:
import sys import itertools data = sys.stdin.read() data = map(lambda x: x > '\x7f', data) for k, g in itertools.groupby(data): l = sum(1 for x in g) if k: print "pulse", l else: print "space", l










