fixed - message response signaling and logging
authorLars Op den Kamp <lars@opdenkamp.eu>
Wed, 3 Oct 2012 15:33:58 +0000 (17:33 +0200)
committerLars Op den Kamp <lars@opdenkamp.eu>
Wed, 3 Oct 2012 15:34:25 +0000 (17:34 +0200)
src/lib/CECProcessor.cpp
src/lib/adapter/Pulse-Eight/USBCECAdapterMessage.cpp
src/lib/adapter/Pulse-Eight/USBCECAdapterMessageQueue.cpp

index 4ae1efeef343291b51425dab8a1f9ceb8585dbc4..409b30b1cdde68d6f4ff79304a9fecc32a7d1316 100644 (file)
@@ -438,7 +438,7 @@ bool CCECProcessor::Transmit(const cec_command &data, bool bIsReply)
   }
 
   return bIsReply ?
-      adapterState != ADAPTER_MESSAGE_STATE_ERROR :
+      adapterState == ADAPTER_MESSAGE_STATE_SENT_ACKED || adapterState == ADAPTER_MESSAGE_STATE_SENT || adapterState == ADAPTER_MESSAGE_STATE_WAITING_TO_BE_SENT :
       adapterState == ADAPTER_MESSAGE_STATE_SENT_ACKED;
 }
 
index f5d07359f28d8f32c97567384c71748d28809522..5756283a60d883acddd2bd05a4d2d4201d29c56b 100644 (file)
@@ -174,7 +174,7 @@ const char *CCECAdapterMessage::ToString(cec_adapter_messagecode msgCode)
   case MSGCODE_TRANSMIT_IDLETIME:
     return "TRANSMIT_IDLETIME";
   case MSGCODE_TRANSMIT_ACK_POLARITY:
-    return "TRANSMIT_ACK_POLARITY";
+    return "CEC transmission";
   case MSGCODE_TRANSMIT_LINE_TIMEOUT:
     return "TRANSMIT_LINE_TIMEOUT";
   case MSGCODE_TRANSMIT_SUCCEEDED:
index a4924b8960c4fa8ad1b75af672cb9cabc7446eb7..77f93c71d98287bc1b011c6acfbd9e8a3939dca3 100644 (file)
@@ -134,6 +134,9 @@ bool CCECAdapterMessageQueueEntry::IsResponseOld(const CCECAdapterMessage &msg)
 
 bool CCECAdapterMessageQueueEntry::IsResponse(const CCECAdapterMessage &msg)
 {
+  if (m_message->state == ADAPTER_MESSAGE_STATE_SENT_ACKED)
+    return false;
+
   cec_adapter_messagecode thisMsgCode = m_message->Message();
   cec_adapter_messagecode msgCode = msg.Message();
   cec_adapter_messagecode msgResponse = msg.ResponseTo();
@@ -231,7 +234,7 @@ bool CCECAdapterMessageQueueEntry::MessageReceivedTransmitSucceeded(const CCECAd
     if (m_iPacketsLeft == 0)
     {
       /* transmission succeeded, so we're done */
-      m_queue->m_com->m_callback->GetLib()->AddLog(CEC_LOG_DEBUG, "%s - transmit succeeded", ToString());
+      m_queue->m_com->m_callback->GetLib()->AddLog(CEC_LOG_DEBUG, "%s - transmit succeeded", m_message->ToString().c_str());
       m_message->state = ADAPTER_MESSAGE_STATE_SENT_ACKED;
       m_message->response = message.packet;
     }
@@ -337,12 +340,7 @@ void CCECAdapterMessageQueue::CheckTimedOutMessages(void)
     {
       timedOut.push_back(it->first);
       if (!it->second->m_bSucceeded)
-      {
-        if (it->second->m_message->IsTranmission())
-          m_com->m_callback->GetLib()->AddLog(CEC_LOG_DEBUG, "transmission '%s' was not acked by the controller", it->second->m_message->ToString().c_str());
-        else
-          m_com->m_callback->GetLib()->AddLog(CEC_LOG_DEBUG, "command '%s' was not acked by the controller", CCECAdapterMessage::ToString(it->second->m_message->Message()));
-      }
+        m_com->m_callback->GetLib()->AddLog(CEC_LOG_DEBUG, "command '%s' was not acked by the controller", CCECAdapterMessage::ToString(it->second->m_message->Message()));
       delete it->second->m_message;
       delete it->second;
     }
@@ -441,10 +439,7 @@ bool CCECAdapterMessageQueue::Write(CCECAdapterMessage *msg)
   {
     if (!entry->Wait(msg->transmit_timeout <= 5 ? CEC_DEFAULT_TRANSMIT_WAIT : msg->transmit_timeout))
     {
-      if (msg->IsTranmission())
-        m_com->m_callback->GetLib()->AddLog(CEC_LOG_DEBUG, "transmission '%s' was not acked by the controller", msg->ToString().c_str());
-      else
-        m_com->m_callback->GetLib()->AddLog(CEC_LOG_DEBUG, "command '%s' was not acked by the controller", CCECAdapterMessage::ToString(msg->Message()));
+      m_com->m_callback->GetLib()->AddLog(CEC_LOG_DEBUG, "command '%s' was not acked by the controller", CCECAdapterMessage::ToString(msg->Message()));
       msg->state = ADAPTER_MESSAGE_STATE_SENT_NOT_ACKED;
       bReturn = false;
     }