Code Example: Linux + PyUSB & the Dream Cheeky Thunder/Storm USB Missile Launcher


Went to Staples the other day to grab some assorted accessories for work and I saw they had some Brookstone USB Desktop Missile Launchers in the clearence section, so I grabbed one.

What fun, I thought. Plugged it into my work desktop (running LinuxMint Debian Edition) only to find there were no linux drivers for this particular device.

This turned into a nice little weekend project :)

Googling around found pyrocket and pymissile. But, neither of these projects would work with this model.

Digging under the hood I ran lsusb which gave me this:

Bus 002 Device 008: ID 2123:1010

A little searching showed that it was a rebrand of the Dream Cheeky Thunder/O.I.C Storm models.

There is a goofy project called Retaliation that uses this model in conjunction with the Jenkins continuous integration server to punish the person who broke a build. It was very useful in seeing how to manipulate the device with PyUSB, as it was really the only thing I could find that interfaces wih the device in Linux.

Additionally USB Snoopy was useful for reverse engineering USB messages the device was using that I couldn’t grok from Retaliation.

A few days later and lots of PyUSB and Tkinter trial and error, I give you my Storm Launcher.

It is not so very complex, but there are a few points to note:

  • Debian/Ubuntu’s python-usb package installs PyUSB 0.4 and this project uses 1.0, so you’ll need to install it manually.
  • You’ll need to run it as root (or via sudo) unless you want to dick around with udev rules.

One final note for others attempting to do something similar with a USB device in Linux that caused me to waste a few hours and receede my hairline a bit: You need to detach the kernel driver or you cannot claim the device.

Setup the device as normal using the ID numbers from lsusb:

dev = usb.core.find(idVendor=0x2123, idProduct=0x1010)

Detach the kernel driver if it is active:

if dev.is_kernel_driver_active(0) is True:
   dev.detach_kernel_driver(0)

This will free you up so you can get to work.

So there you have it. I fear for the sanity of my co-workers who walk up behind me to ask questions: *pew* *pew* *pew* :P

Download the code here.

Share
  • fan of your piece of software

    Could you help me in converting your wonderfull program into a plain terminal version? so without Tkinter? Running an Ubuntu server and controlling it over ssh. Sorry for my english an thank you very much for your help!

  • Anonymous
  • Anonymous

    and:
    $ cat /etc/udev/rules.d/thunder.rules
    SUBSYSTEM==”usb”, ATTR{idVendor}==”2123″, ATTR{idProduct}==”1010″, ACTION==”add”, GROUP=”thunder”, MODE=”0664″
    $ sudo /etc/init.d/udev restart
    (plus adding thunder to /etc/group)

  • airballrad

     I got this working great under Fedora 17 with a few module installs. Thanks!