repositories
/
deb_libcec.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
cec: fix the last commit on linux
[deb_libcec.git]
/
src
/
lib
/
AdapterCommunication.cpp
diff --git
a/src/lib/AdapterCommunication.cpp
b/src/lib/AdapterCommunication.cpp
index 3a403068811a0dfee97d077bbf62f70f057f735a..4b0bcdd1b238ac26aa7882a8b4ebae1c62de90da 100644
(file)
--- a/
src/lib/AdapterCommunication.cpp
+++ b/
src/lib/AdapterCommunication.cpp
@@
-52,11
+52,13
@@
CAdapterCommunication::CAdapterCommunication(CLibCEC *controller) :
CAdapterCommunication::~CAdapterCommunication(void)
{
CAdapterCommunication::~CAdapterCommunication(void)
{
+ StopThread();
m_port->Close();
m_port->Close();
+ delete m_port;
m_port = NULL;
}
m_port = NULL;
}
-bool CAdapterCommunication::Open(const char *strPort,
int iBaudRate /* = 38400 */, in
t iTimeoutMs /* = 10000 */)
+bool CAdapterCommunication::Open(const char *strPort,
uint16_t iBaudRate /* = 38400 */, uint64_
t iTimeoutMs /* = 10000 */)
{
CLockObject lock(&m_commMutex);
if (m_bStarted)
{
CLockObject lock(&m_commMutex);
if (m_bStarted)
@@
-114,20
+116,21
@@
void *CAdapterCommunication::Process(void)
CCondition::Sleep(50);
}
CCondition::Sleep(50);
}
- m_controller->AddLog(CEC_LOG_DEBUG, "reader thread terminated");
-
CLockObject lock(&m_commMutex);
m_bStarted = false;
return NULL;
}
CLockObject lock(&m_commMutex);
m_bStarted = false;
return NULL;
}
-bool CAdapterCommunication::ReadFromDevice(
in
t iTimeout)
+bool CAdapterCommunication::ReadFromDevice(
uint64_
t iTimeout)
{
uint8_t buff[1024];
CLockObject lock(&m_commMutex);
{
uint8_t buff[1024];
CLockObject lock(&m_commMutex);
- int iBytesRead = m_port->Read(buff, sizeof(buff), iTimeout);
+ if (!m_port)
+ return false;
+
+ int32_t iBytesRead = m_port->Read(buff, sizeof(buff), iTimeout);
lock.Leave();
lock.Leave();
- if (iBytesRead < 0)
+ if (iBytesRead < 0
|| iBytesRead > 256
)
{
CStdString strError;
strError.Format("error reading from serial port: %s", m_port->GetError().c_str());
{
CStdString strError;
strError.Format("error reading from serial port: %s", m_port->GetError().c_str());
@@
-135,12
+138,12
@@
bool CAdapterCommunication::ReadFromDevice(int iTimeout)
return false;
}
else if (iBytesRead > 0)
return false;
}
else if (iBytesRead > 0)
- AddData(buff, iBytesRead);
+ AddData(buff,
(uint8_t)
iBytesRead);
return true;
}
return true;
}
-void CAdapterCommunication::AddData(uint8_t *data,
in
t iLen)
+void CAdapterCommunication::AddData(uint8_t *data,
uint8_
t iLen)
{
CLockObject lock(&m_bufferMutex);
if (iLen + m_iInbufUsed > m_iInbufSize)
{
CLockObject lock(&m_bufferMutex);
if (iLen + m_iInbufUsed > m_iInbufSize)
@@
-159,7
+162,7
@@
bool CAdapterCommunication::Write(const cec_frame &data)
{
CLockObject lock(&m_commMutex);
{
CLockObject lock(&m_commMutex);
- if (m_port->Write(data) != data.size())
+ if (m_port->Write(data) !=
(int)
data.size())
{
CStdString strError;
strError.Format("error writing to serial port: %s", m_port->GetError().c_str());
{
CStdString strError;
strError.Format("error writing to serial port: %s", m_port->GetError().c_str());
@@
-174,7
+177,7
@@
bool CAdapterCommunication::Write(const cec_frame &data)
return true;
}
return true;
}
-bool CAdapterCommunication::Read(cec_frame &msg,
in
t iTimeout)
+bool CAdapterCommunication::Read(cec_frame &msg,
uint64_
t iTimeout)
{
CLockObject lock(&m_bufferMutex);
{
CLockObject lock(&m_bufferMutex);