X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Flib%2FCECProcessor.cpp;h=b305a4a06f2d51db77231840c40de72ba8c48d3b;hb=5ee2ae29d79824f71b011059d23d4b6e04012c1d;hp=1f4678245fe49e699c40fb68771ee7dcdaab8d73;hpb=12a36be9d076db48fc6c13d8edf8cf4ea73fd10d;p=deb_libcec.git diff --git a/src/lib/CECProcessor.cpp b/src/lib/CECProcessor.cpp index 1f46782..b305a4a 100644 --- a/src/lib/CECProcessor.cpp +++ b/src/lib/CECProcessor.cpp @@ -59,7 +59,7 @@ CCECProcessor::CCECProcessor(CLibCEC *controller, libcec_configuration *configur { CreateBusDevices(); m_configuration.Clear(); - m_configuration.serverVersion = configuration->serverVersion; + m_configuration.serverVersion = CEC_SERVER_VERSION_1_6_0; SetConfiguration(configuration); if (m_configuration.tvVendor != CEC_VENDOR_UNKNOWN) @@ -77,7 +77,7 @@ CCECProcessor::CCECProcessor(CLibCEC *controller, const char *strDeviceName, con m_iLastTransmission(0) { m_configuration.Clear(); - m_configuration.serverVersion = CEC_SERVER_VERSION_1_5_2; + m_configuration.serverVersion = CEC_SERVER_VERSION_1_6_0; // client version < 1.5.0 m_configuration.clientVersion = (uint32_t)CEC_CLIENT_VERSION_PRE_1_5; @@ -132,7 +132,10 @@ CCECProcessor::~CCECProcessor(void) Close(); for (unsigned int iPtr = 0; iPtr < 16; iPtr++) + { delete m_busDevices[iPtr]; + m_busDevices[iPtr] = NULL; + } } void CCECProcessor::Close(void) @@ -157,7 +160,7 @@ void CCECProcessor::Close(void) } } -bool CCECProcessor::OpenConnection(const char *strPort, uint16_t iBaudRate, uint32_t iTimeoutMs) +bool CCECProcessor::OpenConnection(const char *strPort, uint16_t iBaudRate, uint32_t iTimeoutMs, bool bStartListening /* = true */) { bool bReturn(false); Close(); @@ -184,7 +187,7 @@ bool CCECProcessor::OpenConnection(const char *strPort, uint16_t iBaudRate, uint /* open a new connection */ unsigned iConnectTry(0); - while (timeout.TimeLeft() > 0 && (bReturn = m_communication->Open(this, (timeout.TimeLeft() / CEC_CONNECT_TRIES))) == false) + while (timeout.TimeLeft() > 0 && (bReturn = m_communication->Open(this, (timeout.TimeLeft() / CEC_CONNECT_TRIES), false, bStartListening)) == false) { CLibCEC::AddLog(CEC_LOG_ERROR, "could not open a connection (try %d)", ++iConnectTry); m_communication->Close(); @@ -192,7 +195,10 @@ bool CCECProcessor::OpenConnection(const char *strPort, uint16_t iBaudRate, uint } if (bReturn) - CLibCEC::AddLog(CEC_LOG_NOTICE, "connected to the CEC adapter. firmware version = %d, client version = %s", m_communication->GetFirmwareVersion(), ToString((cec_client_version)m_configuration.clientVersion)); + { + m_configuration.iFirmwareVersion = m_communication->GetFirmwareVersion(); + CLibCEC::AddLog(CEC_LOG_NOTICE, "connected to the CEC adapter. firmware version = %d, client version = %s", m_configuration.iFirmwareVersion, ToString((cec_client_version)m_configuration.clientVersion)); + } if (m_configuration.bGetSettingsFromROM == 1) m_communication->GetConfiguration(&m_configuration); @@ -892,7 +898,7 @@ bool CCECProcessor::Transmit(const cec_command &data) iMaxTries = m_busDevices[data.initiator]->GetHandler()->GetTransmitRetries() + 1; } - return m_communication->Write(data, iMaxTries, m_iLineTimeout, m_iRetryLineTimeout) + return m_communication->Write(data, iMaxTries, m_iStandardLineTimeout, m_iRetryLineTimeout) == ADAPTER_MESSAGE_STATE_SENT_ACKED; } @@ -912,7 +918,9 @@ void CCECProcessor::TransmitAbort(cec_logical_address address, cec_opcode opcode void CCECProcessor::ParseCommand(const cec_command &command) { CStdString dataStr; - dataStr.Format(">> %1x%1x:%02x", command.initiator, command.destination, command.opcode); + dataStr.Format(">> %1x%1x", command.initiator, command.destination); + if (command.opcode_set == 1) + dataStr.AppendFormat(":%02x", command.opcode); for (uint8_t iPtr = 0; iPtr < command.parameters.size; iPtr++) dataStr.AppendFormat(":%02x", (unsigned int)command.parameters[iPtr]); CLibCEC::AddLog(CEC_LOG_TRAFFIC, dataStr.c_str()); @@ -1378,6 +1386,10 @@ const char *CCECProcessor::ToString(const cec_client_version version) return "1.5.1"; case CEC_CLIENT_VERSION_1_5_2: return "1.5.2"; + case CEC_CLIENT_VERSION_1_5_3: + return "1.5.3"; + case CEC_CLIENT_VERSION_1_6_0: + return "1.6.0"; default: return "Unknown"; } @@ -1395,6 +1407,10 @@ const char *CCECProcessor::ToString(const cec_server_version version) return "1.5.1"; case CEC_SERVER_VERSION_1_5_2: return "1.5.2"; + case CEC_SERVER_VERSION_1_5_3: + return "1.5.3"; + case CEC_SERVER_VERSION_1_6_0: + return "1.6.0"; default: return "Unknown"; } @@ -1479,7 +1495,7 @@ bool CCECProcessor::PingAdapter(void) void CCECProcessor::HandlePoll(cec_logical_address initiator, cec_logical_address destination) { - m_busDevices[initiator]->HandlePoll(destination); + m_busDevices[destination]->HandlePoll(initiator); } bool CCECProcessor::HandleReceiveFailed(cec_logical_address initiator) @@ -1647,6 +1663,10 @@ bool CCECProcessor::GetCurrentConfiguration(libcec_configuration *configuration) if (configuration->clientVersion >= CEC_CLIENT_VERSION_1_5_3) configuration->logicalAddresses = m_configuration.logicalAddresses; + // client version 1.6.0 + if (configuration->clientVersion >= CEC_CLIENT_VERSION_1_5_3) + configuration->logicalAddresses = m_configuration.logicalAddresses; + return true; } @@ -1665,3 +1685,16 @@ void CCECProcessor::RescanActiveDevices(void) for (unsigned int iPtr = 0; iPtr < 16; iPtr++) m_busDevices[iPtr]->GetStatus(true); } + +bool CCECProcessor::GetDeviceInformation(const char *strPort, libcec_configuration *config, uint32_t iTimeoutMs /* = 10000 */) +{ + if (!OpenConnection(strPort, 38400, iTimeoutMs, false)) + return false; + + config->iFirmwareVersion = m_communication->GetFirmwareVersion(); + config->iPhysicalAddress = m_communication->GetPhysicalAddress(); + + delete m_communication; + m_communication = NULL; + return true; +}