comparison USBLib/Windows/USB/UsbDevice.cs @ 68:e811297f5aa4

Updated USBLib: removed old LibUsbDotNet compatibility code and added new information helper classes
author Ivo Smits <Ivo@UCIS.nl>
date Wed, 16 Oct 2013 16:58:39 +0200
parents 2d16447eff12
children 9b898d8b2541
comparison
equal deleted inserted replaced
67:2d16447eff12 68:e811297f5aa4
139 request.SetupPacket.Index = (short)langId; 139 request.SetupPacket.Index = (short)langId;
140 request.SetupPacket.Length = (short)length; 140 request.SetupPacket.Length = (short)length;
141 int nBytes = length + szRequest; 141 int nBytes = length + szRequest;
142 Byte[] bigbuffer = new Byte[nBytes]; 142 Byte[] bigbuffer = new Byte[nBytes];
143 if (!Kernel32.DeviceIoControl(handle, UsbApi.IOCTL_USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION, ref request, Marshal.SizeOf(typeof(USB_DESCRIPTOR_REQUEST)), bigbuffer, nBytes, out nBytes, IntPtr.Zero)) { 143 if (!Kernel32.DeviceIoControl(handle, UsbApi.IOCTL_USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION, ref request, Marshal.SizeOf(typeof(USB_DESCRIPTOR_REQUEST)), bigbuffer, nBytes, out nBytes, IntPtr.Zero)) {
144 if (descriptorType == (Byte)UsbDescriptorType.Device && index == 0 && langId == 0) {
145 Byte[] descbytes = DeviceDescriptor.GetBytes();
146 length = Math.Min(descbytes.Length, length);
147 Array.Copy(descbytes, 0, buffer, 0, length);
148 return length;
149 }
144 int err = Marshal.GetLastWin32Error(); 150 int err = Marshal.GetLastWin32Error();
145 if (err != 2 && err != 31 && err != 87) throw new Win32Exception(err); 151 if (err != 31) throw new Win32Exception(err);
146 return 0; 152 return 0;
147 } 153 }
148 nBytes -= szRequest; 154 nBytes -= szRequest;
149 if (nBytes > length) nBytes = length; 155 if (nBytes > length) nBytes = length;
150 if (nBytes < 0) return 0; 156 if (nBytes < 0) return 0;