I suppose this will be much like my last post. If you don’t know much about Heyu, this is from the main website:
HEYU is a text-based console program for remotely controlling lights and appliances in the home or office. The complete source is made available under the free Heyu License.
Heyu uses the CM11A computer interface to send and receive X10 control signals over the AC power lines to modules which can turn On, Off, or Dim attached lamps or appliances. It can store a schedule of timed events in the CM11A memory for execution when the computer is turned off or disconnected.
Now it is written for Linux, and that worked for me for a long time. However, I want to be able to create a GUI and use my most familiar programming environment of Xcode and Mac OS X.
Unless my search skills are horrible, it takes a looooong time to find instructions on how to compile the Heyu libraries for Mac OS X and get it up and running. I finally found some stuff from 2002, and I will share my newfound knowledge here so that it can spread on the interwebs.
First, you need a USB to Serial adapter. Sorry. They are probably $15, but cheaper ones must exist. Next, you need to discover where OS X thinks the adapter is. Open up Terminal and type:
cd /dev
ls
This should show a whole bunch of stuff. Ignore the tty* stuff and look for something that sounds like our adapter. My terminal shows an item called cu.usbserial. Perfect! So write down (or remember) the location.
Download Heyu from the website linked above. ‘cd’ into the downloaded directory and type:
./Configure freebsd
Mac OS X has a Unix base built upon freeBSD, so this creates a makefile perfect for OS X. Even though it says “now run make as a normal user,” there’s one last change left. Edit the x10.h file (I just use ‘pico’ in the Terminal) and perform the following:
change
#else
#define LOCKDIR “/var/lock”
#endifto
#else
#define LOCKDIR “/tmp”
#endif
Now go ahead and run ‘make’. Heyu will guide you through the rest of the install. At some point you ‘sudo make install’ and give and option of where the config file should live. I chose the home directory so I could have easy access to it. (It will be a hidden directory so access through Terminal with ls -a). Also at some point, you’ll be asked to give the address of the CM11a interface, which you’ve connected to your USB to Serial port by now. Give it the location we found earlier. For what I found, this was ‘/dev/cu.usbserial’.
After the ‘sudo make install’ everything is ready to go! You can use the standard Heyu command set. Here are a few to get you started.
heyu start
heyu info
heyu on a1
heyu dim a1 10
My next Heyu post will discuss how to execute shell scripts and commands from an Xcode project using NSTask.