Blog

  • Launchpad Update

    I am almost done rewriting my launchpad code so that it can be run without a kernel module. Instead, I’ll be using libusb, which is a reasonably common and cross-platform library for interacting with USB devices.

    I’m having a couple issues with callbacks and polling, but I’m making pretty steady progress, and should have a stable version to post pretty soon.

    The header for interactions with the launchpad is going to look like this:

    typedef void(*launchpad_callback)(unsigned char* data, size_t len, void* user_data);

    struct launchpad_handle* launchpad_register(launchpad_callback e, void* user_data);

    int launchpad_write(struct launchpad_handle *dp, unsigned char* data, size_t len);
    int launchpad_poll(struct pollfd* descriptors, size_t num);

    void launchpad_deregister(struct launchpad_handle* dp);

    You start by writing your callback function, which will be called whenever new data is available from the launchpad, or a write to the launchpad completes. Then register that to start receiving notifications. Call write to send data to the device, and use the launchpad_poll in your main loop, which externally will act as a standard system poll() call, but also handles device events.

    It’s worth noting that you can play with the kernel module already by downloading the code from the project page

    On the technical side, I’ve worked through a couple issues that took a bit more debugging than I really wanted, so I figured I’d post them here:

    The correct formulation for libusb_lock_events appears to be put immediately before your call to poll(), and you should unlock immediately afterwards. If you lock events for the entire access time, you will find that although you’re polling, the reads and writes you initiate never get processed.

    If libusb_submit_transfer() is failing with code -1, it’s possibly a IO error, meaning that you don’t have your endpoint correctly defined. For me the issue was that although my output endpoint was an interrupt type, it actually was registered as a bulk-data type. (that is, it’s address was 0x02 rather than 0x01. Checking your endpoints with lsusb -v will let you check what the actual endpoints should be.)

  • Novation Launchpad

    The Novation Launchpad
    Launchpad

    Information here is outdated. Look instead at the Latest Progress.

    The new toy I got for christmas was a novation Launchpad.  It’s a Midi controller developed specifically for ableton live, and is able to both generate midi data or trigger program actions.

    Since my current computer is running ubuntu, I was planning to use it in that context, but the device uses its own protocol to communicate at the USB level.  Luckily, the protocol is not a difficult one, in that it is stateless, and consists entirely of sending specific 3-byte sequences to the device.  With that in mind, I started reading through documentation to figure out what it would take to develop a linux driver that was compatible with the protocol.

    Two days later I have a reasonably stable kernel module, and a basic midi driver for the launchpad running under linux.  I’ve placed the work as a google code project, and it is available for perusal: http://code.google.com/p/launchpadd/

    The coding was really interesting, since it was my first experience writing a kernel module.   The kernel environment has always scared me and perhaps rightly so, since I did cause several hard crashes while I was developing this code, but overall it was not unpleasant.  The device did almost everything I wanted using the skeleton USB driver provided in the kernel source, with the one exception that the included driver did not support polling for events.  Since I wanted to allow for non-blocking reads to the device I switched it’s queues so that it would properly hook up with the character device polling interface.

    My eventual goal is to use the launchpad as a control device for my computer, showing and allowing for control of things like virtual desktop, volume, email, battery, and clipboards.  I’ve already written a couple of these functions, and hope to have it essentially finished by the end of winter break when I go back to school.  This has been one of the most fun programming projects I’ve undertaken in a while, since I get the excuse to write in several different contexts, and bring in several of the concepts like sockets and selecting that I got excited by in the fall.

  • Secret Santa

    Just got a secret santa mix-tape. Hosting the images here for re-posting.

    You can listen vicariously through the mp3 version posted here.


  • 2009, the christmas card edition

    2009 was another great year for me.  I came back to the states from my semester abroad in China just after the new year, went back to China for the summer, and had two amazing semesters at Harvey Mudd.

    My spring was very busy mostly because of classes in Algorithms and Galois Theory, both of which were very rewarding.  A tradition I started last year of having a beach party continued this year, and was a nice break in the spring.

    West Dorm Courtyard
    Dorm Courtyard at the Beach Party

    I went back to China this summer to work at Microsoft Research Asia, which was a great experience.  I got to interact with parallel and distributed computing problems that actually interested me, and it got me excited about more challenging problems in Computer Science.  I also got to travel a lot this summer, and went to Datong (inland from Beijing), XiAn (Near the middle of the country), Qingdao (On the coast), and up to Mongolia.

    The last of these trips, a weekend that I went up to mongolia is probably the most memorable part of the year for me, and will stay with me for a long time.  I took a bus up to the border of China and Mongolia, and hitchhiked both ways across the border. (Since you aren’t allowed to walk across and there aren’t any regular busses, hitchhiking is the only reasonable option.)  I ended up meeting the family of the mongolian guy that took me across the border, and got to try to communicate with them in very broken chinese (which they spoke less of than I did) while he unloaded his jeep.

    Jeep at the Mongolian Border
    Broken down while crossing the border

    In the fall I buckled down and applied to several graduate programs in addition to school.  The most interesting classes in the fall were Computer networks and Parallel programming, both of which got through important material, while also being very fun.

    I recently got a job offer from Google that I am leaning towards accepting, although I still need to make peace with delaying graduate school.

  • Preview

    WordPress is now configured to my liking, which has taken a turn to the minimalistic.
    Some additional work may eventually go into making the comments fit better into the rest of the theme, and making some of the sidebar features fit in more naturally. Otherwise though I’m really happy with how it came out.

    The next step will be to setup a google wave plugin that synchronizes posts between the two systems, because that would be cool.

    In real life, it’s winter break. One more semester until I finish college. Some amount of neurosing over what to do with my life. But pretty happy overall.

  • Hello world!

    I flipped this site over to using wordpress. Hopefully that will come with a nicer interface for me and for readers. I’m aiming for a pretty simple theme on the site – modeled after preview – and it’s almost there.

    Font scaling is a bit less perfect than I’d like, but that’s kinda the way it’s going to be, mostly because of the minimum 8pt font restriction browsers have set up.

  • A New Test

    This is testing, once again, the performance of a program I’m writing. The application development provided by google wave is really nice, so I’m building a simple robot that will post waves to an arbitrary server whenever they change. The example for this will be my blog – where posts will show up and stay in sync with the version I have saved in wave.

  • test input

    This is just a test to see if I can get data into this bl