{
{
CLockObject lock(m_mutex);
- ReadFromDevice(5);
bCommandReceived = m_callback && Read(command, 0) && m_bInitialised;
}
return false;
}
-bool CUSBCECAdapterCommunication::Read(CCECAdapterMessage &msg, uint32_t iTimeout)
+bool CUSBCECAdapterCommunication::Read(CCECAdapterMessage &msg, uint32_t iTimeout, size_t iLen)
{
CLockObject lock(m_mutex);
+ ReadFromDevice(iTimeout, iLen);
msg.Clear();
CCECAdapterMessage *buf(NULL);
while (!bTransmitSucceeded && !bError && iNow < iTargetTime)
{
- ReadFromDevice(50);
CCECAdapterMessage msg;
- if (!Read(msg, 0))
+ if (!Read(msg, 50))
{
iNow = GetTimeMs();
continue;
return retVal;
}
- ReadFromDevice(CEC_DEFAULT_TRANSMIT_WAIT, iResponseLength + 3 /* start + msgcode + iResponseLength + end */);
CCECAdapterMessage input;
- if (Read(input, 0))
+ if (Read(input, CEC_DEFAULT_TRANSMIT_WAIT, iResponseLength + 3 /* start + msgcode + iResponseLength + end */))
{
if (input.Message() != msgCode)
CLibCEC::AddLog(CEC_LOG_ERROR, "invalid response to %s received (%s)", CCECAdapterMessage::ToString(msgCode), CCECAdapterMessage::ToString(input.Message()));
bool CheckAdapter(uint32_t iTimeoutMs = 10000);
bool Write(CCECAdapterMessage *data);
- bool Read(CCECAdapterMessage &msg, uint32_t iTimeout = 1000);
+ bool Read(CCECAdapterMessage &msg, uint32_t iTimeout = 1000, size_t iLen = 64);
bool ParseMessage(const CCECAdapterMessage &msg);
void SendMessageToAdapter(CCECAdapterMessage *msg);
void AddData(uint8_t *data, size_t iLen);