1-Wire on Mac OS X and Universal Binaries
Since posting my OneWireViewer App+Source for Mac OS X last August, I still see fairly regular downloads of it in my stats. I also still see lots of hits from google searches for “1-wire” and “mac osx”. I thought I’d let any interested parties know that we are gearing up to release our 1-Wire Public Domain Kit (C code) very soon (likely this month). I put in some effort for this release to create a specific Serial (DS9097U) and USB (DS2490/DS9490) build for Mac OS X. The release will include full source and a build file, as well as pre-built Universal Binaries of all of the example apps. Those without much programming knowledge looking to integrate 1-Wire into bigger systems should appreciate that.
Learning how to build the Universal Binaries was a bit of a chore, but once you get the hang of it it’s fairly simple. The biggest complication was building a Universal Binary for libUSB and since I wanted my libUSB-dependent app to be Universal, I had to jump through hoops to get it to work. I was able to get 0.1.12 to build an Intel library just fine on my Intel Mac (though <= 0.1.11 didn’t work for me, so mind your sources). I couldn’t get it to build the Universal binary due to it’s use of ‘ar’ and ‘ranlib’ (which, according to this tech note from Apple does bad things to Universals). I’m not a configure or makefile whiz and I got a little stumped on the parts of the makefile where gcc was being used to generate new makefiles dynamically (wasn’t aware of this feature before). Apparently when using -MT (to generate new makefile rules) you can’t pass multiple architectures along with your compile command (i.e. “-arch i386 -arch ppc”). I ended up doing things the hard way and just compiling the PPC binary on a PPC mac, and then merging the two with lipo (i.e. “lipo -create -output uni.lib ppc.lib intel.lib”). After all that, I discovered a nice pkg installer for a Universal libUSB that someone else was nice enough to pre-build and distribute for us. I recommend this installer for the easiest path to a Universal binary of libUSB.
My next task is to recompile my Java-to-libUSB-to-1-Wire solution (for OneWireViewer and the rest of the examples in the 1-Wire API for Java) as a Universal Binary. I also need to put a little effort into making it work with libUSB on Linux, so I can update the “live” WebStart version of OneWireViewer with virtually out-of-the-box support for every platofrm. The 1-Wire API for Java was scheduled for release this quarter (ending in 2 weeks), so I hope to have all this done in time to ship out the door with the release.
Posted in 1-Wire, Code | 7 comments |
Source for 1-Wire Java-USB Project
I’ve finally gotten around to creating a source tarball for the work I did to get the Public Domain Kit support files for libUSB running under the 1-Wire API for Java. 80% of the work here was figuring out what to do, so you’ll find there isn’t a lot of code to glue them together. It would be pretty easy, for example, to swap out the PDK files for libUSB with the DS1410E link-level files for Linux. Then you could have parallel port support using the 1-Wire API for Java under Linux as well as the USB port.
The Makefile is geared towards Mac OSX. Everything else, including the C source in the ‘native’ folder, is platform independent and should compile everywhere libUSB does. Using Sun’s reference on how to build JNI libraries for the various platforms, you should be able to modify the Makefile to support your platform. If you have any suggestions for improving the build process, especially if you can help make it a cross-platform Makefile, then please let me know.
OneWireViewer for OSX Download
I had a few people post in the comments about getting a copy of the OneWireViewer update I did… A few email me privately. I’ve been emailing it out to people as it’s requested, but now that I have a good web hosting service, I may as well put it out on the intarweb proper-like.
For now, this is a binary-only distribution. I want to do some more testing with it and make a similar binary distribution for Linux before I make this official. Once I’m convinced that it’s as robust as the PC solution, we’ll move it over to the official Dallas Semiconductor ftp site. Although most of the source is available online (1-Wire API for Java and 1-Wire Public Domain Kit on maxim-ic.com, libusb on libusb.sourceforget.net, rxtx on rxtx.org), some of the glue I used to make this work isn’t. I’ll try to make that available soon to people who want to dig around in that part of it.
Don’t blame me if this application sets your pretty Macintosh computer on fire.
If you have any success with this at all, please leave a comment and let me know.
Posted in 1-Wire, OSX | 29 comments |
1-Wire on Mac OSX: Java/USB Support!
Take a look at this screen capture to see how I spent my 4th of July vacation weekend.
I ended up taking the libusb build of the 1-Wire Public Domain Kit and creating a JNI-wrapper around it. Now I’ve got a nice USB Adapter driver for the Java API (and hence for OneWireViewer). I’m going to look into modifying the WebStart download so that it will deliver the new USB adapter and the binary (JNI) portion of it. Possibly, I can sneak the libusb drivers along with that as well, without causing too much confusion. Maybe make 2 builds, one that includes libusb for people who aren’t cmd-line savvy enough to build their own and one that doesn’t.
The good news is that this should work on Linux, Mac OSX, and Windows. Windows users will have to install a .inf file first, but it will be a single-click application for Linux and Mac.
Update (7/10/2005): I used JarBundler to create a nice .App bundle of this for Mac OS X users. It’s pretty nice to have a installable .App of OneWireViewer that supports both the USB Adapter (DS9490) and the Serial Adapter (DS9097U) on Mac OS X. Unfortunately, I don’t have a good place to host it.. I’m not sure in it’s current form if it’s suitable for an official release to go up on the dalsemi ftp servers. So, if you’d like to try it, just leave a comment and include your email address (not in the comment, but in the regular email address field, where I will be able to see it but noone else will) and I can email you a copy of the app. It’s 2.3mb compressed.
Posted in 1-Wire, OSX, Code | 10 comments |
How-to: 1-Wire/iButton Apps on Mac OSX
For my own benefit (and maybe yours), I’d like to try an collect all the info available for getting 1-Wire apps running on Mac OSX Tiger (10.4). Eventually, I’d like to see a Cocoa application that functions much like OneWireViewer. That’ll be my next fun project, after I complete my “Learning Cocoa and Objective-C” project.
Technorati Tags: 1-Wire, Apple, iButton, MacOSX
Public Domain Kit ApplicationsThe public domain kit includes 2 relevant builds: ulinuxgnu and libusblinux. Though both of these builds have “linux” in the title, ulinuxgnu should really be called uPosixSerial. Libusblinux should just be called the libusb build, as it will work on any libusb platform. I tested with version 3.00 of the Public Domain Kit and got both builds to work perfectly on a near clean installation of Mac OSX 10.4. Both of these builds required the optional XCode install that came with Mac OSX, so that your system will have the GNU C Compiler (gcc) available.
For serial port access, I used a Keyspan serial-to-USB adapter, part number USA-19HS. The drivers included with the adapter worked fine, though you might check Keyspan’s website for the latest drivers. After installing the drivers, I plugged in the serial adapter and used Keyspan’s installed Serial Assistant application to find out the device name of the adapter. In my case, it was USA19H5b14P1. The next step is to connect a DS9097U serial adapter to the Kespan serial-to-USB adapter. Now you can optionally attach a probe or Blue-Dot receptor to the DS9097U and attach any 1-Wire or iButton devices you may have. Otherwise, the only 1-Wire device we are going to see is the 64-bit ID chip embedded in the DS9097U.
For USB access, I used the DS9490R USB adapter and a Blue-Dot receptor. To allow the Public Domain Kit to have access to a USB device, we need a user-land (as opposed to kernel-land) USB driver. That is what libusb provides for us. The easiest way to get libusb is to first install Fink. Fink is a smart package management app that makes it easy to install open-source software on Mac OSX. Soon, a binary installation of Fink will be available for OSX 10.4 users. For now though, follow the “bootstrap” instructions on Fink’s homepage. After fink is installed, type: “fink install libusb” in the terminal. You now have the libUSB drivers installed.
The Public Domain Kit serial and USB builds worked almost “out-of-the-box”. In version 3.00, the ownet.h file optionally defines some types based on platform. Mac OSX isn’t one of the platforms that ownet.h knows how to handle. The next release of the Public Domain Kit will fix this, but for now, I modified the block around “#define OW_UCHAR” to look like the following:
#ifndef OW_UCHARNow, running “make linux” will build all of the Public Domain Kit serial apps. We have to make one more adjustment for the USB build to work. Essentially, Fink “sandboxes” all of the apps and libs that it installs, to keep it from conflicting with other apps that the user may have installed without Fink’s help. So, you’ll need to point the makefile to Fink’s copy of the libusb library files. At the top of the makefile, you’ll find a definition for compiler flags and linker flags, labeled CFLAGS and LFLAGS respectively. Modify them to look like the following:#define OW_UCHAR typedef unsigned char uchar; typedef unsigned long ulong; #include <sys/types.h>#endif
CFLAGS = -DDEBUG -c -I/sw/include LFLAGS = -DDEBUG -g -o $@ -L/sw/libYou are now ready to run “make linux” to build both the serial build and the USB build. In the directory where you built the serial build, type “./tstfind /dev/tty.USA19H5b14P1.1” with you’re serial adapter device name (not mine, USA19H5b14P1). This should give you a scrolling list of all the 1-Wire devices connected to your adapter. To run the same app in the USB build, in the directory where you build the usb build, type “./tstfind DS2490-1” where the number after the dash simply selects which DS9490R or DS9490B adapter you wish to select if you have more than one. To exit both of these applications, type “Ctrl-C”.
1-Wire API for Java Applications
The 1-Wire API for Java is currently waiting for a good RXTX build, version 2.1.7pre19 or later. After installing the RXTX_Jag.pkg included in the current snapshot, I had to edit /etc/groups file to manually add my username to the “uucp” group. I believe the install script should have handled this, but it appears that it didn’t. This got me past a “PortInUseExcpetion”, but now I’m stuck with a “Bus Error”. I believe this is due to a memory management issue in the native layer that is fixed in 2.1-7pre19.
Web-based 1-Wire Applications
A part of the owfs project, owhttpd is a webserver application which allows one to interact with 1-Wire devices. Unfortunately, the owfs app does not itself work on Mac OSX because of the lack of FUSE support. However, owhttpd should work. To set up owhttpd, I first downloaded the “Source only” package for owfs 2.1.0. Then ran, “./configure” and “make”. Configure failed for me when it starting configuring the swig module. I tried to ignore this and cd’ed into the module/owhttpd folder and ran “make” from there. No dice. Looks like the configure script is broken. Hopefully it gets fixed soon as owhttpd looks like a handy application.
1-Wire on Mac OSX
On the very successful front, I have had some luck getting 1-Wire apps to build and run on Mac OSX. I tried for far too long to get rxtx working, so that I could run OneWireViewer. That still fails, but I think it’s for an old reason. I had been having problems with rxtx on Win32 and Linux, but they are fixed in the CVS head revision… Unfortunately, I can’t build the CVS head revision for the Mac yet.
Eventually, I gave up on rxtx/Java and turned to our 1-Wire Public Domain Kit. The ulinuxgnu build (which maybe should be renamed the “posix_serial” build), built and ran perfectly. Using a keyspan USB-to-serial adapter and a DS9097U serial-to-1-Wire adapter, I had 1-Wire connectivity! The only modification I had to make was to the ownet.h file, where it was defining certain data types based on platform (and this platform wasn’t one of the ones it knew about).
I also got the libUSB build to compile, though it threw a lot of ugly warnings. I had to first ask the very cool Fink to “install libUSB.” Unfortunately, I am without a USB-to-1-Wire adapter at home, so I was not able to test if it’s actually going to work. :( But I have every confidence that it’ll work or, if it doesn’t, I’ll get it working.
Posted in 1-Wire, OSX, Code | 2 comments |

