# HG changeset patch # User Ivo Smits # Date 1366925512 -7200 # Node ID a9c4fed19e998161dbd0002d4dec82004990dc24 # Parent 2e3f57f326b379965b4778c1a34a573201a2395c USBLib: fixes in USBIO driver and LibUsbDotNet compatibility code diff -r 2e3f57f326b3 -r a9c4fed19e99 USBLib/Communication/LibUsbDotNet.cs --- a/USBLib/Communication/LibUsbDotNet.cs Sun Apr 21 19:41:19 2013 +0200 +++ b/USBLib/Communication/LibUsbDotNet.cs Thu Apr 25 23:31:52 2013 +0200 @@ -110,7 +110,7 @@ int iConfigs = Info.Descriptor.ConfigurationCount; for (int iConfig = 0; iConfig < iConfigs; iConfig++) { int iBytesTransmitted; - if (!GetDescriptor((byte)UsbDescriptorType.Configuration, 0, 0, cfgBuffer, cfgBuffer.Length, out iBytesTransmitted)) + if (!GetDescriptor((byte)UsbDescriptorType.Configuration, (byte)iConfig, 0, cfgBuffer, cfgBuffer.Length, out iBytesTransmitted)) throw new Exception("Could not read configuration descriptor"); if (iBytesTransmitted < UsbConfigDescriptor.Size || cfgBuffer[1] != (byte)UsbDescriptorType.Configuration) throw new Exception("GetDeviceConfigs: USB config descriptor is invalid."); diff -r 2e3f57f326b3 -r a9c4fed19e99 USBLib/Communication/USBIO/USBIODevice.cs --- a/USBLib/Communication/USBIO/USBIODevice.cs Sun Apr 21 19:41:19 2013 +0200 +++ b/USBLib/Communication/USBIO/USBIODevice.cs Thu Apr 25 23:31:52 2013 +0200 @@ -22,6 +22,7 @@ static readonly int IOCTL_USBIO_GET_DESCRIPTOR = _USBIO_IOCTL_CODE(1, METHOD_OUT_DIRECT); static readonly int IOCTL_USBIO_GET_CONFIGURATION = _USBIO_IOCTL_CODE(6, METHOD_BUFFERED); static readonly int IOCTL_USBIO_SET_CONFIGURATION = _USBIO_IOCTL_CODE(9, METHOD_BUFFERED); + static readonly int IOCTL_USBIO_UNCONFIGURE_DEVICE = _USBIO_IOCTL_CODE(10, METHOD_BUFFERED); static readonly int IOCTL_USBIO_CLASS_OR_VENDOR_IN_REQUEST = _USBIO_IOCTL_CODE(12, METHOD_OUT_DIRECT); static readonly int IOCTL_USBIO_CLASS_OR_VENDOR_OUT_REQUEST = _USBIO_IOCTL_CODE(13, METHOD_IN_DIRECT); static readonly int IOCTL_USBIO_RESET_DEVICE = _USBIO_IOCTL_CODE(21, METHOD_BUFFERED); @@ -114,8 +115,8 @@ req.ConfigurationIndex = (ushort)i; req.NbOfInterfaces = Math.Min((ushort)32, config.Descriptor.InterfaceCount); for (int j = 0; j < req.NbOfInterfaces; j++) { - LibUsbDotNet.Info.UsbInterfaceInfo intf = config.InterfaceInfoList[i]; - *((USBIO_INTERFACE_SETTING*)(req.InterfaceList + sizeof(USBIO_INTERFACE_SETTING) * i)) = + LibUsbDotNet.Info.UsbInterfaceInfo intf = config.InterfaceInfoList[j]; + *((USBIO_INTERFACE_SETTING*)(req.InterfaceList + sizeof(USBIO_INTERFACE_SETTING) * j)) = new USBIO_INTERFACE_SETTING() { InterfaceIndex = intf.Descriptor.InterfaceID, AlternateSettingIndex = 0, MaximumTransferSize = UInt16.MaxValue }; } DeviceIoControl(DeviceHandle, IOCTL_USBIO_SET_CONFIGURATION, (IntPtr)(&req), sizeof(USBIO_SET_CONFIGURATION), IntPtr.Zero, 0);