Posts Tagged ‘usb’

Announcing vusb-analyzer 1.1

December 3rd, 2009

The Virtual USB Analyzer is a graphical tool for analyzing USB sniffer logs. It can do some basic protocol decoding, and it has a graphical timeline view which helps to visualize the latency and concurrency characteristics of USB traffic.

This release only adds a single feature, but it’s one that many people have probably been waiting for: support for Linux’s built-in usbmon sniffer tool.

With usbmon, tracing all USB traffic on your system is as simple as cat’ing text from a sysfs node to a file. It doesn’t have quite as many features as VMware’s low-level capture logs, but for most users (especially users debugging Linux USB drivers) this should be more than sufficient.

If you aren’t familiar with usbmon, the first thing to read is Documentation/usb/usbmon.txt from your kernel sources. That will tell you the basics, including how to capture raw data from the kernel. There are a few other simple front-ends for making this data more human-readable. If you’re using vusb-analyzer, those tools aren’t required. Just save the raw data to a file with a .mon extension, and hand that to vusb-analyzer.

This feature was a patch contributed by Christoph Zimmermann. Without his contribution, I no doubt would have procrastinated this release for many more years :)

“Luggable” power pack

June 9th, 2009

Paul and I are leaving on a cross-country train trip next week, for Jen and Shawn’s wedding in Colorado. I’m sure the view will be great, and I’m bringing a handful of books- but Paul and I are geeks and we need our electro-doodads. If only we had a way to run our Nintendo DS and PSP for the ~30 hours that the trip will take…

I sifted through my stockpile of junk, and came up with this:

IMG_0643

It’s kind of like a mega-size Minty Boost, or a heftier version of the Kensington power pack. The Minty Boost weighs in at about 6 Watt-hours, depending on the AA cells you use. The Kensington pack is rated at 7 Watt-hours, with a Lithium Ion battery. This brick occupies the middle-ground between the Minty Boost and a car jump-start battery, weighing in at 84 Watt-hours. It should run and charge a Nintendo DS for at least 30 hours.

It’s built almost entirely from junk that I had lying around the house: (Your house may vary.)

  • 12 Volt 7 AH Lead-calcium battery
  • Aluminum box, in my stockpile of project enclosures
  • Receptacle end from a cigarette lighter extension cable
  • DC-DC converter from an old Nokia phone charger (for a phone I no longer use). Swapped a resistor with a trimmer pot for 5V output.
  • USB sockets from a dead 4-port hub
  • Heavy duty wires and quick-disconnect plugs from a dead UPS
  • Odds and ends: Switch, mounting hardware, fuse holder, wire nuts, foam weather-stripping, JB-Weld epoxy, heat shrink tubing, LED, resistors

Parts I had to buy at the local Fry’s:

  • 10 Amp fuse (Pack of five for a few dollars)
  • 12V 1 Amp lead-acid battery charger ($20)
  • Cigarette lighter plug for the charger ($2)

Now here’s hoping that nobody thinks it’s a “hoax device”…

P.S. I’m still working on the Robot Odyssey DS port and in fact there are some interesting bits of UI working now- but I haven’t quite reached another blog-worthy milestone yet.

Wireless temperature picture frame mashup

January 21st, 2009

IMG_0567

This is the latest geeky addition to our home decor. It’s a Kodak W820 digital picture frame, showing a graph of real-time temperature data collected from around the house: upstairs and downstairs, garage, outdoors, and even inside the refrigerator.

More photos on Flickr, implementation details below…

Temperature Sensors

Most of my friends probably know that back in 2004, when I was still in college, I built a set of wireless temperature sensors. Each one is an Altoids tin containing a 9V battery, a Dallas 1-wire temperature sensor, PIC microcontroller, and a little 315 MHz AM radio transmitter. I built several of these indoor wireless sensors, plus one outdoor sensor which I built out of PVC pipe.

indoor_therm outdoor_mounted Dallas 1-wire Wireless Temperature Sensor

The PIC spends most of its time sleeping, but every 20 seconds or so it wakes up to read the current temperature from the 1-wire sensor. Most of the indoor sensors have the 1-wire temperature probe soldered to the side of the Altoids tin, for the best thermal conductivity. The refrigerator sensor has a length of 30-gauge wire that leads the 1-wire sensor itself into the fridge.

Every couple of minutes, each sensor transmits a burst of packets back to the base station. The base station is another piece of custom hardware: a matching AM radio receiver, some LEDs, and a TUSB3210 microcontroller to do protocol decoding and to interface back to a server machine over USB. In this case, the host machine is a little NSLU2 embedded Linux box which also acts as our home network’s file server.

NSLU2 and wireless temperature receiver

As usual, microcontroller firmware for the transmitter and receiver is open source.

Software

