Archive for May, 2009

Artomatic!

I’ve accidentally run current backward through some delicate electronics, gone through a staggering number of voltage regulators and flat-out melted a solenoid, but my Artomatic project seems to be working! There is, of course, still a chance that some hardware aspect of the thing will fail. Or that there’s a hidden software bug that will prevent it from rebooting on schedule. Or that I’ll screw something up when I try to move the log files to a nonvolatile disk location. But for now I’m feeling pretty good about it! If you’re by the Navy Yard Metro in the next month, you should drop by, see some art and ring some bells.

The Artomatic website makes it unfortunately difficult to find when the damn event will actually be open. But the info can be found in this press release. The key details:

May 29 – July 5, 2009

Wednesdays and Thursdays, 5 p.m. – 10 p.m.

Fridays and Saturdays, 12 noon – 1 a.m.

Sundays, 12 noon – 10 p.m.

closed Mondays and Tuesdays.

You can find a map of the location here — Artomatic is in the same building as the Navy Yard Metro entrance that’s closest to the ballpark. My piece is on the fourth floor.

OH YEAH: For those interested, the project’s software is all on GitHub. If you’re wandering in from Google in an effort to figure out how to get Python working on the Fonera with serial and network capabilities, this would be a good place to start.

Artomatic Update: HORRIBLE “STAND” PUN HERE

Progress!

Artomatic stand

Based on only my sketchy verbal instructions, my dad whipped two of these up in astoundingly little time as I watched dumbly. He also fed me dinner! It was an impressive performance all around, and I’m very grateful. This thing’s about 3′ tall, and it’s what my finished piece will sit upon for display. It’ll be draped in cloth, though, so this is hopefully the last time you’ll see it.

In less positive news:

stolen wheel

Upon getting back to the Metro last night I found my rear wheel had been stolen. My current run of bad bike-luck is now impressively long (for those keeping score, the last month has gone flat, flat, flat, flat, wheel, flat, brake cable, shifter cable, trued replacement wheel, stolen other wheel). I suppose I can’t complain too much — this Jamis served me very well and with very few problems for the past 3.5 years (ever since my lovely last bike was stolen from out in front of Logan Hardware). Karmically, I’m doing okay.

But this is still infuriating. The return on a stolen bike wheel is miniscule — the person who took this probably got less than 5% of the retail cost of the components that I’ll now have to rebuy. Worse, I know it’s my fault for being rushed and parking it at a Metro and forgetting my cable. And, well, it just sucks. I try to take these things in stride, but it takes me a couple of days to let go of the anger that being victimized provokes. Last night’s dreams featured some pretty elaborate bicycle-themed revenge fantasies.

giving up on DD-WRT

My DD-WRT adventures have come to an end. I spent a long time finding the perfect firmware, cramming Python into it, massaging libraries and… found an immovable roadblock.

Here’s the thing: in DD-WRT the serial port — which I intend to use for communication between the Arduino and Fonera — is connected to the Linux console. This makes sense: that port is there as an interface of last resort, but it’w only useful if it’s actually connected to something like the shell. Unfortunately, a side effect of this is that all incoming communication triggers system commands — regardless of whether it’s from an administrator who’s just accidentally screwed up his ethernet port or from a microcontroller trying to politely say hello. Worse, the console hogs the serial port, preventing my Python script from reading from it at all.

This linkage is established when the kernel is invoked. That’s not an easy thing to change without recompiling DD-WRT. It can be undone at runtime using a program called setconsole, but that program isn’t compiled into the DD-WRT firmware I have — I’d have to recompile to get it. And if I’m going to recompile things, why not just use OpenWRT? It’s smaller, easier to build and more customizable. And while DD-WRT and its community is undoubtedly better for most people trying to simply turn their routers into better routers, OWRT’s got more people ready to discuss the esoteric router territory where I’ve found myself. The order of magnitude difference in the projects’ respective IRC channel populations is proof enough of that. Sure, in OWRT exotic network configurations may require a bit more wading through documentation and conf files (as opposed to DD-WRT’s pleasantly powerful web interface). But that’s a small price to pay if the goddamn thing actually works.

So last night I successfully built and installed OpenWRT. I had to do it in a VirtualBox Ubuntu image — building OWRT on OS X is possible but a bit of a pain. Other than that, it went great. I haven’t yet put the install through its python-using paces — I found I’d accidentally left a few packages out on my first pass, so after establishing that SSH worked I set it to recompile and went to bed — but every software component I need (python-mini, setconsole, pyserial, stty, etc.) was right there in the menuconfig build system. Clearly somebody has gotten these things to work in the past — tonight I hope to be next one to accomplish that feat.

