Example #1
0
    void Setup()
    {
        if (UsbDev != null)
        {
            return;
        }

        UsbDev = FindDevice();

        if (!UsbDev.SetConfiguration(1))
        {
            throw new M4ATXException("Failed to set device config");
        }

        if (!UsbDev.ClaimInterface(0))
        {
            throw new M4ATXException("Failed to claim interface #0");
        }

        if (!UsbDev.SetAltInterface(0))
        {
            throw new M4ATXException("Failed to set alternate interface to 0");
        }

        Writer = UsbDev.OpenEndpointWriter(WriteEndpointID.Ep01);
        Reader = UsbDev.OpenEndpointReader(ReadEndpointID.Ep01);
    }
Example #2
0
        /// <summary>
        /// Search for and open all Helios Laser DACs connected to the computer.
        /// </summary>
        /// <returns>The number of DACs found.</returns>
        public int OpenDevices()
        {
            CloseDevices();

            foreach (UsbRegistry usbRegistry in UsbDevice.AllLibUsbDevices)
            {
                if (usbRegistry.Pid == HELIOS_PID && usbRegistry.Vid == HELIOS_VID)
                {
                    if (usbRegistry.Open(out UsbDevice dac))
                    {
                        IUsbDevice libUsbDevice = dac as IUsbDevice;
                        libUsbDevice.ClaimInterface(0);
                        libUsbDevice.SetAltInterface(1);
                        dacs.Add(new HeliosDevice(libUsbDevice));
                    }
                }
            }

            return(dacs.Count);
        }
Example #3
0
 public bool SetAltInterface(int alternateID)
 {
     return(_device.SetAltInterface(alternateID));
 }