The software running on the server machine has had a rough history. My original implementation was ridiculously complicated: The receiver unit connected to an NSLU2 embedded Linux box over USB. That machine ran a daemon, written in C, which listened for packets over USB and stored their contents in a remote MySQL database. The MySQL database was running on a more powerful server (a 1 GHz Athlon at the time) which had plenty of disk space. That server also ran a web application using mod_python, which pulled data from MySQL, generated graphs on demand using rrdtool, and generally looked really pretty.

My reasons were mostly historical. I wanted to save all of the temperature data (for another project I had at the time), so instead of sending data directly to a lossy RRD file, I just used rrdtool as a cache for the data I was about to graph. As you can imagine, if the cache ever had to be rebuilt, the server would come crashing to its knees. This implementation was plagued with performance and reliability issues.

So, I recently reimplemented a simpler server software solution. I hacked up the C daemon so that instead of writing to a MySQL database, it forks off an rrdtool process to store the data directly into an RRD database. Instead of generating graphs on-demand, I have a small update-graphs shell script which uses rrdtool to generate all of the graphs. This scripts is run from cron every 5 minutes. The resulting graphs aren’t nearly as intricate as the ones that my mod_python app used to generate, but anything looks pretty if you antialias it ;)

The digital picture frame

This frame is a Kodak W820, an amazingly featureful little gadget that I picked up at the local Fry’s for $180. It has an very pretty 8″ 800×480 display and a rather unique touch-based user interface. It also does a pretty ridiculously good job at playing video, considering it’s a picture frame.

But anyway, the real reason to buy this frame is for its Wi-fi connectivity. If you connect it to your network, you get a range of useful and “useful” services:

  • The frame runs its own HTTP server on port 80, with a web interface you can use for managing settings. You can’t upload pictures via this interface, but it does mean that you can configure the picture frame entirely without using Kodak’s silly Windows software.
  • It’s a uPnP media server and a client. The software that comes with it uses uPnP to browse an upload/download files on the frame’s internal memory or memory card, and the frame itself can use uPnP to stream images from your PC. This is a really interesting feature that could be exploited for more dynamic applications…
  • It has a Flickr client. Yes, the frame itself actually speaks the Flickr API.
  • There’s some fancy-pants Kodak online service, which looks like it’s probably little more than an RSS feed in disguise.
  • And best of all, you can give it custom RSS feeds. Like, say, real-time temperature graphs!

The only snag I hit in setting this up was in trying to keep the frame from caching old versions of the temperature graph. It seems to ignore HTTP cache control headers, and the cache seems to be able to hold quite a nontrivial amount of image data!

The best solution I’ve found so far: Use the RSS <ttl> tag to force the frame to reload the RSS feed itself pretty frequently. Then, in my update-graphs script, I dynamically generate an RSS file which includes a timestamp in the URL and GUID for each image. This seems to do the trick.

What next?

I’m really interested in graphing my home power usage, using a receiver circuit based on the one I built for The Kilowatt Clock. I’m currently waiting for some parts from Digi-key, but I’ll definitely blog about this when it’s done.

If you’re at all interested in displaying real-time stats around the home or office, I’d definitely encourage you to play with this picture frame. It has some great hacking potential, and I’m really excited to see what kinds of uses others come up with.

Virtual USB Analyzer

January 12th, 2009

From late 2005 to early 2007, I worked on the USB virtualization stack at VMware. We ran into all sorts of gnarly bugs, many of which were very hard to reproduce or which required access to esoteric or expensive hardware. To help with debugging problems both internally and with customers in the field, we added logging support to our virtual USB stack. Starting with VMware Workstation 5.5, if you set the right hidden config option we’d start dumping the contents of all USB packets to a log. It was a USB sniffer (like USB Snoopy), but built into the virtual hardware.

To make it easier to analyze the resulting logs, I started working on a GUI tool that could navigate through these giant log files. This tool proved to be really useful within our team at VMware, and we’d often ask customers on the beta forums to generate log files that we could analyze. I called this tool vusb-analyzer.

Well, it’s been a while, but I’m proud to now have the opportunity to release vusb-analyzer as open source software under the MIT license. This isn’t just a code dump- I removed the tool from our internal repository today, and all future development will occur in the open, in a Subversion repository on Source Forge.

Currently, vusb-analyzer is most useful for analyzing logs captured by VMware products. Indeed, this is a convenient way to debug USB drivers. You can attach your USB device to VMware Workstation, VMware Fusion, or the free-as-in-beer VMware Player, and it can transparently save a plaintext log of all USB packets that pass through. Debugging a driver in a VM is really convenient, and I find it quite useful, but I understand it’s not for everybody. If you already have a favorite USB sniffer tool, it’s easy to extend vusb-analyzer with a log format plugin so it can read other formats. We already did this once, to add support for the logs generated by our favorite hardware USB analyzers.

