namespace CEC {
#endif
#define CEC_MIN_VERSION 2
- #define CEC_LIB_VERSION 2
+ #define CEC_LIB_VERSION 3
#define CEC_SETTLE_DOWN_TIME 1000
typedef std::vector<uint8_t> cec_frame;
* @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.
- * @param iTimeout Timeout if the message could not be sent for this amount of ms. Does not influence the timeout of the wait for the ACK message. That timeout is specified by the CEC standard.
* @return True when the data was sent and acked, false otherwise.
*/
#ifdef __cplusplus
-extern DECLSPEC bool cec_transmit(const CEC::cec_frame &data, bool bWaitForAck = true, int64_t iTimeout = (int64_t) 5000);
+extern DECLSPEC bool cec_transmit(const CEC::cec_frame &data, bool bWaitForAck = true);
#else
-extern DECLSPEC bool cec_transmit(const cec_frame &data, bool bWaitForAck = true, int64_t iTimeout = (int64_t) 5000);
+extern DECLSPEC bool cec_transmit(const cec_frame &data, bool bWaitForAck = true);
#endif
/*!
/*!
* @see cec_transmit
*/
- virtual bool Transmit(const cec_frame &data, bool bWaitForAck = true, int64_t iTimeout = (int64_t) 5000) = 0;
+ virtual bool Transmit(const cec_frame &data, bool bWaitForAck = true) = 0;
/*!
* @see cec_set_logical_address
using namespace std;
#define CEC_MAX_RETRY 5
+#define CEC_BUTTON_TIMEOUT 500
/*!
* ICECDevice implementation
while (m_bRunning)
{
cec_frame msg;
- while (m_bRunning && m_communication->IsOpen() && m_communication->Read(msg, 500))
+ while (m_bRunning && m_communication->IsOpen() && m_communication->Read(msg, CEC_BUTTON_TIMEOUT))
ParseMessage(msg);
now = GetTimeMs();
PushEscaped(output, MSGCODE_PING);
output.push_back(MSGEND);
- if (!TransmitFormatted(output, false, (int64_t) 5000))
+ if (!TransmitFormatted(output, false))
{
AddLog(CEC_LOG_ERROR, "could not send ping command");
return false;
PushEscaped(output, MSGCODE_START_BOOTLOADER);
output.push_back(MSGEND);
- if (!TransmitFormatted(output, false, (int64_t) 5000))
+ if (!TransmitFormatted(output, false))
{
AddLog(CEC_LOG_ERROR, "could not start the bootloader");
return false;
Transmit(frame);
}
-bool CCECParser::TransmitFormatted(const cec_frame &data, bool bWaitForAck /* = true */, int64_t iTimeout /* = 2000 */)
+bool CCECParser::TransmitFormatted(const cec_frame &data, bool bWaitForAck /* = true */)
{
if (!m_communication || m_communication->Write(data) != data.size())
return false;
return true;
}
-bool CCECParser::Transmit(const cec_frame &data, bool bWaitForAck /* = true */, int64_t iTimeout /* = 5000 */)
+bool CCECParser::Transmit(const cec_frame &data, bool bWaitForAck /* = true */)
{
CStdString txStr = "transmit ";
for (unsigned int i = 0; i < data.size(); i++)
output.push_back(MSGEND);
}
- return TransmitFormatted(output, bWaitForAck, iTimeout);
+ return TransmitFormatted(output, bWaitForAck);
}
-bool CCECParser::WaitForAck(int64_t iTimeout /* = 1000 */)
+bool CCECParser::WaitForAck(int iTimeout /* = 1000 */)
{
bool bGotAck(false);
bool bError(false);
int64_t iNow = GetTimeMs();
- int64_t iTargetTime = iNow + iTimeout;
+ int64_t iTargetTime = iNow + (int64_t) iTimeout;
while (!bGotAck && !bError && (iTimeout <= 0 || iNow < iTargetTime))
{
void CCECParser::CheckKeypressTimeout(int64_t now)
{
- if (m_iCurrentButton != CEC_USER_CONTROL_CODE_UNKNOWN && now - m_buttontime > 500)
+ if (m_iCurrentButton != CEC_USER_CONTROL_CODE_UNKNOWN && now - m_buttontime > CEC_BUTTON_TIMEOUT)
{
AddKey();
m_iCurrentButton = CEC_USER_CONTROL_CODE_UNKNOWN;
virtual bool GetNextLogMessage(cec_log_message *message);
virtual bool GetNextKeypress(cec_keypress *key);
virtual bool GetNextCommand(cec_command *command);
- virtual bool Transmit(const cec_frame &data, bool bWaitForAck = true, int64_t iTimeout = (int64_t) 5000);
+ virtual bool Transmit(const cec_frame &data, bool bWaitForAck = true);
virtual bool SetLogicalAddress(cec_logical_address iLogicalAddress);
virtual bool SetAckMask(uint16_t iMask);
virtual int GetMinVersion(void);
bool Process(void);
void AddLog(cec_log_level level, const std::string &strMessage);
protected:
- virtual bool TransmitFormatted(const cec_frame &data, bool bWaitForAck = true, int64_t iTimeout = (int64_t) 2000);
+ virtual bool TransmitFormatted(const cec_frame &data, bool bWaitForAck = true);
virtual void TransmitAbort(cec_logical_address address, cec_opcode opcode, ECecAbortReason reason = CEC_ABORT_REASON_UNRECOGNIZED_OPCODE);
virtual void ReportCECVersion(cec_logical_address address = CECDEVICE_TV);
virtual void ReportPowerState(cec_logical_address address = CECDEVICE_TV, bool bOn = true);
private:
void AddKey(void);
void AddCommand(cec_logical_address source, cec_logical_address destination, cec_opcode opcode, cec_frame *parameters);
- bool WaitForAck(int64_t iTimeout = (int64_t) 1000);
+ bool WaitForAck(int iTimeout = 1000);
bool ReadFromDevice(int iTimeout);
void ProcessMessages(void);
bool GetMessage(cec_frame &msg, bool bFromBuffer = true);
return false;
}
-bool cec_transmit(const CEC::cec_frame &data, bool bWaitForAck /* = true */, int64_t iTimeout /* = 2000 */)
+bool cec_transmit(const CEC::cec_frame &data, bool bWaitForAck /* = true */)
{
if (cec_parser)
- return cec_parser->Transmit(data, bWaitForAck, iTimeout);
+ return cec_parser->Transmit(data, bWaitForAck);
return false;
}
using namespace CEC;
using namespace std;
-#define CEC_TEST_CLIENT_VERSION 2
+#define CEC_TEST_CLIENT_VERSION 3
void flush_log(ICECDevice *cecParser)
{