diff USBLib/Descriptor/UsbDescriptor.cs @ 65:abe0d55a2201

Removed some redundant USB communication code
author Ivo Smits <Ivo@UCIS.nl>
date Tue, 15 Oct 2013 16:19:45 +0200
parents 99ed461509fe
children e811297f5aa4
line wrap: on
line diff
--- a/USBLib/Descriptor/UsbDescriptor.cs	Sun Oct 13 20:03:05 2013 +0200
+++ b/USBLib/Descriptor/UsbDescriptor.cs	Tue Oct 15 16:19:45 2013 +0200
@@ -103,6 +103,11 @@
 			if (offset < 0 || length < 0 || offset + length > buffer.Length) throw new ArgumentOutOfRangeException("length", "The specified offset and length exceed the buffer dimensions");
 			fixed (Byte* ptr = buffer) return *(UsbConfigurationDescriptor*)(ptr + offset);
 		}
+		public static UsbConfigurationDescriptor FromDevice(IUsbInterface device, Byte index) {
+			Byte[] buff = new Byte[UsbConfigurationDescriptor.Size];
+			int len = device.GetDescriptor((Byte)UsbDescriptorType.Configuration, index, 0, buff, 0, buff.Length);
+			return FromByteArray(buff, 0, len);
+		}
 		public static unsafe int Size { get { return sizeof(UsbConfigurationDescriptor); } }
 	}
 	[StructLayout(LayoutKind.Sequential, Pack = 1)]