[ do default stuff if no widgets ]

Archive for April, 2010

Windows Support with Libusb 1.0

Tuesday, April 27th, 2010

I’m so happy and excited to say that my efforts weren’t in vain. This past sunday morning, at 12:00 AM, I successfully communicated with flirc in windows. I was able to send control transfers down to my device and receive back data. This is actually huge news as I never was able to consistently get these results in windows using libusb 0.13 (legacy). A few hours later, I got flirc fully working in Windows. I had to adjust my firmware but it was a quick and subtle fix and took me a while to catch. If I ever open source my project, I’ll be happy to share the details of this one.

Things have gone exceptionally well in *nix. I haven’t had a problem with libusb’s portability until I tried to get up and running in windows. But since I’m nearing the final stages of completing my product, I have to get windows up and running.

I’m going to get a little technical here in hopes that I can save someone else from pulling out their own hair too. I should also say that since I’m so close to finishing, this will reveal a little bit about the product.

Libusb 0.13 has had it’s limitation in windows, particularly with HID devices (hint hint hint). The problem is that windows basically claims HID devices and keeps users from having read/write access. If you want to do any custom commands, you’re SOL. flirc is dependent on having custom commands as it’s natural existence is the ability to have a special instance of a HID device without crippling the same driver assigned to that device by the OS.

OSX and Linux worked great. But I was unable to send any vendor control requests down to the device so I began my long search of trying to figure out why. I enabled debugging, which wasn’t helpful, and eventually contacted the developers of libusb-legacy.

That thread eventually led me to libusb 1.0 where I asked if what I was trying was even possible. They said it should be, and encouraged me to port my application to libusb 1.0. So I started the process, which wasn’t very hard.

After ensuring my application worked on my Mac without a hitch, I booted up windows, recompiled with the correct libraries, and alas, it didn’t work. I’ll save everyone the details, it’s a very long discussion and opened up a thread of ~50 emails with the developers.

The real solution to my problem was to modify my firmware to be a composite device. Nevertheless, that still didn’t work, until finally, we pin pointed the problem and came up with a solution.

If anyone is interested, here is the thread, which is still ongoing.

A very special thanks to Peter Stuge, Xiaofan Chen, and Pete Batard who made this project possible by being so sincerely nice and helpful. Not to mention the endless amounts of work they do on a free open source project, thank you.