# HG changeset patch # User Ivo Smits # Date 1366926055 -7200 # Node ID 3fddcf72ea6a5a2238899fdd8a442a4a2f325b2e # Parent e3329f686b95fa33a428c26d57db382c34ed753a# Parent a9c4fed19e998161dbd0002d4dec82004990dc24 Merge USBLib fixes for USBIO driver diff -r e3329f686b95 -r 3fddcf72ea6a USBLib/Communication/LibUsbDotNet.cs --- a/USBLib/Communication/LibUsbDotNet.cs Thu Apr 25 23:39:55 2013 +0200 +++ b/USBLib/Communication/LibUsbDotNet.cs Thu Apr 25 23:40:55 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 e3329f686b95 -r 3fddcf72ea6a USBLib/Communication/USBIO/USBIODevice.cs --- a/USBLib/Communication/USBIO/USBIODevice.cs Thu Apr 25 23:39:55 2013 +0200 +++ b/USBLib/Communication/USBIO/USBIODevice.cs Thu Apr 25 23:40:55 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);