private bool InitializeDevice() { try { //Try to initialize the device if (!WinUsb_Initialize(FileHandle, out WinUsbHandle)) { Debug.WriteLine("Failed to initialize winusb device: " + DevicePath); Initialized = false; return(false); } WINUSB_PIPE_INFORMATION pipeInformation = new WINUSB_PIPE_INFORMATION(); USB_INTERFACE_DESCRIPTOR interfaceDescriptor = new USB_INTERFACE_DESCRIPTOR(); if (WinUsb_QueryInterfaceSettings(WinUsbHandle, 0, ref interfaceDescriptor)) { for (byte i = 0; i < interfaceDescriptor.bNumEndpoints; i++) { WinUsb_QueryPipe(WinUsbHandle, 0, i, ref pipeInformation); if (pipeInformation.PipeType == USBD_PIPE_TYPE.Bulk && UsbEndpointDirectionIn(pipeInformation.PipeId)) { BulkIn = pipeInformation.PipeId; WinUsb_FlushPipe(WinUsbHandle, BulkIn); } else if (pipeInformation.PipeType == USBD_PIPE_TYPE.Bulk && UsbEndpointDirectionOut(pipeInformation.PipeId)) { BulkOut = pipeInformation.PipeId; WinUsb_FlushPipe(WinUsbHandle, BulkOut); } else if (pipeInformation.PipeType == USBD_PIPE_TYPE.Interrupt && UsbEndpointDirectionIn(pipeInformation.PipeId)) { IntIn = pipeInformation.PipeId; WinUsb_FlushPipe(WinUsbHandle, IntIn); } else if (pipeInformation.PipeType == USBD_PIPE_TYPE.Interrupt && UsbEndpointDirectionOut(pipeInformation.PipeId)) { IntOut = pipeInformation.PipeId; WinUsb_FlushPipe(WinUsbHandle, IntOut); } } //Debug.WriteLine("Initialized winusb device: " + DevicePath); Initialized = true; return(true); } //Debug.WriteLine("Failed to initialize winusb device: " + DevicePath); Initialized = false; return(false); } catch (Exception ex) { Debug.WriteLine("Failed to initialize winusb device: " + ex.Message); Initialized = false; return(false); } }
protected virtual bool InitializeDevice() { try { var ifaceDescriptor = new USB_INTERFACE_DESCRIPTOR(); var pipeInfo = new WINUSB_PIPE_INFORMATION(); if (Usb.QueryInterfaceSettings(_winUsbHandle, 0, ref ifaceDescriptor)) { for (var i = 0; i < ifaceDescriptor.bNumEndpoints; i++) { Usb.QueryPipe(_winUsbHandle, 0, Convert.ToByte(i), ref pipeInfo); if (((pipeInfo.PipeType == USBD_PIPE_TYPE.UsbdPipeTypeBulk) & UsbEndpointDirectionIn(pipeInfo.PipeId))) { BulkIn = pipeInfo.PipeId; Usb.FlushPipe(_winUsbHandle, BulkIn); } else if (((pipeInfo.PipeType == USBD_PIPE_TYPE.UsbdPipeTypeBulk) & UsbEndpointDirectionOut(pipeInfo.PipeId))) { BulkOut = pipeInfo.PipeId; Usb.FlushPipe(_winUsbHandle, BulkOut); } else if ((pipeInfo.PipeType == USBD_PIPE_TYPE.UsbdPipeTypeInterrupt) & UsbEndpointDirectionIn(pipeInfo.PipeId)) { IntIn = pipeInfo.PipeId; Usb.FlushPipe(_winUsbHandle, IntIn); } else if ((pipeInfo.PipeType == USBD_PIPE_TYPE.UsbdPipeTypeInterrupt) & UsbEndpointDirectionOut(pipeInfo.PipeId)) { IntOut = pipeInfo.PipeId; Usb.FlushPipe(_winUsbHandle, IntOut); } } return(true); } return(false); } catch (Exception ex) { Log.ErrorFormat("{0} {1}", ex.HelpLink, ex.Message); throw; } }
public bool FindPipeAndInterface(UsbK usb, out USB_INTERFACE_DESCRIPTOR interfaceDescriptor, out WINUSB_PIPE_INFORMATION pipeInfo) { if (FindPipeAndInterface(usb, out interfaceDescriptor, out pipeInfo, AltInterfaceId, PipeId)) { AltInterfaceId = interfaceDescriptor.bAlternateSetting; PipeId = pipeInfo.PipeId; return(true); } return(false); }
protected virtual Boolean InitializeDevice() { try { USB_INTERFACE_DESCRIPTOR ifaceDescriptor = new USB_INTERFACE_DESCRIPTOR(); WINUSB_PIPE_INFORMATION pipeInfo = new WINUSB_PIPE_INFORMATION(); if (WinUsb_QueryInterfaceSettings(m_WinUsbHandle, 0, ref ifaceDescriptor)) { for (Int32 i = 0; i < ifaceDescriptor.bNumEndpoints; i++) { WinUsb_QueryPipe(m_WinUsbHandle, 0, System.Convert.ToByte(i), ref pipeInfo); if (((pipeInfo.PipeType == USBD_PIPE_TYPE.UsbdPipeTypeBulk) & UsbEndpointDirectionIn(pipeInfo.PipeId))) { m_BulkIn = pipeInfo.PipeId; WinUsb_FlushPipe(m_WinUsbHandle, m_BulkIn); } else if (((pipeInfo.PipeType == USBD_PIPE_TYPE.UsbdPipeTypeBulk) & UsbEndpointDirectionOut(pipeInfo.PipeId))) { m_BulkOut = pipeInfo.PipeId; WinUsb_FlushPipe(m_WinUsbHandle, m_BulkOut); } else if ((pipeInfo.PipeType == USBD_PIPE_TYPE.UsbdPipeTypeInterrupt) & UsbEndpointDirectionIn(pipeInfo.PipeId)) { m_IntIn = pipeInfo.PipeId; WinUsb_FlushPipe(m_WinUsbHandle, m_IntIn); } else if ((pipeInfo.PipeType == USBD_PIPE_TYPE.UsbdPipeTypeInterrupt) & UsbEndpointDirectionOut(pipeInfo.PipeId)) { m_IntOut = pipeInfo.PipeId; WinUsb_FlushPipe(m_WinUsbHandle, m_IntOut); } } return(true); } return(false); } catch (Exception ex) { Console.WriteLine("{0} {1}", ex.HelpLink, ex.Message); throw; } }
public static bool FindPipeAndInterface(UsbK usb, out USB_INTERFACE_DESCRIPTOR interfaceDescriptor, out WINUSB_PIPE_INFORMATION pipeInfo, int altInterfaceId, int pipeId) { byte interfaceIndex = 0; interfaceDescriptor = new USB_INTERFACE_DESCRIPTOR(); pipeInfo = new WINUSB_PIPE_INFORMATION(); while (usb.SelectInterface(interfaceIndex, true)) { byte altSettingNumber = 0; while (usb.QueryInterfaceSettings(altSettingNumber, out interfaceDescriptor)) { if (altInterfaceId == -1 || altInterfaceId == altSettingNumber) { byte pipeIndex = 0; while (usb.QueryPipe(altSettingNumber, pipeIndex++, out pipeInfo)) { if ((pipeInfo.MaximumPacketSize > 0) && pipeId == -1 || pipeInfo.PipeId == pipeId || ((pipeId & 0xF) == 0 && ((pipeId & 0x80) == (pipeInfo.PipeId & 0x80)))) { goto FindInterfaceDone; } pipeInfo.PipeId = 0; } } altSettingNumber++; } interfaceIndex++; } FindInterfaceDone: return(pipeInfo.PipeId != 0); }
public static USBInterfaceDescriptor WinUsb_QueryInterfaceSettings(IntPtr InterfaceHandle, byte AlternateInterfaceNumber) { USB_INTERFACE_DESCRIPTOR UsbAltInterfaceDescriptor = new USB_INTERFACE_DESCRIPTOR(); if (NativeMethods.WinUsb_QueryInterfaceSettings(InterfaceHandle, AlternateInterfaceNumber, ref UsbAltInterfaceDescriptor) == false) { return(null); } return(new USBInterfaceDescriptor() { bLength = UsbAltInterfaceDescriptor.bLength, bDescriptorType = UsbAltInterfaceDescriptor.bDescriptorType, bInterfaceNumber = UsbAltInterfaceDescriptor.bInterfaceNumber, bAlternateSetting = UsbAltInterfaceDescriptor.bAlternateSetting, bNumEndpoints = UsbAltInterfaceDescriptor.bNumEndpoints, bInterfaceClass = UsbAltInterfaceDescriptor.bInterfaceClass, bInterfaceSubClass = UsbAltInterfaceDescriptor.bInterfaceSubClass, bInterfaceProtocol = UsbAltInterfaceDescriptor.bInterfaceProtocol, iInterface = UsbAltInterfaceDescriptor.iInterface }); }
public static extern bool WinUsb_QueryInterfaceSettings(IntPtr hInterface, byte AlternateInterfaceNumber, ref USB_INTERFACE_DESCRIPTOR UsbAltInterfaceDescriptor);
private static extern bool WinUsb_QueryInterfaceSettings( IntPtr usbInferfaceHandle, sbyte alternateSettingNumber, USB_INTERFACE_DESCRIPTOR usbAltInterfaceDescriptor);
protected static extern Boolean WinUsb_QueryInterfaceSettings(IntPtr InterfaceHandle, Byte AlternateInterfaceNumber, ref USB_INTERFACE_DESCRIPTOR UsbAltInterfaceDescriptor);
protected virtual Boolean InitializeDevice() { try { USB_INTERFACE_DESCRIPTOR ifaceDescriptor = new USB_INTERFACE_DESCRIPTOR(); WINUSB_PIPE_INFORMATION pipeInfo = new WINUSB_PIPE_INFORMATION(); if (WinUsb_QueryInterfaceSettings(m_WinUsbHandle, 0, ref ifaceDescriptor)) { for (Int32 i = 0; i < ifaceDescriptor.bNumEndpoints; i++) { WinUsb_QueryPipe(m_WinUsbHandle, 0, System.Convert.ToByte(i), ref pipeInfo); if (((pipeInfo.PipeType == USBD_PIPE_TYPE.UsbdPipeTypeBulk) & UsbEndpointDirectionIn(pipeInfo.PipeId))) { m_BulkIn = pipeInfo.PipeId; WinUsb_FlushPipe(m_WinUsbHandle, m_BulkIn); } else if (((pipeInfo.PipeType == USBD_PIPE_TYPE.UsbdPipeTypeBulk) & UsbEndpointDirectionOut(pipeInfo.PipeId))) { m_BulkOut = pipeInfo.PipeId; WinUsb_FlushPipe(m_WinUsbHandle, m_BulkOut); } else if ((pipeInfo.PipeType == USBD_PIPE_TYPE.UsbdPipeTypeInterrupt) & UsbEndpointDirectionIn(pipeInfo.PipeId)) { m_IntIn = pipeInfo.PipeId; WinUsb_FlushPipe(m_WinUsbHandle, m_IntIn); } else if ((pipeInfo.PipeType == USBD_PIPE_TYPE.UsbdPipeTypeInterrupt) & UsbEndpointDirectionOut(pipeInfo.PipeId)) { m_IntOut = pipeInfo.PipeId; WinUsb_FlushPipe(m_WinUsbHandle, m_IntOut); } } return true; } return false; } catch (Exception ex) { Console.WriteLine("{0} {1}", ex.HelpLink, ex.Message); throw; } }
public static extern bool WinUsb_QueryInterfaceSettings(IntPtr interfaceHandle, byte alternateInterfaceNumber, ref USB_INTERFACE_DESCRIPTOR usbAltInterfaceDescriptor);
public static extern bool WinUsb_QueryInterfaceSettings(IntPtr InterfaceHandle, Byte AlternateInterfaceNumber, out USB_INTERFACE_DESCRIPTOR UsbAltInterfaceDescriptor);
public bool ConfigureDevice(out WINUSB_PIPE_INFORMATION pipeInfo, out UsbK usb, out USB_INTERFACE_DESCRIPTOR interfaceDescriptor) { bool success; Console.WriteLine("Finding usb device by VID/PID.. ({0:X4}h / {1:X4}h)", Vid, Pid); // Use a patttern match to include only matching devices. // NOTE: You can use the '*' and '?' chars as wildcards for all chars or a single char (respectively). KLST_PATTERN_MATCH patternMatch = new KLST_PATTERN_MATCH(); if (MI != -1) { patternMatch.DeviceID = String.Format("USB\\VID_{0:X4}&PID_{1:X4}&MI_{2:X2}*", Vid, Pid, MI); } else { patternMatch.DeviceID = String.Format("USB\\VID_{0:X4}&PID_{1:X4}*", Vid, Pid); } LstK deviceList = new LstK(KLST_FLAG.NONE, ref patternMatch); KLST_DEVINFO_HANDLE deviceInfo; interfaceDescriptor = new USB_INTERFACE_DESCRIPTOR(); pipeInfo = new WINUSB_PIPE_INFORMATION(); usb = null; // Iterate the devices looking for a matching alt-interface and endpoint id. while (deviceList.MoveNext(out deviceInfo)) { // libusbK class contructors can throw exceptions; For instance, if the device is // using the WinUsb driver and already in-use by another application. Console.WriteLine("Opening usb device.."); usb = new UsbK(deviceInfo); Console.WriteLine("Finding interface and endpoint by PipeId.."); success = FindPipeAndInterface(usb, out interfaceDescriptor, out pipeInfo); if (success) { break; } Console.WriteLine("PipeId {0:X2}h not found on this device.", PipeId); usb.Free(); usb = null; } if (ReferenceEquals(usb, null)) { Console.WriteLine("Usb device not found: {0}", patternMatch.DeviceID); success = false; goto Done; } MI = interfaceDescriptor.bInterfaceNumber; AltInterfaceId = interfaceDescriptor.bAlternateSetting; PipeId = pipeInfo.PipeId; // Set interface alt setting. Console.WriteLine("Setting interface #{0} to bAlternateSetting #{1}..", interfaceDescriptor.bInterfaceNumber, interfaceDescriptor.bAlternateSetting); success = usb.SetAltInterface(interfaceDescriptor.bInterfaceNumber, false, interfaceDescriptor.bAlternateSetting); if (!success) { Console.WriteLine("SetAltInterface failed. ErrorCode={0:X8}h", Marshal.GetLastWin32Error()); Console.WriteLine(interfaceDescriptor.ToString()); } Done: deviceList.Free(); return(success); }
public void SetupEndPoints() { USB_INTERFACE_DESCRIPTOR usbInterfaceDescriptor = new USB_INTERFACE_DESCRIPTOR(); if (!WinUsb_QueryInterfaceSettings(m_usbInferface, 0, usbInterfaceDescriptor)) { throw new Win32Exception(Marshal.GetLastWin32Error()); } for (int i = 0; i < usbInterfaceDescriptor.bNumEndpoints; i++) { WINUSB_PIPE_INFORMATION pipeInfo = new WINUSB_PIPE_INFORMATION(); if (!WinUsb_QueryPipe(m_usbInferface, 0, (sbyte)i, pipeInfo)) { throw new Win32Exception(Marshal.GetLastWin32Error()); } if (pipeInfo.pipeType == USBD_PIPE_TYPE.UsbdPipeTypeInterrupt) { m_pipeID = pipeInfo.pipeId; } } if (m_pipeID == 0) { throw new Exception("interupt pipe no found"); } }
public static extern bool WinUsb_QueryInterfaceSettings(IntPtr InterfaceHandle, Byte AlternateInterfaceNumber, out USB_INTERFACE_DESCRIPTOR UsbAltInterfaceDescriptor);
public bool ConfigureDevice(out WINUSB_PIPE_INFORMATION pipeInfo, out UsbK usb, out USB_INTERFACE_DESCRIPTOR interfaceDescriptor) { bool success; Console.WriteLine("Finding usb device by VID/PID.. ({0:X4}h / {1:X4}h)", Vid, Pid); // Use a patttern match to include only matching devices. // NOTE: You can use the '*' and '?' chars as wildcards for all chars or a single char (respectively). KLST_PATTERN_MATCH patternMatch = new KLST_PATTERN_MATCH(); if (MI != -1) patternMatch.DeviceID = String.Format("USB\\VID_{0:X4}&PID_{1:X4}&MI_{2:X2}*", Vid, Pid, MI); else patternMatch.DeviceID = String.Format("USB\\VID_{0:X4}&PID_{1:X4}*", Vid, Pid); LstK deviceList = new LstK(KLST_FLAG.NONE, ref patternMatch); KLST_DEVINFO_HANDLE deviceInfo; interfaceDescriptor = new USB_INTERFACE_DESCRIPTOR(); pipeInfo = new WINUSB_PIPE_INFORMATION(); usb = null; // Iterate the devices looking for a matching alt-interface and endpoint id. while (deviceList.MoveNext(out deviceInfo)) { // libusbK class contructors can throw exceptions; For instance, if the device is // using the WinUsb driver and already in-use by another application. Console.WriteLine("Opening usb device.."); usb = new UsbK(deviceInfo); Console.WriteLine("Finding interface and endpoint by PipeId.."); success = FindPipeAndInterface(usb, out interfaceDescriptor, out pipeInfo); if (success) break; Console.WriteLine("PipeId {0:X2}h not found on this device.", PipeId); usb.Free(); usb = null; } if (ReferenceEquals(usb, null)) { Console.WriteLine("Usb device not found: {0}", patternMatch.DeviceID); success = false; goto Done; } MI = interfaceDescriptor.bInterfaceNumber; AltInterfaceId = interfaceDescriptor.bAlternateSetting; PipeId = pipeInfo.PipeId; // Set interface alt setting. Console.WriteLine("Setting interface #{0} to bAlternateSetting #{1}..", interfaceDescriptor.bInterfaceNumber, interfaceDescriptor.bAlternateSetting); success = usb.SetAltInterface(interfaceDescriptor.bInterfaceNumber, false, interfaceDescriptor.bAlternateSetting); if (!success) { Console.WriteLine("SetAltInterface failed. ErrorCode={0:X8}h", Marshal.GetLastWin32Error()); Console.WriteLine(interfaceDescriptor.ToString()); } Done: deviceList.Free(); return success; }
public static bool FindPipeAndInterface(UsbK usb, out USB_INTERFACE_DESCRIPTOR interfaceDescriptor, out WINUSB_PIPE_INFORMATION pipeInfo, int altInterfaceId, int pipeId) { byte interfaceIndex = 0; interfaceDescriptor = new USB_INTERFACE_DESCRIPTOR(); pipeInfo = new WINUSB_PIPE_INFORMATION(); while (usb.SelectInterface(interfaceIndex, true)) { byte altSettingNumber = 0; while (usb.QueryInterfaceSettings(altSettingNumber, out interfaceDescriptor)) { if (altInterfaceId == -1 || altInterfaceId == altSettingNumber) { byte pipeIndex = 0; while (usb.QueryPipe(altSettingNumber, pipeIndex++, out pipeInfo)) { if ((pipeInfo.MaximumPacketSize > 0) && pipeId == -1 || pipeInfo.PipeId == pipeId || ((pipeId & 0xF) == 0 && ((pipeId & 0x80) == (pipeInfo.PipeId & 0x80)))) { goto FindInterfaceDone; } pipeInfo.PipeId = 0; } } altSettingNumber++; } interfaceIndex++; } FindInterfaceDone: return pipeInfo.PipeId != 0; }
public bool FindPipeAndInterface(UsbK usb, out USB_INTERFACE_DESCRIPTOR interfaceDescriptor, out WINUSB_PIPE_INFORMATION pipeInfo) { if (FindPipeAndInterface(usb, out interfaceDescriptor, out pipeInfo, AltInterfaceId, PipeId)) { AltInterfaceId = interfaceDescriptor.bAlternateSetting; PipeId = pipeInfo.PipeId; return true; } return false; }
private static bool QueryInterfaceSettings( WinUsbHandle InterfaceHandle, Byte AlternateInterfaceNumber, out USB_INTERFACE_DESCRIPTOR UsbAltInterfaceDescriptor) { return(WinUsb_QueryInterfaceSettings(InterfaceHandle, AlternateInterfaceNumber, out UsbAltInterfaceDescriptor)); }
protected static extern Boolean WinUsb_QueryInterfaceSettings(IntPtr InterfaceHandle, Byte AlternateInterfaceNumber, ref USB_INTERFACE_DESCRIPTOR UsbAltInterfaceDescriptor);
/// <summary> /// Initializes a device interface and obtains information about it. /// </summary> /// /// <returns> True on success. </returns> internal Boolean InitializeDevice() { WINUSB_PIPE_INFORMATION pipeInfo = new WINUSB_PIPE_INFORMATION(); Boolean success; usbInterfaceDescriptor = default(USB_INTERFACE_DESCRIPTOR); try { // Let's try to initialize the device. If it works we can access the devica via winUsbHandle success = WinUsb_Initialize(devInfo.deviceHandle, ref devInfo.winUsbHandle); if (success) { // Lets request an interface descriptor. success = WinUsb_QueryInterfaceSettings(devInfo.winUsbHandle, 0, ref usbInterfaceDescriptor); if (success) { // For each endpoint we can query the pipe to learn the endpoint's transfer type & direction and save it to devInfo. for (Int32 i = 0; i <= (usbInterfaceDescriptor.bNumEndpoints - 1); i++) { WinUsb_QueryPipe(devInfo.winUsbHandle, 0, System.Convert.ToByte(i), ref pipeInfo); if (((pipeInfo.PipeType == USBD_PIPE_TYPE.UsbdPipeTypeBulk) & UsbEndpointDirectionIn(pipeInfo.PipeId))) { devInfo.bulkInPipe = pipeInfo.PipeId; SetPipePolicy(devInfo.bulkInPipe, Convert.ToUInt32(POLICY_TYPE.SHORT_PACKET_TERMINATE), Convert.ToByte(false)); SetPipePolicy(devInfo.bulkInPipe, Convert.ToUInt32(POLICY_TYPE.AUTO_CLEAR_STALL), Convert.ToByte(false)); SetPipePolicy(devInfo.bulkInPipe, Convert.ToUInt32(POLICY_TYPE.PIPE_TRANSFER_TIMEOUT), Convert.ToUInt32(pipeTimeout)); SetPipePolicy(devInfo.bulkInPipe, Convert.ToUInt32(POLICY_TYPE.IGNORE_SHORT_PACKETS), Convert.ToByte(false)); SetPipePolicy(devInfo.bulkInPipe, Convert.ToUInt32(POLICY_TYPE.ALLOW_PARTIAL_READS), Convert.ToByte(true)); SetPipePolicy(devInfo.bulkInPipe, Convert.ToUInt32(POLICY_TYPE.AUTO_FLUSH), Convert.ToByte(false)); SetPipePolicy(devInfo.bulkInPipe, Convert.ToUInt32(POLICY_TYPE.RAW_IO), Convert.ToByte(false)); SetPipePolicy(devInfo.bulkInPipe, Convert.ToUInt32(POLICY_TYPE.RESET_PIPE_ON_RESUME), Convert.ToByte(false)); } else if (((pipeInfo.PipeType == USBD_PIPE_TYPE.UsbdPipeTypeBulk) & UsbEndpointDirectionOut(pipeInfo.PipeId))) { devInfo.bulkOutPipe = pipeInfo.PipeId; SetPipePolicy(devInfo.bulkOutPipe, Convert.ToUInt32(POLICY_TYPE.SHORT_PACKET_TERMINATE), Convert.ToByte(false)); SetPipePolicy(devInfo.bulkOutPipe, Convert.ToUInt32(POLICY_TYPE.AUTO_CLEAR_STALL), Convert.ToByte(false)); SetPipePolicy(devInfo.bulkOutPipe, Convert.ToUInt32(POLICY_TYPE.PIPE_TRANSFER_TIMEOUT), Convert.ToUInt32(pipeTimeout)); SetPipePolicy(devInfo.bulkOutPipe, Convert.ToUInt32(POLICY_TYPE.IGNORE_SHORT_PACKETS), Convert.ToByte(false)); SetPipePolicy(devInfo.bulkOutPipe, Convert.ToUInt32(POLICY_TYPE.ALLOW_PARTIAL_READS), Convert.ToByte(true)); SetPipePolicy(devInfo.bulkOutPipe, Convert.ToUInt32(POLICY_TYPE.AUTO_FLUSH), Convert.ToByte(false)); SetPipePolicy(devInfo.bulkOutPipe, Convert.ToUInt32(POLICY_TYPE.RAW_IO), Convert.ToByte(false)); SetPipePolicy(devInfo.bulkOutPipe, Convert.ToUInt32(POLICY_TYPE.RESET_PIPE_ON_RESUME), Convert.ToByte(false)); } else if ((pipeInfo.PipeType == USBD_PIPE_TYPE.UsbdPipeTypeInterrupt) & UsbEndpointDirectionIn(pipeInfo.PipeId)) { devInfo.interruptInPipe = pipeInfo.PipeId; SetPipePolicy(devInfo.interruptInPipe, Convert.ToUInt32(POLICY_TYPE.SHORT_PACKET_TERMINATE), Convert.ToByte(false)); SetPipePolicy(devInfo.interruptInPipe, Convert.ToUInt32(POLICY_TYPE.AUTO_CLEAR_STALL), Convert.ToByte(false)); SetPipePolicy(devInfo.interruptInPipe, Convert.ToUInt32(POLICY_TYPE.PIPE_TRANSFER_TIMEOUT), Convert.ToUInt32(pipeTimeout)); SetPipePolicy(devInfo.interruptInPipe, Convert.ToUInt32(POLICY_TYPE.IGNORE_SHORT_PACKETS), Convert.ToByte(false)); SetPipePolicy(devInfo.interruptInPipe, Convert.ToUInt32(POLICY_TYPE.ALLOW_PARTIAL_READS), Convert.ToByte(true)); SetPipePolicy(devInfo.interruptInPipe, Convert.ToUInt32(POLICY_TYPE.AUTO_FLUSH), Convert.ToByte(false)); SetPipePolicy(devInfo.interruptInPipe, Convert.ToUInt32(POLICY_TYPE.RAW_IO), Convert.ToByte(false)); SetPipePolicy(devInfo.interruptInPipe, Convert.ToUInt32(POLICY_TYPE.RESET_PIPE_ON_RESUME), Convert.ToByte(false)); } else if ((pipeInfo.PipeType == USBD_PIPE_TYPE.UsbdPipeTypeInterrupt) & UsbEndpointDirectionOut(pipeInfo.PipeId)) { devInfo.interruptOutPipe = pipeInfo.PipeId; SetPipePolicy(devInfo.interruptOutPipe, Convert.ToUInt32(POLICY_TYPE.SHORT_PACKET_TERMINATE), Convert.ToByte(false)); SetPipePolicy(devInfo.interruptOutPipe, Convert.ToUInt32(POLICY_TYPE.AUTO_CLEAR_STALL), Convert.ToByte(false)); SetPipePolicy(devInfo.interruptOutPipe, Convert.ToUInt32(POLICY_TYPE.PIPE_TRANSFER_TIMEOUT), Convert.ToUInt32(pipeTimeout)); SetPipePolicy(devInfo.interruptOutPipe, Convert.ToUInt32(POLICY_TYPE.IGNORE_SHORT_PACKETS), Convert.ToByte(false)); SetPipePolicy(devInfo.interruptOutPipe, Convert.ToUInt32(POLICY_TYPE.PIPE_TRANSFER_TIMEOUT), Convert.ToByte(true)); SetPipePolicy(devInfo.interruptOutPipe, Convert.ToUInt32(POLICY_TYPE.AUTO_FLUSH), Convert.ToByte(false)); SetPipePolicy(devInfo.interruptOutPipe, Convert.ToUInt32(POLICY_TYPE.RAW_IO), Convert.ToByte(false)); SetPipePolicy(devInfo.interruptOutPipe, Convert.ToUInt32(POLICY_TYPE.RESET_PIPE_ON_RESUME), Convert.ToByte(false)); } } } } } catch (Exception) { throw; } return success; }