예제 #1
0
 public bool TryConnect()
 {
     _disconnecting = false;
     if (_connecting)
     {
         return(true);
     }
     _connecting = true;
     try
     {
         DeviceInterface deviceInterface = FindDevice();
         if (deviceInterface == null)
         {
             return(false);
         }
         Thread.Sleep(500);
         _deviceInterfaceFile = deviceInterface.OpenFile(PacketSize);
         var caps = _deviceInterfaceFile.Capabilities;
         _log.Debug("InputReportByteLength: " + caps.InputReportByteLength);
         _log.Debug("OutputReportByteLength: " + caps.NumberOutputDataIndices);
         _log.Debug("OutputReportByteLength: " + caps.OutputReportByteLength);
         BeginAsyncRead();
         ReadDeviceInfo();
         ReadAudioPatterns();
         ReadLedPatterns();
         OnConnected();
         return(true);
     }
     finally
     {
         _connecting = false;
     }
 }