Last year I had the chance to play with an old MacBook ( Late 2006 model ), running Mac OS X Mountain Lion and OS X Mavericks as a second OS installed on the hard drive. Originally I purchased the MacBook online from a second-hand store, and I intended to use it for the development of a iOS proprietary Application for one of our clients. Now that the project is finished I decided to use the MacBook to play with LIRC and the USB Infrared transceiver, allowing the machine to transmit and receive Infrared signals. In the past we have received questions from Irdroid user’s regarding the possibility of using the Irdroid USB Infrared Transceiver on Mac OS X. The above was not possible until now, because Lirc couldn’t compile on Mac OS X without doing changes to the original LIRC source code.
The Irdroid USB Infrared Transceiver module enumerates in the host system as a serial ACM device. In OS X the serial USB ACM driver is shipped and supported natively, which means that you don’t have to install any additional drivers and the module should enumerate “out-of-the-box” once plugged in a free USB port.
Considering the above and in order to have a fully functional Infrared Transmit and Receive environment in Mac OS X the only remaining thing that we need is a port of LIRC for Mac OS X, because LIRC manages the infrared transactions and provide utilities for transmitting and receiving infrared signals. LIRC is based on Linux and it can be easily ported to Mac OS X because Mac OS X is a POSIX operating system.
Mac OS X Mountain Lion
Homebrew / brew v.1.1.7 (for installing GCC and dialog*required by the LIRC setup scripts)
GCC 4.9.3 (installed and compiled using Homebreq/brew)
Xcode 5.1.1 command line utilities (installed via Xcode)
To make a port of LIRC one needs to replace the #include <linux/types.h> (Because we are no longer using Linux) with a custom include file defining the relevant types for Mac OS X.For the above I have created a custom include file that replaces the <linux/types.h> and named it <my_custom_types.h> . Next I replace <linux/types.h> with #include “my_custom_types.h” in all source files that contained <linux/types.h> . I also had to install the “dialog” using brew as the LIRC version I used uses “dialog” for the setup and configuration process.
After that in order to make the configuration for my system I runned the ./configure.sh configuration script which generated a Makefile and configuration for my particular system (Mac OS X Mountain Lion) . After that make && make install compiled successfully and I was surprised to see a fully functional LIRC daemon working with my old Mac.
I had to create a “rc.local” file in /etc/ so that lircd is called on boot and also LIRC needs the directory /var/run/lirc created on boot ,which is a separate lin in /etc/rc.local file.
The contents of rc.local are as follows:
lircd –device=/dev/cu.usbmodem00000001 –listen=8765
the above commands create the required directories on boot and also start the lirc daemon. As you can see on Mac OS X the serial ACM devices are enumerated as /dev/cu.usbmodemxxxxxxxx (that is Apple’s way of naming these) . In my case the Irdroid USB Infrared transceiver enumerated as /dev/cu.usbmodem00000001 .
The other thing that you need to do is to get a sample lircd.conf file and copy it into /etc/lirc/lircd.conf (this is the default location for lircd configuration files)
Depending on your configuration you may have to open port 8765 in Mac OS X firewall settings in order to be able to access the running LIRC daemon from another system on your local network, or using a LIRC client running on your Android Smartphone.
Transmitting Infrared signals:
If you will use LIRC locally only, then you can use the “irsend” utility for transmitting infrared commands.
# irsend SEND_ONCE Samsung_TV Power
Next you can do some useful infrared task automation, with irsend and Cron , scheduling infrared commands etc.
Receiving and decoding Infrared Signals:
There are two utilities which you can use for reading infrared signals with Lirc – irrecord and irw .
The “irw” utility will allow you to “watch” the received pulse – space IR sequencies directly in the console.
The “irrecord” utility will allow you to scan and record your existing remote controls and storing the recorded commands into a lirc configuration file.
You can record your remote by issuing :
# irrecord –device=/dev/cu.usbmodem00000001 mylirc.conf
Used Tools (Software and Hardware):
Homebrew for Mac OS X (v 1.1.7)
The LIRCd port for Mac OS X https://github.com/Irdroid/LIRC-port-for-Mac-OS-X
Example Lircd.conf file https://www.irdroid.com/db/database/mylirc/lircd.conf