In the ongoing effort to enhance Podtique for mere mortals, I’m building a web server within the device to aid in configuration. I’ve chosen node.js (really, locomotive) for this. But the main code is written in C++, and I needed a way for the node.js code to communicate with the C++ process.
For now, I’ve settled on dbus for this. While the actual device runs Linux, making dbus a natural choice, I prefer to do as much development as possible on OS X, and dbus also works on OS X when installed via brew. But before you do that, there are a few caveats to getting d-bus to build and run on Yosemite (probably true of the last few OS X releases) that aren’t handled by brew out-of-the box.
Setting up dbus
Be sure to remove any leftover launchd files that might’ve been installed by MacPorts. My system had symlinks pointing into
/opt did not exist.
/Library/LaunchAgents/org.freedesktop.dbus-session.plist /Library/LaunchDaemons/org.freedesktop.dbus-system.plist ~/Library/LaunchAgents/org.freedesktop.dbus-session.plist ~/Library/LaunchDaemons/org.freedesktop.dbus-system.plist
A Google search turns up a lot of information showing both of these plist files being used, but the latest version only provides one of them, and that’s all that seems necessary.
Now install dbus:
$ brew install d-bus
As of this writing, this installs dbus 1.8.14.
dbus requires a dæmon process to be running. Thew brew formula for dbus doesn’t set that up automatically, but has some instructions to set it up. Execute the following commands to configure the dbus dæmon to run automatically:1
$ ln -sfv /usr/local/opt/d-bus/*.plist ~/Library/LaunchAgents $ launchctl load ~/Library/LaunchAgents/org.freedesktop.dbus-session.plist
launchctl reports the following:
/usr/local/Cellar/d-bus/1.8.14/org.freedesktop.dbus-session.plist: File exists
it means that it is already loaded and running (perhaps from a previous install). Try the following (you might need to
$ launchctl remove org.freedesktop.dbus-session
Note: It’s important to note that the user that starts the dbus dæmon should be the same user that will own the processes that want to communicate with that dæmon.
Setting up Xcode
Setting up Xcode is relatively straightforward. Select the appropriate target, choose the “General” tab, and click the “+” under “Linked Frameworks and Libraries.” This will open a sheet. Click “Other…” and begin typing
libdbus-1.dylib and click “Add.”
Next, click on the “Build Settings” tab and ensure that you have the following search paths added to “Header Search Paths”:
Include dbus headers like this in your code:
Last year I powered my camp entirely from the sun (with the exception of our ridiculous lighting on Pipe Dream). Here’s a quick description of the system.
|Panels||3 72-cell, 230 W, leased from BRS|
|Charge Controller||Morningstar TriStar MPPT 60|
|Inverter||Samlex 24V 2000W Pure Sine Wave|
|Batteries||2 SunXtender PVX-2120L 12 V 212 Ah|
|Electrical Panel||MidNite Solar MNE125ALT|
|DC Breakers||MidNite Solar MNEPV-XX|
|AC Breakers||MidNite Solar MNEACXXQZD|
|Surge Protector||MidNite Solar MNSPD-300-DC on PV Input|
|Monitoring||Pentametric PM-5000-U and PM-102-USB, and a BeagleBone Black with LCD display and custom software.|
|Hardware||Custom-designed and built PVC rack, XRS Rails, associated mounting hardware. Also, breakers, outlets, grounding hardware, surge protection on panels.|