changeset 38:a9c4fed19e99

USBLib: fixes in USBIO driver and LibUsbDotNet compatibility code
author Ivo Smits <Ivo@UCIS.nl>
date Thu, 25 Apr 2013 23:31:52 +0200
parents 2e3f57f326b3
children 3fddcf72ea6a
files USBLib/Communication/LibUsbDotNet.cs USBLib/Communication/USBIO/USBIODevice.cs
diffstat 2 files changed, 4 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- 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.");
--- 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);