Esempio n. 1
0
        private bool Connect(string port, int timeout)
        {
            bool conn = _lib.Open(port, timeout);

            if (conn)
            {
                WriteLog("Connected succesfully to CEC-adapter on port: " + port);
                _audiosystem = _lib.IsActiveDevice(CecLogicalAddress.AudioSystem);

                if (_extensiveLogging)
                {
                    WriteLog("TV vendor: " + _lib.GetDeviceVendorId(CecLogicalAddress.Tv).ToString());
                    WriteLog("AVR connected: " + _audiosystem.ToString() + " vendor: "
                             + _lib.GetDeviceVendorId(CecLogicalAddress.AudioSystem));
                }
            }
            else
            {
                WriteLog("Connection to adapter on port: " + port + " failed");
            }

            return(conn);
        }
Esempio n. 2
0
        public void Scan()
        {
            StringBuilder output = new StringBuilder();

            output.AppendLine("CEC bus information");
            output.AppendLine("===================");
            CecLogicalAddresses addresses = Lib.GetActiveDevices();

            for (int iPtr = 0; iPtr < addresses.Addresses.Length; iPtr++)
            {
                CecLogicalAddress address = (CecLogicalAddress)iPtr;
                if (!addresses.IsSet(address))
                {
                    continue;
                }

                CecVendorId    iVendorId        = Lib.GetDeviceVendorId(address);
                bool           bActive          = Lib.IsActiveDevice(address);
                ushort         iPhysicalAddress = Lib.GetDevicePhysicalAddress(address);
                string         strAddr          = Lib.PhysicalAddressToString(iPhysicalAddress);
                CecVersion     iCecVersion      = Lib.GetDeviceCecVersion(address);
                CecPowerStatus power            = Lib.GetDevicePowerStatus(address);
                string         osdName          = Lib.GetDeviceOSDName(address);
                string         lang             = Lib.GetDeviceMenuLanguage(address);

                output.AppendLine("device #" + iPtr + ": " + Lib.ToString(address));
                output.AppendLine("address:       " + strAddr);
                output.AppendLine("active source: " + (bActive ? "yes" : "no"));
                output.AppendLine("vendor:        " + Lib.ToString(iVendorId));
                output.AppendLine("osd string:    " + osdName);
                output.AppendLine("CEC version:   " + Lib.ToString(iCecVersion));
                output.AppendLine("power status:  " + Lib.ToString(power));
                if (!string.IsNullOrEmpty(lang))
                {
                    output.AppendLine("language:      " + lang);
                }
                output.AppendLine("");
            }
            Debug.WriteLine(output.ToString());
        }