internal static bool GetDeviceDescriptor(UsbDevice usbDevice, out UsbDeviceDescriptor deviceDescriptor) { if (usbDevice.mCachedDeviceDescriptor != null) { deviceDescriptor = usbDevice.mCachedDeviceDescriptor; return(true); } deviceDescriptor = new UsbDeviceDescriptor(); GCHandle gcDeviceDescriptor = GCHandle.Alloc(deviceDescriptor, GCHandleType.Pinned); int ret; bool bSuccess = usbDevice.GetDescriptor((byte)DescriptorType.Device, 0, 0, gcDeviceDescriptor.AddrOfPinnedObject(), UsbDeviceDescriptor.Size, out ret); gcDeviceDescriptor.Free(); if (bSuccess) { return(true); } return(false); }
public LinuxDevItem(string deviceFileName, byte busNumber, byte deviceAddress, MonoUsbDeviceDescriptor monoUsbDeviceDescriptor) { DeviceFileName = deviceFileName; BusNumber = busNumber; DeviceAddress = deviceAddress; DeviceDescriptor = new UsbDeviceDescriptor(monoUsbDeviceDescriptor); }
public LinuxDevItem(string deviceFileName, byte busNumber, byte deviceAddress, byte[] fileDescriptor) { DeviceFileName = deviceFileName; BusNumber = busNumber; DeviceAddress = deviceAddress; DeviceDescriptor = new UsbDeviceDescriptor(); GCHandle gcFileDescriptor = GCHandle.Alloc(DeviceDescriptor, GCHandleType.Pinned); Marshal.Copy(fileDescriptor, 0, gcFileDescriptor.AddrOfPinnedObject(), Marshal.SizeOf(DeviceDescriptor)); gcFileDescriptor.Free(); }
/// <summary> /// Initializes a new instance of the <see cref="UsbDeviceFound"/> struct. /// </summary> /// <param name="descriptor"> /// The descriptor. /// </param> internal UsbDeviceFound(UsbDeviceDescriptor descriptor) : this() { this.path = descriptor.DevicePath; this.Information = new HidInformation { HidAttributes = new HidAttributes { ProductId = descriptor.ProductId, VendorId = descriptor.VendorId, }, DevicePath = descriptor.DevicePath }; }
internal UsbDeviceInfo(UsbDevice usbDevice, MonoUsbDeviceDescriptor usbDeviceDescriptor) { mUsbDevice = usbDevice; mDeviceDescriptor = new UsbDeviceDescriptor(); mDeviceDescriptor.BcdDevice = usbDeviceDescriptor.BcdDevice; mDeviceDescriptor.BcdUsb = usbDeviceDescriptor.BcdUsb; mDeviceDescriptor.Class = usbDeviceDescriptor.Class; mDeviceDescriptor.ConfigurationCount = usbDeviceDescriptor.ConfigurationCount; mDeviceDescriptor.DescriptorType = usbDeviceDescriptor.DescriptorType; mDeviceDescriptor.Length = usbDeviceDescriptor.Length; mDeviceDescriptor.ManufacturerStringIndex = usbDeviceDescriptor.ManufacturerStringIndex; mDeviceDescriptor.MaxPacketSize0 = usbDeviceDescriptor.MaxPacketSize0; mDeviceDescriptor.ProductID = usbDeviceDescriptor.ProductID; mDeviceDescriptor.ProductStringIndex = usbDeviceDescriptor.ProductStringIndex; mDeviceDescriptor.Protocol = usbDeviceDescriptor.Protocol; mDeviceDescriptor.SerialStringIndex = usbDeviceDescriptor.SerialStringIndex; mDeviceDescriptor.SubClass = usbDeviceDescriptor.SubClass; mDeviceDescriptor.VendorID = usbDeviceDescriptor.VendorID; }
/// <summary> /// Initializes an instance of FirmwareVersion given the USB device descriptor. /// </summary> /// <param name="bcdVersionNumber"> The USB device descriptor. </param> public FirmwareVersion(UsbDeviceDescriptor bcdVersionNumber) : this(bcdVersionNumber.BcdDevice) { }
internal MonoUsbDevice(ref MonoUsbProfile monoUSBProfile) : base(null, null) { mMonoUSBProfile = monoUSBProfile; mCachedDeviceDescriptor = new UsbDeviceDescriptor(monoUSBProfile.DeviceDescriptor); }
internal DeviceDescriptor(UsbDeviceDescriptor descriptor) { this.descriptor = descriptor ?? throw new ArgumentNullException(nameof(descriptor)); }