| 
     
      
      
      From: Dan E. <dan...@ne...> - 2007-06-07 08:31:12
      
     
   | 
Dave Higton wrote: > > > -----Original Message----- > > From: lib...@li... > > [mailto:lib...@li...] On > > Behalf Of Bertrik Sikken > > Sent: 2007 June 06 17:53 > > To: lib...@li... > > Subject: Re: [Libusb-win32-devel] Help, please > > > > Stephan Meyer wrote: > > > Try to replace: > > > > > > uci = usb_claim_interface (udev, 0); > > > > > > with > > > > > > usb_set_configuation(udev, 1); > > > uci = usb_claim_interface (udev, 0); > > > > > > It should work then. > > > > I think I recently saw a recommendation on the libusb list to NOT > > do an explicit usb_set_configuration. If I remember correctly > > Linux already picks a configuration for you (usually devices > > only have one configuration anyway). > > I don't have to do this on Linux, but I do on Win32. > > > What is the proper thing to do when writing something for > > both Linux and Windows? > > Yes, I'd like to know too, please. I'm writing for both. > I've only just started with Win32 and I've discovered > 3 incompatibilities. All solved, of course, thanks to > some extremely rapid help; but it would be easiest for > everybody if there weren't any incompatibilities. > It's a bit of a tricky one really. Under Windows, if you claim a device by VID and PID, then you get to talk to it before the set configuration request is sent - basically the earliest time your driver could be called. This is good, because the OS doesn't actually know which configuration you're going to want (admittedly there's usually only one). The way Linux and at least some other libusb ports work, is that since there is no kernel libusb driver, if there is a class driver for the device, then the configuration will have been set already, and you then have to remove the kernel class driver somehow. If the generic driver is picked then it still seems to set the configuration, which does to me seem a little odd. It gets more complicated if the device has multiple interfaces. Under Windows the compositie driver will be attached if there is no match for the VID/PID. If one of the interfaces has a class driver, then that will be loaded, and obviously the configuration will have to be set. If there is a proprietry driver matchin on VID/PID/Iface, then it won't have much choice about the configuration setting, I'm not sure what happens if it tries to change it. Dan.  |