Mercurial > hg > ucis.core
comparison USBLib/Communication/WinUsb/WinUsbDevice.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 | 7e4dae99f919 |
children | 2d16447eff12 |
comparison
equal
deleted
inserted
replaced
64:99ed461509fe | 65:abe0d55a2201 |
---|---|
78 SafeWinUsbInterfaceHandle InterfaceHandle; | 78 SafeWinUsbInterfaceHandle InterfaceHandle; |
79 if (!WinUsb_Initialize(DeviceHandle, out InterfaceHandle)) throw new Win32Exception(Marshal.GetLastWin32Error(), "Could not initialize WinUsb"); | 79 if (!WinUsb_Initialize(DeviceHandle, out InterfaceHandle)) throw new Win32Exception(Marshal.GetLastWin32Error(), "Could not initialize WinUsb"); |
80 if (InterfaceHandle.IsInvalid || InterfaceHandle.IsClosed) throw new Win32Exception(Marshal.GetLastWin32Error(), "Could not open interface"); | 80 if (InterfaceHandle.IsInvalid || InterfaceHandle.IsClosed) throw new Win32Exception(Marshal.GetLastWin32Error(), "Could not open interface"); |
81 InterfaceHandles = new SafeWinUsbInterfaceHandle[1] { InterfaceHandle }; | 81 InterfaceHandles = new SafeWinUsbInterfaceHandle[1] { InterfaceHandle }; |
82 foreach (LibUsbDotNet.Info.UsbConfigInfo ci in (new LibUsbDotNet.UsbDevice(this)).Configs) { | 82 foreach (LibUsbDotNet.Info.UsbConfigInfo ci in (new LibUsbDotNet.UsbDevice(this)).Configs) { |
83 if (ci.Descriptor.ConfigID == Configuration) { | 83 if (ci.Descriptor.ConfigurationValue == Configuration) { |
84 foreach (LibUsbDotNet.Info.UsbInterfaceInfo ifinfo in ci.InterfaceInfoList) { | 84 foreach (LibUsbDotNet.Info.UsbInterfaceInfo ifinfo in ci.InterfaceInfoList) { |
85 foreach (LibUsbDotNet.Info.UsbEndpointInfo epinfo in ifinfo.EndpointInfoList) { | 85 foreach (LibUsbDotNet.Info.UsbEndpointInfo epinfo in ifinfo.EndpointInfoList) { |
86 int epidx = epinfo.Descriptor.EndpointID & 0x7F; | 86 int epidx = epinfo.Descriptor.EndpointAddress & 0x7F; |
87 if ((epinfo.Descriptor.EndpointID & 0x80) != 0) { | 87 if ((epinfo.Descriptor.EndpointAddress & 0x80) != 0) { |
88 if (EndpointToInterfaceIn.Length <= epidx) Array.Resize(ref EndpointToInterfaceIn, epidx + 1); | 88 if (EndpointToInterfaceIn.Length <= epidx) Array.Resize(ref EndpointToInterfaceIn, epidx + 1); |
89 EndpointToInterfaceIn[epidx] = ifinfo.Descriptor.InterfaceID; | 89 EndpointToInterfaceIn[epidx] = ifinfo.Descriptor.InterfaceNumber; |
90 } else { | 90 } else { |
91 if (EndpointToInterfaceOut.Length <= epidx) Array.Resize(ref EndpointToInterfaceOut, epidx + 1); | 91 if (EndpointToInterfaceOut.Length <= epidx) Array.Resize(ref EndpointToInterfaceOut, epidx + 1); |
92 EndpointToInterfaceOut[epidx] = ifinfo.Descriptor.InterfaceID; | 92 EndpointToInterfaceOut[epidx] = ifinfo.Descriptor.InterfaceNumber; |
93 } | 93 } |
94 } | 94 } |
95 } | 95 } |
96 } | 96 } |
97 } | 97 } |