repositories
/
deb_libcec.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
cec: renamed CCommunication -> CAdapterCommunication
[deb_libcec.git]
/
src
/
lib
/
AdapterCommunication.cpp
diff --git
a/src/lib/Communication.cpp
b/src/lib/AdapterCommunication.cpp
similarity index 86%
rename from
src/lib/Communication.cpp
rename to
src/lib/AdapterCommunication.cpp
index fd86b539aae20bb6d91166ec16d6b84328fea6a8..1ee7f883e53e3d9549bc998e289f0883faecb0b9 100644
(file)
--- a/
src/lib/Communication.cpp
+++ b/
src/lib/AdapterCommunication.cpp
@@
-30,7
+30,7
@@
* http://www.pulse-eight.net/
*/
* http://www.pulse-eight.net/
*/
-#include "Communication.h"
+#include "
Adapter
Communication.h"
#include "CECParser.h"
#include "libPlatform/serialport.h"
#include "util/StdString.h"
#include "CECParser.h"
#include "libPlatform/serialport.h"
#include "util/StdString.h"
@@
-38,7
+38,7
@@
using namespace std;
using namespace CEC;
using namespace std;
using namespace CEC;
-C
Communication::C
Communication(CCECParser *parser) :
+C
AdapterCommunication::CAdapter
Communication(CCECParser *parser) :
m_parser(parser),
m_inbuf(NULL),
m_iInbufSize(0),
m_parser(parser),
m_inbuf(NULL),
m_iInbufSize(0),
@@
-49,13
+49,13
@@
CCommunication::CCommunication(CCECParser *parser) :
m_port = new CSerialPort;
}
m_port = new CSerialPort;
}
-C
Communication::~C
Communication(void)
+C
AdapterCommunication::~CAdapter
Communication(void)
{
m_port->Close();
m_port = NULL;
}
{
m_port->Close();
m_port = NULL;
}
-bool CCommunication::Open(const char *strPort, int iBaudRate /* = 38400 */, int iTimeoutMs /* = 10000 */)
+bool C
Adapter
Communication::Open(const char *strPort, int iBaudRate /* = 38400 */, int iTimeoutMs /* = 10000 */)
{
CLockObject lock(&m_commMutex);
if (m_bStarted)
{
CLockObject lock(&m_commMutex);
if (m_bStarted)
@@
-79,10
+79,10
@@
bool CCommunication::Open(const char *strPort, int iBaudRate /* = 38400 */, int
m_bStop = false;
m_bStarted = true;
m_bStop = false;
m_bStarted = true;
- if (pthread_create(&m_thread, NULL, (void *(*) (void *))&CCommunication::ReaderThreadHandler, (void *)this) == 0)
+
+ if (CreateThread())
{
m_parser->AddLog(CEC_LOG_DEBUG, "reader thread created");
{
m_parser->AddLog(CEC_LOG_DEBUG, "reader thread created");
- pthread_detach(m_thread);
return true;
}
else
return true;
}
else
@@
-93,22
+93,13
@@
bool CCommunication::Open(const char *strPort, int iBaudRate /* = 38400 */, int
return false;
}
return false;
}
-void *CCommunication::ReaderThreadHandler(CCommunication *comm)
-{
- if (comm)
- comm->ReaderProcess();
-
- return NULL;
-}
-
-void CCommunication::Close(void)
+void CAdapterCommunication::Close(void)
{
{
- m_bStop = true;
- pthread_join(m_thread, NULL);
+ StopThread();
m_port->Close();
}
m_port->Close();
}
-void *C
Communication::Reader
Process(void)
+void *C
AdapterCommunication::
Process(void)
{
while (!m_bStop)
{
{
while (!m_bStop)
{
@@
-128,7
+119,7
@@
void *CCommunication::ReaderProcess(void)
return NULL;
}
return NULL;
}
-bool CCommunication::ReadFromDevice(int iTimeout)
+bool C
Adapter
Communication::ReadFromDevice(int iTimeout)
{
uint8_t buff[1024];
CLockObject lock(&m_commMutex);
{
uint8_t buff[1024];
CLockObject lock(&m_commMutex);
@@
-147,7
+138,7
@@
bool CCommunication::ReadFromDevice(int iTimeout)
return true;
}
return true;
}
-void CCommunication::AddData(uint8_t *data, int iLen)
+void C
Adapter
Communication::AddData(uint8_t *data, int iLen)
{
CLockObject lock(&m_bufferMutex);
if (iLen + m_iInbufUsed > m_iInbufSize)
{
CLockObject lock(&m_bufferMutex);
if (iLen + m_iInbufUsed > m_iInbufSize)
@@
-162,7
+153,7
@@
void CCommunication::AddData(uint8_t *data, int iLen)
m_condition.Signal();
}
m_condition.Signal();
}
-bool CCommunication::Write(const cec_frame &data)
+bool C
Adapter
Communication::Write(const cec_frame &data)
{
CLockObject lock(&m_commMutex);
{
CLockObject lock(&m_commMutex);
@@
-178,7
+169,7
@@
bool CCommunication::Write(const cec_frame &data)
return true;
}
return true;
}
-bool CCommunication::Read(cec_frame &msg, int iTimeout)
+bool C
Adapter
Communication::Read(cec_frame &msg, int iTimeout)
{
CLockObject lock(&m_bufferMutex);
{
CLockObject lock(&m_bufferMutex);
@@
-269,7
+260,7
@@
bool CCommunication::Read(cec_frame &msg, int iTimeout)
return false;
}
return false;
}
-std::string CCommunication::GetError(void) const
+std::string C
Adapter
Communication::GetError(void) const
{
return m_port->GetError();
}
{
return m_port->GetError();
}