#define ESCOFFSET 3
#define CEC_MIN_VERSION 6
#define CEC_LIB_VERSION 7
-#define CEC_SETTLE_DOWN_TIME 1500
#define CEC_BUTTON_TIMEOUT 500
#ifdef __cplusplus
uint8_t buff[1024];
m_port->Read(buff, sizeof(buff), 50);
- Sleep(CEC_SETTLE_DOWN_TIME);
-
if (CreateThread())
{
m_controller->AddLog(CEC_LOG_DEBUG, "communication thread created");
return false;
}
- if (!m_comm->Open(strPort, 38400, iTimeoutMs))
+ int64_t iNow = GetTimeMs();
+ int64_t iTarget = iNow + iTimeoutMs;
+
+ bool bOpened(false);
+ while (!bOpened && iNow < iTarget)
+ {
+ bOpened = m_comm->Open(strPort, 38400, iTimeoutMs);
+ iNow = GetTimeMs();
+ }
+
+ if (!bOpened)
{
AddLog(CEC_LOG_ERROR, "could not open a connection");
return false;