p8: match to the response provided by the firmware when checking responses (added...
[deb_libcec.git] / src / lib / adapter / Pulse-Eight / USBCECAdapterMessage.cpp
index f213c1dda81238bac53ccac8a69aa051a70deee3..08e6c358243c70b6ecf2eb7ef8591c32692d297c 100644 (file)
@@ -126,9 +126,14 @@ std::string CCECAdapterMessage::ToString(void) const
         strMsg.AppendFormat(" %02x %s", At(2), IsEOM() ? "eom" : "");
       break;
     default:
-      for (uint8_t iPtr = 2; iPtr < Size(); iPtr++)
-        if (At(iPtr) != MSGEND)
-          strMsg.AppendFormat(" %02x", At(iPtr));
+      if (Size() >= 2 && (Message() == MSGCODE_COMMAND_ACCEPTED || Message() == MSGCODE_COMMAND_REJECTED))
+        strMsg.AppendFormat(": %s", ToString((cec_adapter_messagecode)At(2)));
+      else
+      {
+        for (uint8_t iPtr = 2; iPtr < Size(); iPtr++)
+          if (At(iPtr) != MSGEND)
+            strMsg.AppendFormat(" %02x", At(iPtr));
+      }
       break;
     }
   }
@@ -329,6 +334,13 @@ cec_adapter_messagecode CCECAdapterMessage::Message(void) const
       MSGCODE_NOTHING;
 }
 
+cec_adapter_messagecode CCECAdapterMessage::ResponseTo(void) const
+{
+  return packet.size >= 3 ?
+      (cec_adapter_messagecode) (packet.At(2) & ~(MSGCODE_FRAME_EOM | MSGCODE_FRAME_ACK)) :
+      MSGCODE_NOTHING;
+}
+
 bool CCECAdapterMessage::IsTranmission(void) const
 {
   cec_adapter_messagecode msgCode = Message();