changeset 44:5a2b51b0d71b

USBLib: Fixed initialization of multi-interface USBIO devices
author Ivo Smits <Ivo@UCIS.nl>
date Wed, 12 Jun 2013 23:08:48 +0200
parents 29cf42a12c34
children 8df7f4dc5615
files USBLib/Communication/USBIO/USBIODevice.cs
diffstat 1 files changed, 6 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/USBLib/Communication/USBIO/USBIODevice.cs	Thu May 23 17:02:17 2013 +0200
+++ b/USBLib/Communication/USBIO/USBIODevice.cs	Wed Jun 12 23:08:48 2013 +0200
@@ -105,7 +105,6 @@
 		public override Byte Configuration {
 			get { return base.Configuration; }
 			set {
-				if (value == Configuration) return;
 				IList<LibUsbDotNet.Info.UsbConfigInfo> configs = (new LibUsbDotNet.UsbDevice(this)).Configs;
 				for (int i = 0; i < configs.Count; i++) {
 					LibUsbDotNet.Info.UsbConfigInfo config = configs[i];
@@ -119,7 +118,12 @@
 								*((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);
+							try {
+								DeviceIoControl(DeviceHandle, IOCTL_USBIO_SET_CONFIGURATION, (IntPtr)(&req), sizeof(USBIO_SET_CONFIGURATION), IntPtr.Zero, 0);
+							} catch (Win32Exception ex) {
+								if (ex.NativeErrorCode == unchecked((int)0xE0001005L)) return;
+								throw;
+							}
 						}
 						return;
 					}