0

I'm using C++ and libusb-win32 to try and communicate with a commercial USB device ... I don't know much about USB programming, but I want to send some commands to the device that I know from using a sniffer program. Libusb-win32 seemed OK, but it looks like it can only be used on a device that uses the libusb driver for the device. I want to use it on a device with a driver "USB Composite Device" driver provided by windows usbccgp.sys ... is it even possible? If not, how can I do this? I just need to send some Control Transfers

jdex
  • 1,279
  • 1
  • 13
  • 20
  • 1
    This is a fairly broad question. You really should spend some time learning about USB protocols and the USB stack. Here is a [link to the libusb documentation](http://libusb.sourceforge.net/api-1.0/) which would be a starting place. – Richard Chambers Mar 30 '14 at 12:14

2 Answers2

1

This is currently not possible. libusb is designed around the Linux driver model where composite devices are treated as a single device by the system. Windows treats composite devices as multiple separate ones - a parent composite device and child devices for each interface.

As such libusb cannot access the child devices without first changing the parent driver to a libusb supported one. It can be done but then the device won't work with the vendor supplied software.

shogged
  • 281
  • 2
  • 10
0

If you want to talk to a commercial device you need to contact the manufacturer and find out if there is an interface to that device that is published through their driver. Most manufacturers won't have a way to interface with generic control requests in a product. There may be an undocumented IOCTL, but again you'll need to work with them to get this information.

If you just want to hook the device and send it a control request then you need to replace the manufacturer's driver with the libusb driver. The problem here is that while you can get at the device it may not function the way you want unless you spoof what the manufacturer does (for example, the device might expect some vendor specific communication to get the device ready to interact with the host). If you do see problems then you can reverse engineer the vendor specific protocol by looking at the USB line through some hardware analyzer.

Read USB Complete, it's a great introduction to the USB protocol and will help you understand more of what's going on between a USB device and your host PC.

Preston
  • 2,543
  • 1
  • 17
  • 26
  • Actually, I realise now that the device is actually "USB Composite Device" driver provided by windows usbccgp.sys. Maybe this makes it more straight forward? – jdex Apr 01 '14 at 07:22
  • No, not unless one of the interfaces has documentation on usage. The idea here is still the same you'll just need to choose which interface you are addressing through the libusb API, it's usually supplied through the wIndex paramater. – Preston Apr 01 '14 at 14:17
  • So, if some devices use these Windows driver such as usbccgp.sys, how does the manufacturer write their software that interfaces with the device? Even if I can't "interface" with it, just getting so far as to identify the device and open some sort of connection to it would be a good starting point. – jdex Apr 02 '14 at 10:22
  • You really need to read USB complete. The composite driver is just an underlying driver that handles the multiple USB interfaces. There is still another driver that needs to handle the individual interfaces. For example a composite device could have a USB Audio interface, and HID interface and vendor specific interface. Three unique drivers would handle each interface as a unique "device" - a USB Audio driver, an HID driver and a vendor specific driver. In your case you need to interface (verb) with one of your USB interfaces on your device using libusb to be able to send it commands. – Preston Apr 02 '14 at 12:27