Пример #1
0
        public void Connect()
        {
            Context = new UsbContext();
            Device  = Context.Find(d => VID.Any(vid => d.VendorId == vid) &&
                                   PID.Any(pid => d.ProductId == pid)).Clone();

            if (Device is null)
            {
                throw new Exception("Device isn't connected!");
            }

            Device.Open();
        }
Пример #2
0
        public Switch()
        {
            Console.WriteLine("Connecting to Switch");
            this.LibUsbContext = new UsbContext();
            var usbDeviceCollection = LibUsbContext.List();

            NX = usbDeviceCollection.FirstOrDefault(d => d.ProductId == PID && d.VendorId == VID);

            if (NX == null)
            {
                throw new Exception("Unable to find Switch. Ensure Switch is connected and USB Install is open.");
            }

            NX.Open();
            NX.ClaimInterface(NX.Configs[0].Interfaces[0].Number);

            Writer = NX.OpenEndpointWriter(WriteEndpointID.Ep01);
            Reader = NX.OpenEndpointReader(ReadEndpointID.Ep01);
        }
Пример #3
0
        public void Open()
        {
            if (!Driver.IsOpen)
            {
                Driver.Open();
                IUsbDevice wholeUsbDevice = Driver as IUsbDevice;
                if (wholeUsbDevice is not null)
                {
                    wholeUsbDevice.Open();
                    wholeUsbDevice.SetConfiguration(1);
                    wholeUsbDevice.ClaimInterface(0);
                }
                //Get the first config number of the interface
                Driver.ClaimInterface(Driver.Configs[0].Interfaces[0].Number);
                EndpointWriter = Driver.OpenEndpointWriter(WriteEndpointID.Ep01);
                EndpointReader = Driver.OpenEndpointReader(ReadEndpointID.Ep01);

                DeviceInfo.Manufacturer = Driver.Info.Manufacturer;
                DeviceInfo.Product      = Driver.Info.Product;
                DeviceInfo.SerialNumber = Driver.Info.SerialNumber;
            }
            DeviceInfo.Ready = Driver.IsOpen;
        }
Пример #4
0
 public void Open()
 {
     _device.Open();
 }