Beispiel #1
0
        internal WinusbAppiDev(USBDeviceInfo di)
        {
            // TODO: Отлавливать исключения WinUsbNet
            try
            {
                Device = new USBDevice(di);
                DevicePath = di.DevicePath;

                ReadPipe = Device.Pipes.First(p => p.IsIn);
                ReadPipe.Policy.PipeTransferTimeout = 100;
                ReadPipe.Policy.AutoClearStall = true;
                ReadPipe.Flush();

                WritePipe = Device.Pipes.First(p => p.IsOut);
                WritePipe.Policy.PipeTransferTimeout = 100;

                lock (OpenedDevicesLocker)
                {
                    OpenedDevices.Add(this);
                }
            }
            catch (USBException e)
            {
                throw new AppiConnectoinException(e);
            }
        }
Beispiel #2
0
 public BackendWinUsb(MadWizard.WinUSBNet.USBDeviceInfo deviceInfo)
 {
     // Vendor page and usage_id = 2
     this.packet_size   = 0x200;
     this.vendor_name   = deviceInfo.Manufacturer;
     this.product_name  = deviceInfo.DeviceDescription.First().ToString();
     this.serial_number = ""; // deviceInfo.;
     this.vid           = (UInt16)deviceInfo.VID;
     this.pid           = (UInt16)deviceInfo.PID;
     this.device_info   = deviceInfo;
     this.deviceOut     = null;
     this.deviceIn      = null;
 }
 public WinusbAppiDeviceSlot(USBDeviceInfo OnUsbDeviceInfo)
 {
     DeviceInfo = OnUsbDeviceInfo;
 }
Beispiel #4
0
 /// <summary>
 /// Constructs a new USB device
 /// </summary>
 /// <param name="deviceInfo">USB device info of the device to create</param>
 public USBDevice(USBDeviceInfo deviceInfo)
     : this(deviceInfo.DevicePath)
 {
     // Handled in other constructor
 }
Beispiel #5
0
        /// <summary>
        /// Finds WinUSB devices with a GUID matching the parameter guid
        /// </summary>
        /// <param name="guid">The GUID that the device should match.</param>
        /// <returns>An array of USBDeviceInfo objects representing the 
        /// devices found. When no devices are found an empty array is 
        /// returned.</returns>
        public static USBDeviceInfo[] GetDevices(Guid guid)
        {
            API.DeviceDetails[] detailList = API.DeviceManagement.FindDevicesFromGuid(guid);

            USBDeviceInfo[] devices = new USBDeviceInfo[detailList.Length];

            for (int i = 0; i < detailList.Length; i++)
            {
                devices[i] = new USBDeviceInfo(detailList[i]);
            }
            return devices;
        }