From: Lars Op den Kamp Date: Sun, 30 Oct 2011 09:44:17 +0000 (+0100) Subject: cec: include the ack timeout in the cec_command struct X-Git-Tag: upstream/2.2.0~1^2~176 X-Git-Url: https://git.piment-noir.org/?p=deb_libcec.git;a=commitdiff_plain;h=8d84e2c0857878d0391aee40190919cf57d689e7 cec: include the ack timeout in the cec_command struct --- diff --git a/include/cec.h b/include/cec.h index 6356455..69f1941 100644 --- a/include/cec.h +++ b/include/cec.h @@ -98,7 +98,7 @@ namespace CEC /*! * @see cec_transmit */ - virtual bool Transmit(const cec_command &data, bool bWaitForAck = true) = 0; + virtual bool Transmit(const cec_command &data) = 0; /*! * @see cec_set_logical_address diff --git a/include/cecc.h b/include/cecc.h index 1c9a987..c069b14 100644 --- a/include/cecc.h +++ b/include/cecc.h @@ -175,13 +175,12 @@ extern DECLSPEC int cec_get_next_command(cec_command *command); /*! * @brief Transmit a frame on the CEC line. * @param data The frame to send. - * @param bWaitForAck Wait for an ACK message for 1 second after this frame has been sent. * @return True when the data was sent and acked, false otherwise. */ #ifdef __cplusplus -extern DECLSPEC int cec_transmit(const CEC::cec_command &data, int bWaitForAck = 1); +extern DECLSPEC int cec_transmit(const CEC::cec_command &data); #else -extern DECLSPEC int cec_transmit(const cec_command &data, int bWaitForAck = 1); +extern DECLSPEC int cec_transmit(const cec_command &data); #endif /*! diff --git a/include/cectypes.h b/include/cectypes.h index c08c64d..7fa70c7 100644 --- a/include/cectypes.h +++ b/include/cectypes.h @@ -634,6 +634,7 @@ typedef struct cec_command cec_opcode opcode; cec_datapacket parameters; int8_t opcode_set; + int32_t ack_timeout; #ifdef __cplusplus static void format(cec_command &command, cec_logical_address initiator, cec_logical_address destination, cec_opcode opcode) @@ -643,6 +644,7 @@ typedef struct cec_command command.destination = destination; command.opcode = opcode; command.opcode_set = 1; + command.ack_timeout = 1000; } void push_back(uint8_t data) @@ -669,6 +671,7 @@ typedef struct cec_command eom = 0; opcode_set = 0; opcode = CEC_OPCODE_FEATURE_ABORT; + ack_timeout = 1000; parameters.clear(); }; #endif diff --git a/src/lib/CECProcessor.cpp b/src/lib/CECProcessor.cpp index 1bc4c59..f763451 100644 --- a/src/lib/CECProcessor.cpp +++ b/src/lib/CECProcessor.cpp @@ -187,7 +187,7 @@ bool CCECProcessor::SwitchMonitoring(bool bEnable) return m_communication && m_communication->SetAckMask(0x1 << (uint8_t)m_iLogicalAddress); } -bool CCECProcessor::Transmit(const cec_command &data, bool bWaitForAck /* = true */) +bool CCECProcessor::Transmit(const cec_command &data) { bool bReturn(false); LogOutput(data); @@ -210,10 +210,10 @@ bool CCECProcessor::Transmit(const cec_command &data, bool bWaitForAck /* = true } } - if (bWaitForAck) + if (data.ack_timeout > 0) { bool bError(false); - if ((bReturn = WaitForAck(&bError, output->size(), 1000)) == false) + if ((bReturn = WaitForAck(&bError, output->size(), data.ack_timeout)) == false) m_controller->AddLog(CEC_LOG_ERROR, "did not receive ack"); } else diff --git a/src/lib/CECProcessor.h b/src/lib/CECProcessor.h index bd616df..0d8a21f 100644 --- a/src/lib/CECProcessor.h +++ b/src/lib/CECProcessor.h @@ -57,7 +57,7 @@ namespace CEC virtual bool SetActiveView(void); virtual bool SetInactiveView(void); - virtual bool Transmit(const cec_command &data, bool bWaitForAck = true); + virtual bool Transmit(const cec_command &data); virtual bool SetLogicalAddress(cec_logical_address iLogicalAddress); virtual bool SetPhysicalAddress(uint16_t iPhysicalAddress); virtual bool SwitchMonitoring(bool bEnable); diff --git a/src/lib/LibCEC.cpp b/src/lib/LibCEC.cpp index ab25290..bf5de8a 100644 --- a/src/lib/LibCEC.cpp +++ b/src/lib/LibCEC.cpp @@ -159,9 +159,9 @@ bool CLibCEC::GetNextCommand(cec_command *command) return m_commandBuffer.Pop(*command); } -bool CLibCEC::Transmit(const cec_command &data, bool bWaitForAck /* = true */) +bool CLibCEC::Transmit(const cec_command &data) { - return m_cec ? m_cec->Transmit(data, bWaitForAck) : false; + return m_cec ? m_cec->Transmit(data) : false; } bool CLibCEC::SetLogicalAddress(cec_logical_address iLogicalAddress) diff --git a/src/lib/LibCEC.h b/src/lib/LibCEC.h index d0147d8..8873ff9 100644 --- a/src/lib/LibCEC.h +++ b/src/lib/LibCEC.h @@ -63,7 +63,7 @@ namespace CEC virtual bool GetNextKeypress(cec_keypress *key); virtual bool GetNextCommand(cec_command *command); - virtual bool Transmit(const cec_command &data, bool bWaitForAck = true); + virtual bool Transmit(const cec_command &data); virtual bool SetLogicalAddress(cec_logical_address iLogicalAddress = CECDEVICE_PLAYBACKDEVICE1); virtual bool SetPhysicalAddress(uint16_t iPhysicalAddress = CEC_DEFAULT_PHYSICAL_ADDRESS); diff --git a/src/lib/LibCECC.cpp b/src/lib/LibCECC.cpp index 7915765..1f8416b 100644 --- a/src/lib/LibCECC.cpp +++ b/src/lib/LibCECC.cpp @@ -124,10 +124,10 @@ int cec_get_next_command(cec_command *command) return -1; } -int cec_transmit(const CEC::cec_command &data, int bWaitForAck /* = true */) +int cec_transmit(const CEC::cec_command &data) { if (cec_parser) - return cec_parser->Transmit(data, bWaitForAck == 1) ? 1 : 0; + return cec_parser->Transmit(data) ? 1 : 0; return -1; } diff --git a/src/lib/devices/CECBusDevice.cpp b/src/lib/devices/CECBusDevice.cpp index 5086e8b..75862b7 100644 --- a/src/lib/devices/CECBusDevice.cpp +++ b/src/lib/devices/CECBusDevice.cpp @@ -139,7 +139,8 @@ void CCECBusDevice::PollVendorId(void) cec_command command; cec_command::format(command, GetMyLogicalAddress(), GetLogicalAddress(), CEC_OPCODE_GIVE_DEVICE_VENDOR_ID); - m_processor->Transmit(command, false); + command.ack_timeout = 0; + m_processor->Transmit(command); } } diff --git a/src/testclient/main.cpp b/src/testclient/main.cpp index 867501d..9cb32bf 100644 --- a/src/testclient/main.cpp +++ b/src/testclient/main.cpp @@ -404,7 +404,10 @@ int main (int argc, char *argv[]) while (GetWord(input, strvalue) && HexStrToInt(strvalue, ivalue)) bytes.push_back(ivalue); - parser->Transmit(bytes, command == "tx"); + if (command == "txn") + bytes.ack_timeout = 0; + + parser->Transmit(bytes); } else if (command == "on") {