Artomatic Update: Python on the Fonera

UPDATE: Scratch that. I’ve hit a roadblock related to serial communication in DD-WRT. If you’re only interested in using Python for socket communication and simple stuff, the below text is still useful. But I’ve concluded that if you want serial, DD-WRT is not the way to go. I’ve moved on to OpenWRT — you can see the first step in this process here.


You might remember that I’ve done a bunch of work on integrating the Fonera and the Arduino. It’s a handy setup for microcontroller hobbyists: a reflashed router provides a wireless network interface that’s much cheaper than the purpose-built alternatives available for the Arduino, and one which, by virtue of its Linux firmware, is also considerably more powerful. The downsides are its size and power requirements, but for most applications those aren’t big concerns.

Last time around I just ran a cron job on the router that periodically fetched data from a web server and shoved it to the Arduino using the busybox-based command line tools that come with the DD-WRT firmware (wget, bash, stty). For my next project, those tools aren’t going to cut it. I need two way communication between the Arduino and the Fonera, and I need less latency and more flexibility than those command line tools can offer. I need a proper scripting language.

Unfortunately, things are a bit cramped on the Fonera. There’s an apt-get-like system for installing add-on packages to OpenWRT-based firmwares — it’s called ipkg — but it’s broken on the Fonera, and there’s very little space for the installation of such packages.

You can get around this, but it’s a little tricky. First: realize that ipkg is only sort of broken (on the newer firmwares, at least). You can’t update the list of packages. You can locate a package, copy it over and do an “ipkg install filename“. You’ve just gotta find the right one. (Also: note that I’ve read that using ipkg to remove items on the Fonera can badly screw up your filesystem. Better to remove them manually and/or reformat your JFFS partition.)

Packages with “mini” in their name are probably your best bet. Now you just need to find a compatible one. From the DD-WRT List of Supported Devices we can see that the Fonera uses an Atheros chipset. Start running Google searches like this one and you should be able to find what you need. Here, I’ll make it easy for you: this is the ipkg I used to install python on the Fonera. Copy it over to the Fonera with scp or something similar, then run “ipkg install python-mini_2.5.1-2_mips.ipk”. Success!

Well, until you try to do something with it. I needed three things out of this python installation: simple client/server network functionality (the socket module); the ability to fire off shell processes (the os module); and the ability to communicate with the Arduino over a serial link (the pySerial project).

The first is pretty simple. For reasons that I haven’t bothered to figure out, the socket module is named _socket in the minipython distribution. Adjust your scripts to do an “import _socket as socket” instead of “import socket” and you should be fine. I was able to run the first two examples (client and server) on this page, anyway (debugging the other end of the connection with netcat on my laptop). Good enough for me!

Firing other programs runs into problems. Try to import the os module and you’ll get some complaints about a missing UserDict class. I believe that this class wrapper has been deprecated; I cobbled this UserDict.py together from some Google searches, and after placing it in the lib-dynload path (on my router it’s /jffs/usr/lib/python2.5/lib-dynload/), I can import the os module successfully. I have not tested it thoroughly. os.system(‘touch WHATEVER’) works fine, but beyond that I can’t make any guarantees.

Finally, there’s the question of serial communication. This is actually harder than is may sound: there’s a hardware issue we need to work out before we worry about pySerial at all.

The comments on my Dorkbot post revealed a problem I didn’t know I had: the serial voltage of the Arduino is different from the serial voltage of the Fonera. The former uses 5v, the latter uses 3.3v. This is a pretty common situation, actually, and it’s generally solved through the use of a chip like the MAX232. Fortunately, we can get away with even less. The Arduino’s designers anticipated this problem and made the device able to recognize 3.3v serial input, so signals from the Fonera to the Arduino should work fine. This is why my Dorkbot project worked even though I hadn’t accounted for the voltage mismatch.

But the voltage differential of signals sent from the Arduino to the Fonera needs to be explicitly dealt with — we can’t rely on the Fonera to handle the higher voltage as gracefully as the Arduino does. Fortunately, shedding DC voltage is a lot easier than boosting it, so this is also a pretty easy problem to solve. We just need to make a voltage divider circuit that goes from 5v to 3.3v. It’s basically two resistors, simply arranged. Easy! Alternately, you might be able to step the voltage down using the magic voltage-dropping properties of diodes, but I haven’t bothered to try.

