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 |
Comparing Ruby Performance
My old friend P.O. Boykin recently took a look at Ruby (and other scripting languages) and came up with a very interesting post: Performance of Programming Languages
After spending time with so called “scripting languages” (a term that I feel is not a terribly well defined or useful), I have found that I enjoy programming in languages like Ruby, Python, and Boo more than languages like C, C++, Java, or C# (though C# is getting better and better as they improve the language). My question is: how much performance do I loose by adopting one these laguages. To answer this question I took a look at the Language Shootout site.
I hadn’t heard of the Language Shootout site; that’s a very interesting link. They compare the implementations of your favorite programming languages (and are very careful not to say they compare the actual language, just the implementation) and produce a whole lot of “at-a-glance” graphs.
I’m a very recent fan(atic) of Ruby. I still don’t “think” in Ruby, just because I don’t have enough trench time with it. But I subscribe to the Google group RSS feed for comp.lang.ruby, and it’s very common to find code snippets (usually in response to a question) that just make me smile. Since more than half of the work I do at my job is using a PC to communicate with a significantly slower device (parallel FPGA, usb or serial Micro, or a 1-Wire device), I try to sneak scripting solutions in wherever I can. If the PC takes 100x more cpu time to compute a message that is going to be put on a slow bus (several orders of magnitude slower than the cpu) noone is going to notice the loss of a few extra nanoseconds. That said, I usually need to hand code off to other people (those so-called “paying customers”) and using a more popular programming language (C or Java) makes that hand-off much easier.
But for some of my tasks, Ruby’s elegance outweighs any of the performance penalties. Ruby is still fairly young, so I’m hoping that in the near future it will reach a good level of general acceptance and gain some significant performance improvements (thanks to all the eyes it now has on it). Also, I think it’d be interesting to run the same benchmarks the Language Shootout guys did, but using either YARV [1] or RB2C [2]. Seems that if those projects don’t do better than vanilla Python, they should re-think their solution. It’d be nice to see if they are able to tighten the large margins between the Java or .NET runtime.
[1] YARV: Yet Another Ruby VM - http://www.atdot.net/yarv/
[2] RB2C : a Ruby to C converter http://www-lab09.kuee.kyoto-u.ac.jp/~hiwada/ruby/rb2c/
Posted in Code | 4 comments |
Updated Typo to Latest Edge
Last night, I updated this Typo install to the latest svn trunk (rev 725). I had been running at rev 586 for a while now, but I was hesitant to upgrade as I noticed there were a few database changes. Turns out that, thanks to Rails Migrations, the database changes were simple (for me anyways, maybe not for the author of the migrations). While I was at it, I went ahead and updated Typo to run the latest Edge Rails also. Here’s the procedure I used on Dreamhost to install these:
# Get Latest Typo
$ svn co svn://leetsoft.com/typo/trunk typo-edge
# Get Latest Rails
$ cd typo-edge/vendor
$ svn co http://dev.rubyonrails.org/svn/rails/trunk rails
$ cd ..
$ rake update_javascripts
$ rake add_new_scripts
# Copy My Typo Configuration
$ cp ../{old-typo}/config/database.yml config/database.yml
$ cp -r ../{old-typo}/themes/globalreset themes/globalreset
$ vi config/environment.rb #forced RAILS_ENV='production'
# Update link I use to point to a version of Typo
# My setup expects web root at this link/public
$ rm typo
$ ln -s typo-edge typo
Then I opened my browser and navigated to /admin and was immediately prompted with a list of necessary Database Migrations, which must be performed on my existing database to be compatible with this version of Typo. I clicked affirmatively, and after a few seconds I was running the latest and greatest Rails and Typo.
Make sure you backup your database before attempting this. The web-based phpMyAdmin that Dreamhost provides is suitable for this. I’ve seen a couple of users report on the Typo-ML that they had some migration issues. I don’t know if those issues ended up in a wedged database or not, but better safe than sorry.
Posted in Code | 4 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.
RubyConf
RubyConf 2005 is underway and I’m hoping that the slides from the presentations will be available soon. I found that Kevin Clark is live-blogging RubyConf and is doing a pretty good job of it (Thanks, Kevin!).
His notes from the progress report on YARV: Yet Another Ruby VM are an especially interesting read. Maybe YARV will finally help answer the question, “Does RubyOnRails Scale?”
Thanks to Ezra Zygmuntowicz, you can start listening in on some presentations as well.
Update: Matz’s slides from his keynote speech on the future of Ruby are now available online. He talks about a lot of cool ideas that are going to keep Ruby 2.0 very fun. There’s even a video(198mb).
Posted in Technology, Code | no comments |
Rogue Software Development
I happened upon this amazing story (via Wired). The incredible Graphing Calculator application, which is included with Macintosh computers, was actually a clandestine, rogue project at Apple. A contractor, whose project was cancelled, continued to sneak into the building and work on the application.
I asked my friend Greg Robbins to help me. His contract in another division at Apple had just ended, so he told his manager that he would start reporting to me. She didn’t ask who I was and let him keep his office and badge. In turn, I told people that I was reporting to him. Since that left no managers in the loop, we had no meetings and could be extremely productive. We worked twelve hours a day, seven days a week.
Thanks to all his hard work, Graphing Calculator was bundled in with the OS and was initially shipped on more than 20 million machines. That’s a pretty good sized audience.
When we had a test Mac at my first co-op job, I wasted a few hours playing around with Graphing Calculator. It was almost enough to make me ‘switch’ back then… Though, college students who are paying their own way through college have a hard time affording a Mac (until the Mac Mini anyways). Wondering why he didn’t ship a version of it with Windows?
We wanted to release a Windows version as part of Windows 98, but sadly, Microsoft has effective building security.
Posted in Code | no comments |
Freeloader - a RubyOnRails Movie Librarian
I’ve been working on my own RubyOnRails app for the past week: Freeloader. The idea is sort of like Delicious Library, except it’s web-based and it’s a form of folksonomy. Like Delicious Library, Freeloader will allow you to create a library of all the movies you own and it will track who you’ve lent those movies too and whether or not those movies are overdue. Unlike Delicious Library, friends who you’ve designated as contacts can browse your collection online and request to borrow any movie(s) they see of interest. Registered users can help ‘tag’ movies and rate/review movies or other users. i.e. “I recommend this movie if you like such and such” or “Scott sucks, he never returns my stuff on time”.
My immediate goal is to create a very narrow folksonomy, as in a private install with a private group of friends. The project is open and (much like Typo) your free to install your own version of it to help coordinate your circle of movie-borrowing friends.
I do have a test site setup that anyone can try out. I will nuke the database periodically, so don’t spend much time inputting your library. Right now, the only features that work are registering a new user, searching/adding new movies, adding any existing movie to your own collection, viewing your collection, viewing the collection of any user, and adding/removing ‘friends’. When I’m ready to start using the project regularly, the test site will become ‘invite-only’, though anyone is still free to browse the collections.
If you want to try out the code for yourself, you can browse the source and see other project details at the Trac wiki and svn repository.
If you’d like to contribute anything to the project or need help installing what’s currently there, let me know.
Update - if the test site doesn’t seem to work (i.e. you get an Application Error), just hit refresh a couple of times. For some reason, my fcgi processes are having trouble staying alive on Dreamhost tonight.
Posted in Technology, Movies, Code | no comments |
JSR-277 Might Fix Java
Thanks to Ted Neward, I just read about this interesting new Java Specification Request: JSR 277
The specification of the Java Module System should define an infrastructure that addresses the above issues. Its components are likely to include:We also expect the Java Module System to expose the public J2SE APIs as a virtual module in order to prevent unwanted usage of the private APIs in the implementation.
- A distribution format (i.e., a Java module) and its metadata as a unit of delivery for packaging collections of Java code and related resources. The metadata would contain information about a module, the resources within the module, and its dependencies upon other modules. The metadata would also include an export list to restrict resources from being exposed outside the module unintentionally. The metadata may allow subset of exposed resources to be used by other modules selectively.
- A versioning scheme that defines how a module declares its own version as well its versioned dependencies upon other modules.
- A repository for storing and retrieving modules on the machine with versioning and namespaces isolation support.
- Runtime support in the application launcher and class loaders for the discovery, loading, and integrity checking of modules.
- A set of support tools, including packaging tools as well as repository tools to support module installation and removal.
Modules with metadata about their dependencies sounds like just what the doctor ordered. It’s crazy that Java has such a large and pro-active userbase, yet it is so slow in catching up to the fledgling .NET. Item #1 and #2 should’ve been implemented a long time ago, and Sun knows it. I agree with Ted as well when he says:
About the only thing I *wish* we could do that’s out-of-scope to the JSR is to fix the javac compiler to cease emitting .class files directly, but instead consider .class files to be the moral equivalent of C/C++-compiled .obj files, and automagically do that final step and turn it into a .jar file right out of the box. (Out of curiosity, is there anybody out there who doesn’t immediately jar up your .class files?)
I know I immediately jar mine up, except in the cases where I’m prototyping with a single .class. If Javac auto-jarred, that wouldn’t bother me in that case.
Posted in Technology, Code | no comments |
Typo
Always one to chase after the shiny new technology, I’ve moved my blog over to Typo from Wordpress. Typo is a recent blogging engine developed using the latest buzzworthy web framework Ruby on Rails. I’ve been meaning to experiment with Ruby on Rails for a while now, and I guess Typo is a good start. One of the first differences you’ll notice is that Typo is AJAX-ified with a handy “Live Search” dialog over there on the right-hand side. This provides a pretty nifty instant search interface, with a transparent round-trip to the server. So you get something that looks somewhat like a local application, much like most of GMail’s functionality. Getting Typo running on Dreamhost wasn’t nearly as straightforward as Wordpress. Here’s the steps I followed:
- Used Subversion to do a checkout on my local Mac of the latest Typo source (svn co svn://leetsoft.com/typo/trunk trunk).
- Used the Dreamhost Web Panel to add the IP address of my local Mac to the allowed IP addresses that can access my mysql database.
- Used CocoaMySQL to make a dump of my existing database (in case I screwed anything up) using the Export->”CocoaMySQL Dump” menu option.
- Used CocoaMySQL to import the schema required for Typo (I imported it into the same database as my Wordpress install) using the Import->”CocoaMySQL Dump” menu option and selecting the db/schemas.mysql.sql file.
- I used Cyberduck to ftp the Typo files into mywebsite/typo folder.
- Made some necessary files executable (chmod +x script/ public/).
- Browsed to http://mywebsite/typo/public to configure the installation.
- Ran db/converters/wordpress.rb to import my Wordpress database into Typo.
- Made a backup of the Wordress blog php files (moved /blog to /blog2).
- Used the Dreamhost Web Panel to make a new subdomain (blog.globalreset.org).
- Moved the Typo installation into the subfolder for blog.globalreset.org.
- Remapped the domain to point to blog.globalreset.org/typo/public as the root folder for the website.
I fought for a while with getting Typo to work under my /blog subfolder of my domain, but it didn’t like it. I followed on the directions on the Rails wiki and in the Dreamhost forum, but couldn’t get it to grok the urls. I gave up and just went with a new subdomain, which Rails apps seem to like.
Also, I couldn’t find any themes I liked for Typo yet, so I started mucking with the default one. I’m not terribly happy with what I’ve ended up with here, but it’ll do for now.
Technorati Tags: RubyOnRails, Typo
Posted in Technology, Code | no 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 |

