/ raspberrypi

Solving timeouts with IguanaIR transceiver and raspberry pi

Sometimes you encounter problems for which a variety of solutions might exist. Some of these solutions are clean, and some of these solutions feel like a very duct-tape solution. However, if such a duct-tape solutions works, why change it?? :) In this post I will share one of such duct-tape solutions for a problem I ran into.

So one of my pet projects is to see if I can make good use of the raspberry pi zero w that I have laying around. I finally decided to use it to control the different media devices in the living room (receiver, xbmc, tv, and cable box). In order to do so, I also bought an Iguanaworks USB IR transceiver:
Iguanaworks USB IR transceiver

The nice thing is that you can attach up to 4 IR emitters to the device, where you control which emitter you want to use for sending commands. Furthermore, it also contains an IR receiver that you can use to record the IR codes from your existing remote controls.

To get the transceiver to work with LIRC does require some steps. I basically followed the steps from this Instructables page. In short, it boils down to adding the iguanaworks apt repository and installing the iguanair package. After that, remove all LIRC packages, and build the package from source. By building from source, it will now see the iguanaworks driver and will include it. Finally, install the created deb files and you're good to go!

The most basic command you can try out is using the statement igclient --get-version to query the version of the device. However, when executing this command I would often see the following timeout message:

pi@raspberrypi:/ $ igclient --get-version
get version: failed: 110: Connection timed out

Typically, I would get this timeout for the first couple of tries when executing the command and after that it would work without a problem. So this timeout not only happens when you try to query the version but also would happen if you would use a command like:

pi@raspberrypi:/ $ irsend send_once Ziggo POWER_OFF

I did quite some research on it and it might be caused by timeouts happening in the dwc_otg USB drivers on the raspberry pi. You can try all kinds of different settings by providing kernel parameters in the /boot/cmdline.txt (e.g. add dwc_otg.speed=1), but none of these options so far has worked for me.

I noticed that whenever the device is being queried regularly, the timeouts do not seem to happen at all. So instead of trying all kinds of different kernel parameters my current solution is much simpler, namely, start a screen or nohup session with the following statement:

pi@raspberrypi:~ $ while true ; do igclient --get-version ; sleep 1; done 

This will indefinitely query the device version every second. Since I have been running this command in the background, I have not seen any timeout at all.

As to why this extremely duct-tape like solution is working, my guess is that after some time of inactivity some of the internals in the DWC_OTG driver and/or connection are reset resulting in the timeouts. After a couple of tries, the connection is up again and the timeouts are gone. So if you just ensure that the connection never resets, the timeouts disappear :)

So one problem solved but I still don't have the whole thing working: I cannot seem to get the transceiver working with my Ziggo Cisco HDTV cable box, it might have something to do with it using different carrier frequencies or so. If you do know any solution for this, will be happy to hear!! Once that final problem is solved, I will be able to control the complete media center from my raspberry pi (and of course connect it to Alexa :) )

Guido Diepen

Guido Diepen

Senior Data Scientist at T-Mobile NL | Fascinated with new technologies and tools | Trying to automate the boring bits of life | Love to travel

Read More