From: Lars Op den Kamp Date: Mon, 31 Oct 2011 19:47:19 +0000 (+0100) Subject: cec: renamed WaitForAck() to WaitForTransmitSucceeded(), because it waits for the... X-Git-Tag: upstream/2.2.0~1^2~150 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=1f0e9e0fb3ddfaf84650867e55e645cda7868e06;p=deb_libcec.git cec: renamed WaitForAck() to WaitForTransmitSucceeded(), because it waits for the TRANSMISSION_SUCCEEDED message, not for an ack from the CEC device. we'll add that later --- diff --git a/include/cectypes.h b/include/cectypes.h index df9af81..afd5b16 100644 --- a/include/cectypes.h +++ b/include/cectypes.h @@ -642,17 +642,16 @@ typedef struct cec_command cec_opcode opcode; cec_datapacket parameters; int8_t opcode_set; - int32_t ack_timeout; + int32_t transmit_timeout; #ifdef __cplusplus static void format(cec_command &command, cec_logical_address initiator, cec_logical_address destination, cec_opcode opcode) { command.clear(); - command.initiator = initiator; - command.destination = destination; - command.opcode = opcode; - command.opcode_set = 1; - command.ack_timeout = 1000; + command.initiator = initiator; + command.destination = destination; + command.opcode = opcode; + command.opcode_set = 1; } void push_back(uint8_t data) @@ -673,13 +672,13 @@ typedef struct cec_command void clear(void) { - initiator = CECDEVICE_UNKNOWN; - destination = CECDEVICE_UNKNOWN; - ack = 0; - eom = 0; - opcode_set = 0; - opcode = CEC_OPCODE_FEATURE_ABORT; - ack_timeout = 1000; + initiator = CECDEVICE_UNKNOWN; + destination = CECDEVICE_UNKNOWN; + ack = 0; + eom = 0; + opcode_set = 0; + opcode = CEC_OPCODE_FEATURE_ABORT; + transmit_timeout = 1000; parameters.clear(); }; #endif diff --git a/src/lib/CECProcessor.cpp b/src/lib/CECProcessor.cpp index 19984f0..3b6f6f2 100644 --- a/src/lib/CECProcessor.cpp +++ b/src/lib/CECProcessor.cpp @@ -259,16 +259,13 @@ bool CCECProcessor::Transmit(const cec_command &data) } } - if (data.ack_timeout > 0) + if (data.transmit_timeout > 0) { - bool bError(false); - if ((bReturn = WaitForAck(&bError, output->size(), data.ack_timeout)) == false) + if ((bReturn = WaitForTransmitSucceeded(output->size(), data.transmit_timeout)) == false) m_controller->AddLog(CEC_LOG_ERROR, "did not receive ack"); } else - { bReturn = true; - } } return bReturn; @@ -286,16 +283,16 @@ void CCECProcessor::TransmitAbort(cec_logical_address address, cec_opcode opcode Transmit(command); } -bool CCECProcessor::WaitForAck(bool *bError, uint8_t iLength, uint32_t iTimeout /* = 1000 */) +bool CCECProcessor::WaitForTransmitSucceeded(uint8_t iLength, uint32_t iTimeout /* = 1000 */) { - bool bTransmitSucceeded = false; + bool bError(false); + bool bTransmitSucceeded(false); uint8_t iPacketsLeft(iLength / 4); - *bError = false; int64_t iNow = GetTimeMs(); int64_t iTargetTime = iNow + (uint64_t) iTimeout; - while (!bTransmitSucceeded && !*bError && (iTimeout == 0 || iNow < iTargetTime)) + while (!bTransmitSucceeded && !bError && (iTimeout == 0 || iNow < iTargetTime)) { CCECAdapterMessage msg; @@ -305,7 +302,7 @@ bool CCECProcessor::WaitForAck(bool *bError, uint8_t iLength, uint32_t iTimeout continue; } - *bError = msg.is_error(); + bError = msg.is_error(); m_controller->AddLog(msg.is_error() ? CEC_LOG_WARNING : CEC_LOG_DEBUG, msg.ToString()); switch(msg.message()) @@ -315,20 +312,20 @@ bool CCECProcessor::WaitForAck(bool *bError, uint8_t iLength, uint32_t iTimeout break; case MSGCODE_TRANSMIT_SUCCEEDED: bTransmitSucceeded = (iPacketsLeft == 0); - *bError = !bTransmitSucceeded; + bError = !bTransmitSucceeded; break; default: CStdString strLog; strLog.Format("received unexpected reply '%1x' instead of ack", msg.message()); m_controller->AddLog(CEC_LOG_WARNING, strLog); - *bError = true; + bError = true; break; } iNow = GetTimeMs(); } - return bTransmitSucceeded && !*bError; + return bTransmitSucceeded && !bError; } bool CCECProcessor::ParseMessage(const CCECAdapterMessage &msg) diff --git a/src/lib/CECProcessor.h b/src/lib/CECProcessor.h index 2d5c312..8569949 100644 --- a/src/lib/CECProcessor.h +++ b/src/lib/CECProcessor.h @@ -81,7 +81,7 @@ namespace CEC private: void LogOutput(const cec_command &data); - bool WaitForAck(bool *bError, uint8_t iLength, uint32_t iTimeout = 1000); + bool WaitForTransmitSucceeded(uint8_t iLength, uint32_t iTimeout = 1000); bool ParseMessage(const CCECAdapterMessage &msg); void ParseCommand(cec_command &command); diff --git a/src/lib/devices/CECBusDevice.cpp b/src/lib/devices/CECBusDevice.cpp index cbd332e..7faa5fb 100644 --- a/src/lib/devices/CECBusDevice.cpp +++ b/src/lib/devices/CECBusDevice.cpp @@ -212,7 +212,6 @@ void CCECBusDevice::PollVendorId(void) cec_command command; cec_command::format(command, GetMyLogicalAddress(), GetLogicalAddress(), CEC_OPCODE_GIVE_DEVICE_VENDOR_ID); - command.ack_timeout = 0; m_processor->Transmit(command); } } diff --git a/src/testclient/main.cpp b/src/testclient/main.cpp index 33cbd88..d30d982 100644 --- a/src/testclient/main.cpp +++ b/src/testclient/main.cpp @@ -200,7 +200,7 @@ void show_console_help(void) "Available commands:" << endl << endl << "tx {bytes} transfer bytes over the CEC line." << endl << - "txn {bytes} transfer bytes and don't wait for an ACK reply." << endl << + "txn {bytes} transfer bytes but don't wait for transmission ACK." << endl << "[tx 40 00 FF 11 22 33] sends bytes 0x40 0x00 0xFF 0x11 0x22 0x33" << endl << endl << "on {address} power on the device with the given logical address." << endl << @@ -421,7 +421,7 @@ int main (int argc, char *argv[]) bytes.push_back(ivalue); if (command == "txn") - bytes.ack_timeout = 0; + bytes.transmit_timeout = 0; parser->Transmit(bytes); }