Mercurial > hg > ucis.core
diff USBLib/Descriptor/UsbDescriptor.cs @ 58:fd63c453ff65
Improved Windows USB enumeration classes
author | Ivo Smits <Ivo@UCIS.nl> |
---|---|
date | Wed, 09 Oct 2013 20:54:15 +0200 |
parents | 15ddb1e0e2a5 |
children | 99ed461509fe |
line wrap: on
line diff
--- a/USBLib/Descriptor/UsbDescriptor.cs Fri Oct 04 13:22:21 2013 +0200 +++ b/USBLib/Descriptor/UsbDescriptor.cs Wed Oct 09 20:54:15 2013 +0200 @@ -33,6 +33,7 @@ public static String GetStringFromDevice(IUsbInterface device, byte index, short langId) { Byte[] buff = new Byte[256]; int len = device.GetDescriptor((Byte)UsbDescriptorType.String, index, langId, buff, 0, buff.Length); + if (len == 0) return null; return GetString(buff, 0, len); } } @@ -199,5 +200,6 @@ 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 *(UsbHubDescriptor*)(ptr + offset); } + public static unsafe int Size { get { return sizeof(UsbHubDescriptor); } } } }