Hi

Because of many people recommended to use usbser.sys instead of writing
my own COM mapping driver I did so, and it works so far.

My problem now is, that I should be able to use the device's second
configuration - so I think I can name some kind of multifunctional device.

For getting quick results about feasability, I used libusb-win32 (latest
version). I tried to reset the device, enumerate all for getting a new
handle set config but got an error. I think it must be usbser.sys that
claims the device befor I can do it. How can I solve the problem. Any idea.

Many thanks in advance

Robin

--> here's the code by Robin

Robin
Wed Aug 18 03:02:32 CDT 2004

int main(int argc, char* argv[])
{
struct usb_bus *busses;
struct usb_bus *bus;
struct usb_device *dev;
int c, i, a, r;

usb_init();
usb_find_busses();
busses = usb_get_busses();
usb_find_devices();

for (bus = busses; bus; bus = bus->next)
{
for (dev = bus->devices; dev; dev = dev->next)
{
usb_dev_handle* udev = usb_open(dev);

if (udev && dev->descriptor.iManufacturer)
{
usb_reset(udev);
break;
}
} // for (dev = bus->devices; dev; dev = dev->next)

r = usb_find_devices();
for (dev = bus->devices; dev; dev = dev->next)
{
// Loop through all of the configurations
for (c = 0; c < dev->descriptor.bNumConfigurations; c++)
{
// Loop through all of the interfaces
for (i = 0; i < dev->config[c].bNumInterfaces; i++)
{
// Loop through all of the alternate settings
for (a = 0; a < dev->config[c].usbInterface[i].num_altsetting; a++)
{
// Check if this interface is vendor specific
if (dev->config[c].usbInterface[i].altsetting[a].bInterfaceClass
== 255)
{
usb_dev_handle* udev = usb_open(dev);
int r = usb_set_configuration(udev, c+1); // --> fails
r = usb_claim_interface(udev, i);
char bufWrite[] = "this is just a test string";
char bufRead[1024] = {0};
for (int l = 0; l < 100; l++)
{
r = usb_bulk_write(udev, 1, bufWrite, sizeof(bufWrite), 100);
printf("Written %d bytes\n", r);
r = usb_bulk_read(udev, 2, bufRead, sizeof(bufRead), 100);
}
r = usb_release_interface(udev, i);
r = usb_close(udev);
}
}
} // for (i = 0; i < dev->config[c].bNumInterfaces; i++)
} // for (c = 0; c < dev->descriptor.bNumConfigurations; c++)
} // for (dev = bus->devices; dev; dev = dev->next)
} // for (bus = busses; bus; bus = bus->next)
}

Re: USB: multifunction device beside usbser.sys by ste_meyer

ste_meyer
Sat Aug 21 10:26:12 CDT 2004

Robin <holi@nospam.com> wrote in message news:<#6n3kiPhEHA.244@TK2MSFTNGP10.phx.gbl>...
> Hi
>
> Because of many people recommended to use usbser.sys instead of writing
> my own COM mapping driver I did so, and it works so far.
>
> My problem now is, that I should be able to use the device's second
> configuration - so I think I can name some kind of multifunctional device.
>
> For getting quick results about feasability, I used libusb-win32 (latest
> version). I tried to reset the device, enumerate all for getting a new
> handle set config but got an error. I think it must be usbser.sys that
> claims the device befor I can do it. How can I solve the problem. Any idea.
>

AFAIK, Windows doesn't support devices with multiple configurations.
Linux and other OS's do. If your device has multiple configurations you can
only use the first one.

To overcome this problem you could modify your firmware (descriptors) and
build a composite device (device with one configuration and multiple
interfaces).
Your device would than appear as two seperate devices. One of them handled by
usbser.sys the other one by libusb-win32's device driver.

Hope this helps.

Stephan

> Many thanks in advance
>
> Robin