Exemplo n.º 1
0
 private void USBPort_USBDeviceRemoved(object sender, UsbClass.UsbDeviceEventArgs e)
 {
     if (!UsbClass.GetUsbDevice(MyDeviceVid, MyDevicePid, ref _listOfUsbList, false))
     {
         //My Device is removed
         _myUsbDeviceConnected = false;
         Disconnect();
     }
 }
Exemplo n.º 2
0
        private const uint MyDevicePid = 0X6001; //FTDI 245R PID

        #region USB
        /// <summary>
        /// Try to connect to the device.
        /// </summary>
        /// <returns>True if success, false otherwise</returns>
        private bool UsbTryMyDeviceConnection()
        {
            uint?      mi             = null;
            const bool bGetSerialPort = true;

            if (UsbClass.GetUsbDevice(MyDeviceVid, MyDevicePid, ref _listOfUsbList, bGetSerialPort, mi))
            {
                Connect();
                return(true);
            }
            else
            {
                Disconnect();
                return(false);
            }
        }