From b5f34cf9fe42a1c12269a6f97db94a2a354cf8cd Mon Sep 17 00:00:00 2001 From: Lars Op den Kamp Date: Tue, 1 Nov 2011 19:39:55 +0100 Subject: [PATCH] cec: pass unexpected replies to ParseMessage() in WaitForTransmitSucceeded(). added some extra sleeps --- src/lib/AdapterCommunication.cpp | 1 + src/lib/CECProcessor.cpp | 11 +++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/lib/AdapterCommunication.cpp b/src/lib/AdapterCommunication.cpp index 122565e..8fc70cd 100644 --- a/src/lib/AdapterCommunication.cpp +++ b/src/lib/AdapterCommunication.cpp @@ -310,6 +310,7 @@ void *CAdapterCommunication::Process(void) while (!IsStopped()) { ReadFromDevice(500); + Sleep(5); WriteNextCommand(); Sleep(5); } diff --git a/src/lib/CECProcessor.cpp b/src/lib/CECProcessor.cpp index 8b8532d..35fb4aa 100644 --- a/src/lib/CECProcessor.cpp +++ b/src/lib/CECProcessor.cpp @@ -115,7 +115,10 @@ void *CCECProcessor::Process(void) { CLockObject lock(&m_mutex); if (m_communication->IsOpen() && m_communication->Read(msg, 50)) + { + m_controller->AddLog(msg.is_error() ? CEC_LOG_WARNING : CEC_LOG_DEBUG, msg.ToString()); bParseFrame = ParseMessage(msg) && !IsStopped(); + } if (bParseFrame) command = m_currentframe; @@ -124,13 +127,14 @@ void *CCECProcessor::Process(void) if (bParseFrame) ParseCommand(command); + Sleep(5); + m_controller->CheckKeypressTimeout(); for (unsigned int iDevicePtr = 0; iDevicePtr < 16; iDevicePtr++) m_busDevices[iDevicePtr]->PollVendorId(); - if (!IsStopped()) - Sleep(5); + Sleep(5); } return NULL; @@ -318,6 +322,7 @@ bool CCECProcessor::WaitForTransmitSucceeded(uint8_t iLength, uint32_t iTimeout CStdString strLog; strLog.Format("received unexpected reply '%s' instead of ack", msg.MessageCodeAsString().c_str()); m_controller->AddLog(CEC_LOG_WARNING, strLog); + ParseMessage(msg); bError = true; break; } @@ -335,8 +340,6 @@ bool CCECProcessor::ParseMessage(const CCECAdapterMessage &msg) if (msg.empty()) return bEom; - m_controller->AddLog(msg.is_error() ? CEC_LOG_WARNING : CEC_LOG_DEBUG, msg.ToString()); - switch(msg.message()) { case MSGCODE_FRAME_START: -- 2.34.1