|
From: <mmi...@gm...> - 2006-12-04 12:37:35
|
Hello,
I am working in a project that needs to use libusb to avoid automatic
detection of some usb devices when connected.
I have downloaded and instaled libusb-win32-filter-bin-20060827.exe. But I
can't make work the example application, I have an "access violation error"
when trying to access to usb_configuration_descriptor, here is the code:
struct usb_bus *bus;
struct usb_device *dev;
const struct usb_version *version;
edit_printf_init();
usb_find_devices();
version = usb_get_version();
if(version)
{
edit_printf("DLL version:\t%d.%d.%d.%d\r\n",
version->dll.major, version->dll.minor,
version->dll.micro, version->dll.nano);
edit_printf("Driver version:\t%d.%d.%d.%d\r\n\r\n",
version->driver.major, version->driver.minor,
version->driver.micro, version->driver.nano);
}
edit_printf("bus/device idVendor/idProduct\r\n");
for (bus = usb_get_busses(); bus; bus = bus->next) {
for (dev = bus->devices; dev; dev = dev->next) {
int ret, i;
char string[256];
usb_dev_handle *udev;
edit_printf("%s/%s %04X/%04X\r\n", bus->dirname, dev->filename,
dev->descriptor.idVendor, dev->descriptor.idProduct);
udev = usb_open(dev);
if (udev) {
if (dev->descriptor.iManufacturer) {
ret = usb_get_string_simple(udev, dev->descriptor.iManufacturer,
string, sizeof(string));
if (ret > 0)
edit_printf("- Manufacturer : %s\r\n", string);
else
edit_printf("- Unable to fetch manufacturer string\r\n");
}
if (dev->descriptor.iProduct) {
ret = usb_get_string_simple(udev, dev->descriptor.iProduct, string,
sizeof(string));
if (ret > 0)
edit_printf("- Product : %s\r\n", string);
else
edit_printf("- Unable to fetch product string\r\n");
}
if (dev->descriptor.iSerialNumber) {
ret = usb_get_string_simple(udev, dev->descriptor.iSerialNumber,
string, sizeof(string));
if (ret > 0)
edit_printf("- Serial Number: %s\r\n", string);
else
edit_printf("- Unable to fetch serial number string\r\n");
}
usb_close (udev);
}
if (!dev->config) {
edit_printf(" Couldn't retrieve descriptors\r\n");
continue;
}
for (i = 0; i < dev->descriptor.bNumConfigurations; i++)
print_configuration(&dev->config[i]);
}
}
SendMessage(edit_box, WM_SETTEXT, 0, (LPARAM) edit_buffer);
edit_printf_free();
}
dev->config is not NULL, but when I try to acces to his content I have the
acces violation error. That makes me think that the configuration is not in
the structure, but Why not??
I would appereciate very much your help.
Regards,
Mar
|