From: Lars Op den Kamp Date: Fri, 9 Mar 2012 11:07:10 +0000 (+0100) Subject: cec: fixed the log message when sending a command failed. bugzid: 543 X-Git-Tag: upstream/2.2.0~1^2~31^2~86 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=7a87e02ec121e65ea9039c5c54863c9a44c22de5;p=deb_libcec.git cec: fixed the log message when sending a command failed. bugzid: 543 --- diff --git a/src/lib/adapter/USBCECAdapterCommunication.cpp b/src/lib/adapter/USBCECAdapterCommunication.cpp index 34db7ba..351fa28 100644 --- a/src/lib/adapter/USBCECAdapterCommunication.cpp +++ b/src/lib/adapter/USBCECAdapterCommunication.cpp @@ -844,7 +844,7 @@ bool CUSBCECAdapterCommunication::SendCommand(cec_adapter_messagecode msgCode, C bool bWriteOk = output->state == (output->expectControllerAck ? ADAPTER_MESSAGE_STATE_SENT_ACKED : ADAPTER_MESSAGE_STATE_SENT); if (!bWriteOk) { - CLibCEC::AddLog(CEC_LOG_ERROR, "'%s' failed", output->ToString().c_str()); + CLibCEC::AddLog(CEC_LOG_ERROR, "'%s' failed", CCECAdapterMessage::ToString(msgCode)); delete output; return false; } diff --git a/src/lib/adapter/USBCECAdapterMessage.h b/src/lib/adapter/USBCECAdapterMessage.h index f7cf6f6..4ff920a 100644 --- a/src/lib/adapter/USBCECAdapterMessage.h +++ b/src/lib/adapter/USBCECAdapterMessage.h @@ -109,7 +109,7 @@ namespace CEC } else { - strMsg = MessageCodeAsString(); + strMsg = ToString(Message()); switch (Message()) { @@ -139,140 +139,97 @@ namespace CEC return strMsg; } - CStdString MessageCodeAsString(void) const + static const char *ToString(cec_adapter_messagecode msgCode) { - CStdString strMsg; - switch (Message()) + switch (msgCode) { case MSGCODE_NOTHING: - strMsg = "NOTHING"; - break; + return "NOTHING"; case MSGCODE_PING: - strMsg = "PING"; - break; + return "PING"; case MSGCODE_TIMEOUT_ERROR: - strMsg = "TIMEOUT"; - break; + return "TIMEOUT"; case MSGCODE_HIGH_ERROR: - strMsg = "HIGH_ERROR"; - break; + return "HIGH_ERROR"; case MSGCODE_LOW_ERROR: - strMsg = "LOW_ERROR"; - break; + return "LOW_ERROR"; case MSGCODE_FRAME_START: - strMsg = "FRAME_START"; - break; + return "FRAME_START"; case MSGCODE_FRAME_DATA: - strMsg = "FRAME_DATA"; - break; + return "FRAME_DATA"; case MSGCODE_RECEIVE_FAILED: - strMsg = "RECEIVE_FAILED"; - break; + return "RECEIVE_FAILED"; case MSGCODE_COMMAND_ACCEPTED: - strMsg = "COMMAND_ACCEPTED"; - break; + return "COMMAND_ACCEPTED"; case MSGCODE_COMMAND_REJECTED: - strMsg = "COMMAND_REJECTED"; - break; + return "COMMAND_REJECTED"; case MSGCODE_SET_ACK_MASK: - strMsg = "SET_ACK_MASK"; - break; + return "SET_ACK_MASK"; case MSGCODE_TRANSMIT: - strMsg = "TRANSMIT"; - break; + return "TRANSMIT"; case MSGCODE_TRANSMIT_EOM: - strMsg = "TRANSMIT_EOM"; - break; + return "TRANSMIT_EOM"; case MSGCODE_TRANSMIT_IDLETIME: - strMsg = "TRANSMIT_IDLETIME"; - break; + return "TRANSMIT_IDLETIME"; case MSGCODE_TRANSMIT_ACK_POLARITY: - strMsg = "TRANSMIT_ACK_POLARITY"; - break; + return "TRANSMIT_ACK_POLARITY"; case MSGCODE_TRANSMIT_LINE_TIMEOUT: - strMsg = "TRANSMIT_LINE_TIMEOUT"; - break; + return "TRANSMIT_LINE_TIMEOUT"; case MSGCODE_TRANSMIT_SUCCEEDED: - strMsg = "TRANSMIT_SUCCEEDED"; - break; + return "TRANSMIT_SUCCEEDED"; case MSGCODE_TRANSMIT_FAILED_LINE: - strMsg = "TRANSMIT_FAILED_LINE"; - break; + return "TRANSMIT_FAILED_LINE"; case MSGCODE_TRANSMIT_FAILED_ACK: - strMsg = "TRANSMIT_FAILED_ACK"; - break; + return "TRANSMIT_FAILED_ACK"; case MSGCODE_TRANSMIT_FAILED_TIMEOUT_DATA: - strMsg = "TRANSMIT_FAILED_TIMEOUT_DATA"; - break; + return "TRANSMIT_FAILED_TIMEOUT_DATA"; case MSGCODE_TRANSMIT_FAILED_TIMEOUT_LINE: - strMsg = "TRANSMIT_FAILED_TIMEOUT_LINE"; - break; + return "TRANSMIT_FAILED_TIMEOUT_LINE"; case MSGCODE_FIRMWARE_VERSION: - strMsg = "FIRMWARE_VERSION"; - break; + return "FIRMWARE_VERSION"; case MSGCODE_START_BOOTLOADER: - strMsg = "START_BOOTLOADER"; - break; + return "START_BOOTLOADER"; case MSGCODE_FRAME_EOM: - strMsg = "FRAME_EOM"; - break; + return "FRAME_EOM"; case MSGCODE_FRAME_ACK: - strMsg = "FRAME_ACK"; - break; + return "FRAME_ACK"; case MSGCODE_SET_POWERSTATE: - strMsg = "SET_POWERSTATE"; - break; + return "SET_POWERSTATE"; case MSGCODE_SET_CONTROLLED: - strMsg = "SET_CONTROLLED"; - break; + return "SET_CONTROLLED"; case MSGCODE_GET_AUTO_ENABLED: - strMsg = "GET_AUTO_ENABLED"; - break; + return "GET_AUTO_ENABLED"; case MSGCODE_SET_AUTO_ENABLED: - strMsg = "SET_AUTO_ENABLED"; - break; + return "SET_AUTO_ENABLED"; case MSGCODE_GET_DEFAULT_LOGICAL_ADDRESS: - strMsg = "GET_DEFAULT_LOGICAL_ADDRESS"; - break; + return "GET_DEFAULT_LOGICAL_ADDRESS"; case MSGCODE_SET_DEFAULT_LOGICAL_ADDRESS: - strMsg = "SET_DEFAULT_LOGICAL_ADDRESS"; - break; + return "SET_DEFAULT_LOGICAL_ADDRESS"; case MSGCODE_GET_LOGICAL_ADDRESS_MASK: - strMsg = "GET_LOGICAL_ADDRESS_MASK"; - break; + return "GET_LOGICAL_ADDRESS_MASK"; case MSGCODE_SET_LOGICAL_ADDRESS_MASK: - strMsg = "SET_LOGICAL_ADDRESS_MASK"; - break; + return "SET_LOGICAL_ADDRESS_MASK"; case MSGCODE_GET_PHYSICAL_ADDRESS: - strMsg = "GET_PHYSICAL_ADDRESS"; - break; + return "GET_PHYSICAL_ADDRESS"; case MSGCODE_SET_PHYSICAL_ADDRESS: - strMsg = "SET_PHYSICAL_ADDRESS"; - break; + return "SET_PHYSICAL_ADDRESS"; case MSGCODE_GET_DEVICE_TYPE: - strMsg = "GET_DEVICE_TYPE"; - break; + return "GET_DEVICE_TYPE"; case MSGCODE_SET_DEVICE_TYPE: - strMsg = "SET_DEVICE_TYPE"; - break; + return "SET_DEVICE_TYPE"; case MSGCODE_GET_HDMI_VERSION: - strMsg = "GET_HDMI_VERSION"; - break; + return "GET_HDMI_VERSION"; case MSGCODE_SET_HDMI_VERSION: - strMsg = "SET_HDMI_VERSION"; - break; + return "SET_HDMI_VERSION"; case MSGCODE_GET_OSD_NAME: - strMsg = "GET_OSD_NAME"; - break; + return "GET_OSD_NAME"; case MSGCODE_SET_OSD_NAME: - strMsg = "SET_OSD_NAME"; - break; + return "SET_OSD_NAME"; case MSGCODE_WRITE_EEPROM: - strMsg = "WRITE_EEPROM"; - break; + return "WRITE_EEPROM"; } - return strMsg; + return "unknown"; } uint8_t operator[](uint8_t pos) const