X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Flib%2Fadapter%2FAdapterCommunication.cpp;h=2bbcb0153ba0ec798fe76ff7ee0786abb3760f58;hb=2c7804018856ae3cbfc937b7c9b4cf9b00bc0e8d;hp=05ab9b836dd1f6c7ebea9744bcfb8fc7f238ada8;hpb=b2f0b1abed1a76ec1cf2687924f5c60cab2a5316;p=deb_libcec.git diff --git a/src/lib/adapter/AdapterCommunication.cpp b/src/lib/adapter/AdapterCommunication.cpp index 05ab9b8..2bbcb01 100644 --- a/src/lib/adapter/AdapterCommunication.cpp +++ b/src/lib/adapter/AdapterCommunication.cpp @@ -98,11 +98,15 @@ bool CAdapterCommunication::Open(const char *strPort, uint16_t iBaudRate /* = 38 return false; } - CLibCEC::AddLog(CEC_LOG_DEBUG, "connection opened"); + CLibCEC::AddLog(CEC_LOG_DEBUG, "connection opened, clearing any previous input and waiting for active transmissions to end before starting"); //clear any input bytes - uint8_t buff[1]; - while (m_port->Read(buff, 1, 5) == 1) {} + uint8_t buff[1024]; + while (m_port->Read(buff, 1024, 100) > 0) + { + CLibCEC::AddLog(CEC_LOG_DEBUG, "data received, clearing it"); + Sleep(250); + } if (CreateThread()) { @@ -300,7 +304,7 @@ uint16_t CAdapterCommunication::GetFirmwareVersion(void) CCECAdapterMessage input; if (!Read(input, CEC_DEFAULT_TRANSMIT_WAIT) || input.Message() != MSGCODE_FIRMWARE_VERSION || input.Size() != 3) - CLibCEC::AddLog(CEC_LOG_ERROR, "no or invalid firmware version"); + CLibCEC::AddLog(CEC_LOG_ERROR, "no or invalid firmware version (size = %d, message = %d)", input.Size(), input.Message()); else { m_iFirmwareVersion = (input[1] << 8 | input[2]);