I hope vusb-analyzer turns out to be useful for the open source community, particularly to those who are working on Linux device drivers. To get started, visit the project’s web site:

http://vusb-analyzer.sourceforge.net

Besides the usual introduction and download links, there is also a detailed tutorial with lots of shiny screenshots :)

Whirlwind update

March 19th, 2006

CIA

EXPLAIN SELECT is your friend. Added a few indices, eliminated a filesort and a temporary table. Now the front page is super-speedy. Hopefully this will control some of the minor growing pains that I’ve been seeing in the last couple months.

Of course, this is no substitute for some real designed-in scalability and maintainability. I finally updated the to-do list to include these “deep changes”. In theory I’m currently working on Caterpillar Daemon, but I honestly haven’t had the right combination of time and motivation lately to make a whole lot of progress on it.

I should probably set up trac for CIA. At the least, it’s about time we had a mailing list and a bug tracker. The main stumbling block for this actually is that I have no idea what to call such a server. trac.cia.navi.cx is a bit unwieldy. I’d love to have a good second-level domain for CIA, but nobody has come up with a suitable name for one as of yet. Any ideas? cia.gov is probably taken.

Sorry, I’m a little behind on email. Take a number…

Life

Complicated… with a distinct sense of deja vu from almost exactly a year ago.

I’ve had Donnie Darko (the soundtrack and the movie itself) stuck in my head for about a week now. Very tempted to put in an Amazon order with that and a couple other favorite movies of mine that I haven’t bothered purchasing yet.

Jen, David, and Kendra are coming in less than a week!

Music

I forgot how much I like Mogwai.

I finally did some re-wiring such that I can easily route audio to my living room speakers from either the TV, DVD player, HTPC, video games, laptop, or Rio. The Rio cradle also has Ethernet again, including my lovely hack (schematic) to work around a bug in their Ethernet transceiver.

I’m still amazed by how much wiring I’ve been able to stuff into a TV stand that’s exactly the minimum size to hold my subwoofer, DVD player, and 42″ plasma.

Beer

A few weeks ago I finally got around to trying David’s favorite beer, Black Butte Porter. I’m still quite a Guinness fan, but now this may very well be my favorite beer too.

SVLUG

Well, I finally accepted Paul’s nomination for Vice President. Despite my total lack of motivation this weekend, I’d like to start out by helping fix up the increasingly decrepit web site. We’d like to just stick a wiki in there- we’d have introductory content and event schedules posted by core volunteers, but the rest of the site would be more of a general purpose forum for Linux users and other forms of open source nerds in the bay area.

Looking farther ahead, I’d really like to do my part to make SVLUG appeal to open source hackers, rather than just people who use Linux for the sake of using Linux. I should write more on this soon…

USB

Since some clown seems to think I’m a USB-obsessed lunatic, I might as well have a section just for this.

There are lots of exciting USB-related happenings at VMware lately. They should be sneaking into a release later this year, and I’ll finally be able to talk about all the coolness without totally ruining the surprise for you non-VMware folks. For VMware folks, I helped give a tech talk on Wednesday covering our recent USB work.

On a whim today, I thought I’d try getting my old wireless thermometer system working again. I’ve had all the equipment in a box since I moved to California, just waiting for me to set it up. Well, that’s not entirely true… the original system used this awkward combination of MySQL and rrdtool that I’d really love to replace with a clean integration into our Cacti setup.

All hopes of that were dashed away as I gave up on just getting my laptop to talk to the receiver module. I’m not sure whether it’s a new version of SDCC breaking the firmware, or a new Linux kernel that’s a little more picky, but the firmware is dying in an infinite loop the first time my laptop tries to read its device descriptor. I’m tempted to use the USB analyzer at work to debug this.

February 22nd, 2006

Well, it’s been a while since I’ve updated. Nothing on its own recently has inspired me much to write, but I have some smallish things to mention.

I have a new laptop on the way! My 700 MHz Pentium III with 192MB of RAM was just getting too clunky for day-to-day use. I recently ordered a Thinkpad T43 with 2GHz CPU, 1GB RAM, and SXGA+ 14.1″ display. It shipped Monday, and I can’t wait to start using a Real Computer.

At work, things were stagnating a bit for the past few days. I have three fairly large changes all blocking on code reviews, and no really solid projects in progress. Well, today that changed- I got some new hardware, and began on a really exciting Top Sekret project. If it goes well, you’ll find out eventually.

Life? Not bad at all… I had a really enjoyable three-day weekend. David, Jen, and Kendra are visiting during their spring break, in less than a month. Plans for that week-long adventure are starting to gel, and I can’t wait.

[Update: The Top Sekret project in this post would eventually become VMware Fusion 1.0. I was working on USB at the time, and I did the original port of VMware's USB stack to Mac OS.]