Alright! So our signals are aligned. Back to the software problems. pySerial requires the os module, but we’ve already solved that module’s UserDict problem; on to the next headache. This one is called termios, and it’s a compiled library, not just a python class. It’s commonly included with python, but apparently not with the stripped-down version that we’re using. That’s a drag. We need a version of this library that has been compiled for the Fonera’s MIPS processor. Compiling such a thing on a non-MIPS processor (like your computer) is possible, but cross-compilation is fairly involved to set up. I wanted to just find a compiled version and drop it in.

Once again, googling around downloads.openwrt.org turned out to be a good idea. But don’t go looking for termios — you won’t find it. Instead, I looked for a beefier python ipkg — one designed for more powerful machines, and which contains all of the normal libraries that ship with python. I found it, downloaded it and then uncompressed it (ipkgs are just tarball archives with a specific layout). That yielded two more tarballs; I opened the one named “data.tar.gz”. Within the directories spawned by that I found termios.so. I took that file, dropped it into the aforementioned /jffs/usr/lib/python2.5/lib-dynload/ directory, and was immediately able to import pyserial. Well, okay, not immediately — the first version of the python ipkg that I grabbed was built for mipsel processors, not mips, and gave me a helpful error message when I tried to import it. Once I had the right binary everything went surprisingly smoothly. I haven’t currently got the necessary hardware set up to properly test pySerial, but will report back when I do.

For those of you trying to follow my steps exactly, here’s the termios.so that I’m using. This method should work more generally for selectively loading python libraries that you need onto your Fonera.

Incidentally, all of this is a massive overengineering of what’s necessary to finish my Artomatic project: those requirements could probably be satisfied with a wireless doorbell kit from Logan Hardware and a couple of 555 ICs. But I want this system to ultimately work over the internet, so for me it’s worthwhile to create an IP-capable device.

more homebrew

I’ve been a little worn down all day. Yesterday Kriston and I set out to begin a batch of homebrewed wheat beer. But we did a bad job of estimating times and got a late start, and the result was a brewing operation that lasted until 3AM.

It seems to have gone fine, though. It wasn’t yet bubbling by the time I left for work, but of course that was only a horrifically small number of hours since it went into the fermenter. By the time I got home from work it was bubbling away happily:

This is a marked improvement from my last brewing attempt, which spewed foam all over the goddamn place. This time the friendly folks at the Philly homebrew store gave me some Belgian Wyeast liquid yeast, and it seems to be a bit better behaved than True Brew’s relatively vigorous stuff.

I been on the teevee

Want to hear me say “UHHH” several hundred times? Here, this should scratch that itch:

I can’t help cringing when I watch this, but I really did have a good time, and I’m grateful for being given the opportunity to represent Sunlight.

Washington Journal is an impressively high-volume operation — you’re led into the studio and then it’s almost immediately time to go. It’s a little bit disorienting. The fact that the studio turns out to be exactly on the other side of wall on which the green room monitors are located doesn’t help matters. It’s like a video window, man! I appreciated the coffee and the chocolate croissant, but it seems like an even nicer thing to do for your guests would be to minimize the mind-bending spatial revelations that you expose them to.

I can’t say I’m immensely pleased with my performance during the first half of the show, but things did improve as we got further in and moved on to topics that I’ve been working on for more than a couple of days (this recovery.gov stuff has been kind of sudden). By the twenty minute mark I was still acting weird and stilted, but not much more so than I do in real life. If I get another chance to do this maybe I’ll find a way to speak fluidly for more than six syllables at a time — that’s the dream, anyway.

I wish I had more amusing thoughts to share about the experience, but at the time I was too terrified to make many wry observations. Besides, I’m pretty sure that everyone who works in D.C. winds up on Washington Journal eventually — when I signed my name in the guestbook (marking myself as a total n00b, no doubt), I wasn’t at all surprised to see the name of a friend-of-friends that I run into at parties a couple of lines above my own. What I’m trying to say is that you’ll no doubt have a chance to have this experience yourself if you you have both a job in Washington and a collared shirt.

Oh yeah! They gave me a coffee mug! This small piece of proof (the above clip could of course be entirely computer-generated and for all I know is) is now my most prized media-appearance-related mug. Previously this position was held by the mug I received for my appearance at the NBC4 Health & Fitness Expo, which involved walking in and helping myself to a complimentary mug. I think someone was getting crowd shots, though, so it totally counts.

Proof!

this is getting ridiculous

My new wheel is working great — more than 24 hours without a flat! — but on my way to work this morning something happened to my front brake cable. I can still engage the break, but it doesn’t disengage. My current theory is that the cable half-popped somewhere in its housing, maintaining the connection but providing a tangled wire mess that prevents proper braking (I have to pry the levers apart by hand). Back to the Bike Rack! The guys there are going to think I have the cyclist version of Munchausen by Proxy.