if (byte >= MSGESC && byte != MSGSTART)
{
push_back(MSGESC);
- push_back(byte - ESCOFFSET);
+ push_back((uint8_t) (byte - ESCOFFSET));
}
else
- push_back(byte);
+ push_back((uint8_t) byte);
}
CAdapterCommunication::CAdapterCommunication(CLibCEC *controller) :
if (CreateThread())
{
- m_controller->AddLog(CEC_LOG_DEBUG, "communication thread created");
+ m_startCondition.Wait(&m_mutex);
+ m_controller->AddLog(CEC_LOG_DEBUG, "communication thread started");
return true;
}
else
void CAdapterCommunication::Close(void)
{
CLockObject lock(&m_mutex);
- StopThread();
-
+ m_startCondition.Broadcast();
m_rcvCondition.Broadcast();
+ StopThread();
}
void *CAdapterCommunication::Process(void)
{
- m_controller->AddLog(CEC_LOG_DEBUG, "communication thread started");
+ {
+ CLockObject lock(&m_mutex);
+ m_startCondition.Signal();
+ }
while (!IsStopped())
{
uint8_t buf = 0;
if (!m_inBuffer.Pop(buf))
{
- if (!m_rcvCondition.Wait(&m_mutex, iTarget - iNow))
+ if (!m_rcvCondition.Wait(&m_mutex, (uint32_t) (iTarget - iNow)))
return false;
}
bool CAdapterCommunication::IsOpen(void) const
{
- return !IsStopped() && m_port->IsOpen();
+ return !IsStopped() && m_port->IsOpen() && IsRunning();
}