Ejemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="timeout"></param>
        /// <returns></returns>
        public bool Open(int timeout)
        {
            Close();
            CecAdapter[] adapters = iLib.FindAdapters(string.Empty);
            if (adapters.Length > 0)
            {
                Open(adapters[0].ComPort, timeout);
            }
            else
            {
                Trace.WriteLine("CEC did not find any adapters");
            }

            return(iConnected);
        }
Ejemplo n.º 2
0
 public bool Connect(int timeout)
 {
     CecAdapter[] adapters = Lib.FindAdapters(string.Empty);
     if (adapters.Length > 0)
     {
         return(Connect(adapters[0].ComPort, timeout));
     }
     else
     {
         return(false);
     }
 }
Ejemplo n.º 3
0
        public bool Connect(int timeout)
        {
            var adapters = Lib.FindAdapters(string.Empty);

            if (adapters.Length > 0)
            {
                return(Connect(adapters[0].ComPort, timeout));
            }

            Log("LibCECClient: Did not find any CEC adapters");
            return(false);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Establish a connection to the CEC devices
 /// </summary>
 /// <param name="timeout"></param>
 /// <returns></returns>
 public bool Connect(int timeout)
 {
     CecAdapter[] adapters = CecLib.FindAdapters(string.Empty);
     if (adapters.Length > 0)
     {
         return(Connect(adapters[0].ComPort, timeout));
     }
     else
     {
         //Console.WriteLine("Did not find any CEC adapters");
         return(false);
     }
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Initialize the Cec bus without callback methods (no need)
        /// </summary>
        /// <param name="timeout">Timeout for the connections to the bus. Must be positive</param>
        /// <exception cref="CecException">Unable to initialize Cec Bus or can't find controller</exception>
        /// <exception cref="ArgumentOutOfRangeException">timeout not strictly positive</exception>
        public CecBus(int timeout)
        {
            if (timeout <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(timeout));
            }

            this.timeout = timeout;

            configuration = new LibCECConfiguration();
            configuration.DeviceTypes.Types[0] = CecDeviceType.PlaybackDevice;
            configuration.DeviceName           = Resources.StrCecDeviceName;
            configuration.ClientVersion        = LibCECConfiguration.CurrentVersion;
            configuration.SetCallbacks(this);

            connection = new LibCecSharp(configuration) ?? throw new CecException(Resources.ErrorNoCecBus);
            connection.InitVideoStandalone();

            // Get the controller on the bus
            controller = null;
            CecAdapter[] adapters = connection.FindAdapters(string.Empty);
            if (adapters.Length > 0)
            {
                controller = adapters[controllerId];
            }
            else
            {
                throw new CecException(Resources.ErrorNoCecController);
            }

            // Connection must be openned before going to suspend mode as the SCM stop the thread if we try to open
            // the connection during power event because it's an async operation
            if (!connection.Open(controller.ComPort, timeout))
            {
                throw new CecException(Resources.ErrorNoCecControllerConnection);
            }

            // Register active source of the connection
            connection.SetActiveSource(CecDeviceType.PlaybackDevice);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Opens connection to first available CEC-adapter.
        /// </summary>
        private bool Connect(int timeout = 10000)
        {
            WriteLog("Opening connection to CEC-Adapter...");

            if (_lib == null)
            {
                WriteLog("Unable to connect, library (libCEC) doesn't exist!");
                return(false);
            }

            CecAdapter[] adapters = _lib.FindAdapters(string.Empty);
            if (adapters.Length > 0)
            {
                // We will use the first available adapter
                return(Connect(adapters[0].ComPort, timeout));
            }
            else
            {
                WriteLog("Unable to find free adapter. Adapter not connected or in use by other process?");
                return(false);
            }
        }
Ejemplo n.º 7
0
        public void Start()
        {
            Config = new LibCECConfiguration();
              Config.DeviceTypes.Types[0] = CecDeviceType.RecordingDevice;
              Config.DeviceName = "CEC Tester";
              Config.ClientVersion = CecClientVersion.CurrentVersion;
              Config.SetCallbacks(this);
              LogLevel = (int)CecLogLevel.All;

              Lib = new LibCecSharp(Config);
              Lib.InitVideoStandalone();

              CecAdapter[] adapters = Lib.FindAdapters(string.Empty);
              if (adapters.Length > 0)
              {
            Console.WriteLine("Found CEC adapters");
            Lib.Open(adapters[0].ComPort, 1000);
            this.EnsureActive();
              }
              else
              {
            Console.WriteLine("Did not find any CEC adapters");
              }
        }