public IUsbDevice Create(IUsbNode parentNode) { var driverKeyName = DeviceIoControlInvoker.Invoke( _hubHandle, IOCTL_USB_GET_NODE_CONNECTION_DRIVERKEY_NAME, new USB_NODE_CONNECTION_DRIVERKEY_NAME() { ConnectionIndex = _portNo }).DriverKeyName; var deviceMetaData = EnumerableDeviceMetaData(_targetDevice) .FirstOrDefault(data => data.DriverKeyName == driverKeyName); var usbDevice = new UsbDevice( _portNo, _usbConnectInfomation.DeviceDescriptor.idVendor, _usbConnectInfomation.DeviceDescriptor.idProduct, (UsbSupportSpeed)_usbConnectInfomation.Speed, ConvertUsbDeviceType(_usbConnectInfomation.DeviceDescriptor.bcdUSB), driverKeyName, deviceMetaData?.DevicePath, deviceMetaData?.DeviceDescription, GetSerialNumber(), parentNode); return(_usbConnectInfomation.DeviceDescriptor.bDeviceClass == 0xEF ? CreateUsbDeviceWithMiDevice(usbDevice) : usbDevice); }
internal static IReadOnlyList <IUsbDevice> Create(string hubDevicePath, IUsbNode parentNode) { using (var hubHandle = NativeMethods.CreateFile( hubDevicePath, NativeMethods.GENERIC_WRITE, NativeMethods.FILE_SHARE_WRITE, IntPtr.Zero, NativeMethods.OPEN_EXISTING, 0, IntPtr.Zero)) { return(Create(hubHandle, parentNode)); } }
private static IReadOnlyList <IUsbDevice> Create(SafeFileHandle hubHandle, IUsbNode parentNode) { var nodeInformation = DeviceIoControlInvoker .Invoke(hubHandle, NativeMethods.IOCTL_USB_GET_NODE_INFORMATION, new USB_NODE_INFORMATION { NodeType = 0 }); var usbDevices = new List <IUsbDevice>(); var portNumber = nodeInformation.UsbNodeUnion.HubInformation.HubDescriptor.bNumberOfPorts; for (uint portNo = 1; portNo <= portNumber; portNo++) { var usbDeviceFactory = AbstractUsbDeviceFactory.CreateFactory(hubHandle, portNo); usbDevices.Add(usbDeviceFactory.Create(parentNode)); } return(usbDevices); }
public UsbHub(IUsbDevice usbDevice) { var childDevices = UsbDeviceListFactory.Create(usbDevice.DevicePath, this); PortNumber = childDevices.Count; ConnectedDevices = childDevices.NotOfType(typeof(UnConnectUsbDevice)); PortNo = usbDevice.PortNo; VendorId = usbDevice.VendorId; ProductId = usbDevice.ProductId; SupportSpeed = usbDevice.SupportSpeed; CurrentUsbDevice = usbDevice.CurrentUsbDevice; DeviceKey = usbDevice.DeviceKey; DevicePath = usbDevice.DevicePath; DeviceDescription = usbDevice.DeviceDescription; SerialNumber = usbDevice.SerialNumber; Parent = usbDevice.Parent; }
public UsbDevice( uint portNo, ushort vendorId, ushort productId, UsbSupportSpeed supportSpeed, UsbDeviceType currentUsbDevice, string deviceKey, string devicePath, string fridlyName, string serialNumber, IUsbNode parentNode) { PortNo = portNo; VendorId = vendorId; ProductId = productId; SupportSpeed = supportSpeed; CurrentUsbDevice = currentUsbDevice; Parent = parentNode; DeviceKey = deviceKey; DevicePath = devicePath; DeviceDescription = fridlyName; SerialNumber = serialNumber; }
public UnConnectUsbDevice(uint portNo, IUsbNode parent) { Parent = parent; PortNo = portNo; }
public IUsbDevice Create(IUsbNode parentNode) { var usbDeviceFactory = new UsbDeviceFactory(_hubHandle, _portNo, _usbConnectInfomation, GUID_DEVINTERFACE_USB_HUB); return(new UsbHub(usbDeviceFactory.Create(parentNode))); }
public IUsbDevice Create(IUsbNode parentNode) { return(new UnConnectUsbDevice(_portNo, parentNode)); }