X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Flib%2FCECProcessor.cpp;h=20b63bd7347ad1726d92647de2a80712d73b8751;hb=efed01e1744208de67b6c54799a5c45e87d00406;hp=f1686d64251e0a8074a34d22f1f98bd7b2e0136b;hpb=6c1a84b8ace46872191383eff5c61be3ccf610d4;p=deb_libcec.git diff --git a/src/lib/CECProcessor.cpp b/src/lib/CECProcessor.cpp index f1686d6..20b63bd 100644 --- a/src/lib/CECProcessor.cpp +++ b/src/lib/CECProcessor.cpp @@ -146,47 +146,18 @@ bool CCECProcessor::OpenConnection(const char *strPort, uint16_t iBaudRate, uint uint64_t iNow = GetTimeMs(); uint64_t iTarget = iTimeoutMs > 0 ? iNow + iTimeoutMs : iNow + CEC_DEFAULT_TRANSMIT_WAIT; - unsigned iConnectTry(0), iPingTry(0), iFwVersionTry(0), iControlledTry(0); - bool bConnected(false), bPinged(false), bControlled(false); /* open a new connection */ - while (iNow < iTarget && (bConnected = m_communication->Open(this, iTimeoutMs)) == false) + unsigned iConnectTry(0); + while (iNow < iTarget && (bReturn = m_communication->Open(this, iTimeoutMs)) == false) { CLibCEC::AddLog(CEC_LOG_ERROR, "could not open a connection (try %d)", ++iConnectTry); Sleep(500); iNow = GetTimeMs(); } - /* try to ping the adapter */ - while (bConnected && iNow < iTarget && (bPinged = m_communication->PingAdapter()) == false) - { - CLibCEC::AddLog(CEC_LOG_ERROR, "the adapter did not respond correctly to a ping (try %d)", ++iPingTry); - Sleep(500); - iNow = GetTimeMs(); - } - - /* try to read the firmware version */ - uint16_t iFirmwareVersion(CEC_FW_VERSION_UNKNOWN); - while (bPinged && iNow < iTarget && (iFirmwareVersion = m_communication->GetFirmwareVersion()) == CEC_FW_VERSION_UNKNOWN) - { - CLibCEC::AddLog(CEC_LOG_ERROR, "the adapter did not respond with a correct firmware version (try %d)", ++iFwVersionTry); - Sleep(500); - iNow = GetTimeMs(); - } - - if (iFirmwareVersion >= 2) - { - /* try to set controlled mode */ - while (bConnected && iNow < iTarget && (bControlled = m_communication->SetControlledMode(true)) == false) - { - CLibCEC::AddLog(CEC_LOG_ERROR, "the adapter did not respond correctly to setting controlled mode (try %d)", ++iControlledTry); - Sleep(500); - iNow = GetTimeMs(); - } - } - - if ((bReturn = iFirmwareVersion != CEC_FW_VERSION_UNKNOWN) == true) - CLibCEC::AddLog(CEC_LOG_NOTICE, "connected to the CEC adapter. firmware version = %d", iFirmwareVersion); + if (bReturn) + CLibCEC::AddLog(CEC_LOG_NOTICE, "connected to the CEC adapter. firmware version = %d", m_communication->GetFirmwareVersion()); return bReturn; }