コード例 #1
0
        public LinuxDevItem(string deviceFileName, byte busNumber, byte deviceAddress, MonoUsbDeviceDescriptor monoUsbDeviceDescriptor)
        {
            DeviceFileName = deviceFileName;
            BusNumber = busNumber;
            DeviceAddress = deviceAddress;

            DeviceDescriptor = new UsbDeviceDescriptor(monoUsbDeviceDescriptor);
        }
コード例 #2
0
        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();
        }
コード例 #3
0
 /// <summary>
 /// Determines whether the specified <see cref="UsbDeviceDescriptor"/> is equal to the current <see cref="UsbDeviceDescriptor"/>.
 /// </summary>
 /// <returns>
 /// true if the specified <see cref="UsbDeviceDescriptor"/> is equal to the current <see cref="UsbDeviceDescriptor"/>; otherwise, false.
 /// </returns>
 /// <param name="other">The <see cref="UsbDeviceDescriptor"/> to compare with the current <see cref="UsbDeviceDescriptor"/>. </param><exception cref="T:System.NullReferenceException">The <paramref name="other"/> parameter is null.</exception><filterpriority>2</filterpriority>
 public bool Equals(UsbDeviceDescriptor other)
 {
     if (ReferenceEquals(null, other))
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     return(other.BcdUsb == BcdUsb && other.Class == Class && other.SubClass == SubClass && other.Protocol == Protocol &&
            other.MaxPacketSize0 == MaxPacketSize0 && other.VendorID == VendorID && other.ProductID == ProductID &&
            other.BcdDevice == BcdDevice && other.ManufacturerStringIndex == ManufacturerStringIndex &&
            other.ProductStringIndex == ProductStringIndex && other.SerialStringIndex == SerialStringIndex &&
            other.ConfigurationCount == ConfigurationCount);
 }
コード例 #4
0
        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;
        }
コード例 #5
0
 internal LibUsbDevice(ref LibUsbProfile monoUSBProfile)
     : base(null, null)
 {
     mMonoUSBProfile = monoUSBProfile;
     mCachedDeviceDescriptor = new UsbDeviceDescriptor(monoUSBProfile.DeviceDescriptor);
 }
コード例 #6
0
        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;
        }
コード例 #7
0
 /// <summary>
 /// Determines whether the specified <see cref="UsbDeviceDescriptor"/> is equal to the current <see cref="UsbDeviceDescriptor"/>.
 /// </summary>
 /// <returns>
 /// true if the specified <see cref="UsbDeviceDescriptor"/> is equal to the current <see cref="UsbDeviceDescriptor"/>; otherwise, false.
 /// </returns>
 /// <param name="other">The <see cref="UsbDeviceDescriptor"/> to compare with the current <see cref="UsbDeviceDescriptor"/>. </param><exception cref="T:System.NullReferenceException">The <paramref name="other"/> parameter is null.</exception><filterpriority>2</filterpriority>
 public bool Equals(UsbDeviceDescriptor other)
 {
     if (ReferenceEquals(null, other)) return false;
     if (ReferenceEquals(this, other)) return true;
     return other.BcdUsb == BcdUsb && other.Class == Class && other.SubClass == SubClass && other.Protocol == Protocol &&
            other.MaxPacketSize0 == MaxPacketSize0 && other.VendorID == VendorID && other.ProductID == ProductID &&
            other.BcdDevice == BcdDevice && other.ManufacturerStringIndex == ManufacturerStringIndex &&
            other.ProductStringIndex == ProductStringIndex && other.SerialStringIndex == SerialStringIndex &&
            other.ConfigurationCount == ConfigurationCount;
 }