Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Programming a USB transfer cable / talking to a USB device driver

How do I programmatically access a USB transfer cable (such as Belkin's Easy Transfer Cable) from Windows?

I'm familiar with libusb-win32, but from what I can tell, using that with newer devices and with Windows Vista seems iffy.

I know that Windows Easy Transfer can do this. How do I write code that does the same thing as Windows Easy Transfer?

If there is no canned documentation on how to do this, I'm willing to do some digging, but I don't know where to start. How do I watch what Windows Easy Transfer is doing to find out how it does it? I see that Windows even gives transfer cables their own category in the Device Manager, "Transfer Cable Devices." How do I do low-level communication with one of these these drivers?

like image 663
Josh Kelley Avatar asked Mar 03 '09 22:03

Josh Kelley


2 Answers

I found out that Microsoft now offers WinUSB for simple user-mode communication with USB devices. (A WinUSB device driver must first be installed for the device; this is somewhat similar to a libusb-win32 device driver.) WinUSB works on XP (SP2 and above) and Vista.

The Easy Transfer Cable uses WinUSB for its device driver, so I was able to communicate with it by following the example code in Microsoft's WinUSB howto document.

like image 145
Josh Kelley Avatar answered Oct 23 '22 09:10

Josh Kelley


You will need to use the low level win32 API to do this. Microsoft has some nice examples here on accessing a Human Interface Device. The transfer cable isn't explicitly an HID like a mouse or keyboard, but it conforms to the HID spec.

For example, to get the name of the USB device you would call

HidD_GetProductString(...)

http://msdn.microsoft.com/en-us/library/ms790920.aspx

There is lots more there, you should definitely take a look at the sample c app that works for all versions of windows from 2000 to Vista.

http://msdn.microsoft.com/en-us/library/dd163258.aspx

Good Luck!

like image 37
Byron Whitlock Avatar answered Oct 23 '22 09:10

Byron Whitlock