repositories
/
deb_libcec.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
b9861f8
)
cec: fixed int parameter sizes and some signed/unsigned warnings. will need to be...
author
Lars Op den Kamp
<lars.opdenkamp@pulse-eight.com>
Tue, 4 Oct 2011 21:19:09 +0000
(23:19 +0200)
committer
Lars Op den Kamp
<lars.opdenkamp@pulse-eight.com>
Tue, 4 Oct 2011 21:19:09 +0000
(23:19 +0200)
13 files changed:
include/CECExportsC.h
patch
|
blob
|
blame
|
history
include/CECExportsCpp.h
patch
|
blob
|
blame
|
history
src/lib/AdapterCommunication.cpp
patch
|
blob
|
blame
|
history
src/lib/AdapterCommunication.h
patch
|
blob
|
blame
|
history
src/lib/CECProcessor.cpp
patch
|
blob
|
blame
|
history
src/lib/LibCEC.cpp
patch
|
blob
|
blame
|
history
src/lib/LibCEC.h
patch
|
blob
|
blame
|
history
src/lib/LibCECC.cpp
patch
|
blob
|
blame
|
history
src/lib/platform/baudrate.h
patch
|
blob
|
blame
|
history
src/lib/platform/serialport.h
patch
|
blob
|
blame
|
history
src/lib/platform/windows/serialport.cpp
patch
|
blob
|
blame
|
history
src/lib/util/buffer.h
patch
|
blob
|
blame
|
history
src/testclient/main.cpp
patch
|
blob
|
blame
|
history
diff --git
a/include/CECExportsC.h
b/include/CECExportsC.h
index 61cabd2bd4e18fee19588af863c5e3f67b8e6e75..b96beba585ff7eacfbb39d340b2ac52da96a60d5 100644
(file)
--- a/
include/CECExportsC.h
+++ b/
include/CECExportsC.h
@@
-46,9
+46,9
@@
extern "C" {
* @return True when initialised, false otherwise.
*/
#ifdef __cplusplus
* @return True when initialised, false otherwise.
*/
#ifdef __cplusplus
-extern DECLSPEC bool cec_init(const char *strDeviceName, CEC::cec_logical_address iLogicalAddress = CEC::CECDEVICE_PLAYBACKDEVICE1,
in
t iPhysicalAddress = CEC_DEFAULT_PHYSICAL_ADDRESS);
+extern DECLSPEC bool cec_init(const char *strDeviceName, CEC::cec_logical_address iLogicalAddress = CEC::CECDEVICE_PLAYBACKDEVICE1,
uint8_
t iPhysicalAddress = CEC_DEFAULT_PHYSICAL_ADDRESS);
#else
#else
-extern DECLSPEC bool cec_init(const char *strDeviceName, cec_logical_address iLogicalAddress = CECDEVICE_PLAYBACKDEVICE1,
in
t iPhysicalAddress = CEC_DEFAULT_PHYSICAL_ADDRESS);
+extern DECLSPEC bool cec_init(const char *strDeviceName, cec_logical_address iLogicalAddress = CECDEVICE_PLAYBACKDEVICE1,
uint8_
t iPhysicalAddress = CEC_DEFAULT_PHYSICAL_ADDRESS);
#endif
/*!
#endif
/*!
@@
-62,7
+62,7
@@
extern DECLSPEC void cec_destroy(void);
* @param iTimeout Connection timeout in ms.
* @return True when connected, false otherwise.
*/
* @param iTimeout Connection timeout in ms.
* @return True when connected, false otherwise.
*/
-extern DECLSPEC bool cec_open(const char *strPort,
in
t iTimeout);
+extern DECLSPEC bool cec_open(const char *strPort,
uint64_
t iTimeout);
/*!
* @brief Close the connection to the CEC adapter.
/*!
* @brief Close the connection to the CEC adapter.
diff --git
a/include/CECExportsCpp.h
b/include/CECExportsCpp.h
index f052592b5d034688d376cdd5ac81f23e1e34392e..f0a0ac9306040bb171d39160442b4d13b8a14cfe 100644
(file)
--- a/
include/CECExportsCpp.h
+++ b/
include/CECExportsCpp.h
@@
-41,7
+41,7
@@
namespace CEC
/*!
* @see cec_open
*/
/*!
* @see cec_open
*/
- virtual bool Open(const char *strPort,
in
t iTimeoutMs = 10000) = 0;
+ virtual bool Open(const char *strPort,
uint64_
t iTimeoutMs = 10000) = 0;
/*!
* @see cec_close
/*!
* @see cec_close
@@
-122,7
+122,7
@@
namespace CEC
};
};
};
};
-extern DECLSPEC void * CECCreate(const char *strDeviceName, CEC::cec_logical_address iLogicalAddress = CEC::CECDEVICE_PLAYBACKDEVICE1,
in
t iPhysicalAddress = CEC_DEFAULT_PHYSICAL_ADDRESS);
+extern DECLSPEC void * CECCreate(const char *strDeviceName, CEC::cec_logical_address iLogicalAddress = CEC::CECDEVICE_PLAYBACKDEVICE1,
uint8_
t iPhysicalAddress = CEC_DEFAULT_PHYSICAL_ADDRESS);
#if !defined(DLL_EXPORT)
#if defined(_WIN32) || defined(_WIN64)
#if !defined(DLL_EXPORT)
#if defined(_WIN32) || defined(_WIN64)
@@
-135,7
+135,7
@@
static int g_iLibCECInstanceCount = 0;
/*!
* @see cec_init
*/
/*!
* @see cec_init
*/
-inline CEC::ICECAdapter *LoadLibCec(const char *strName, CEC::cec_logical_address iLogicalAddress = CEC::CECDEVICE_PLAYBACKDEVICE1,
in
t iPhysicalAddress = CEC_DEFAULT_PHYSICAL_ADDRESS)
+inline CEC::ICECAdapter *LoadLibCec(const char *strName, CEC::cec_logical_address iLogicalAddress = CEC::CECDEVICE_PLAYBACKDEVICE1,
uint8_
t iPhysicalAddress = CEC_DEFAULT_PHYSICAL_ADDRESS)
{
typedef void* (__cdecl*_CreateLibCec)(const char *, uint8_t, uint8_t);
_CreateLibCec CreateLibCec;
{
typedef void* (__cdecl*_CreateLibCec)(const char *, uint8_t, uint8_t);
_CreateLibCec CreateLibCec;
@@
-149,7
+149,7
@@
inline CEC::ICECAdapter *LoadLibCec(const char *strName, CEC::cec_logical_addres
CreateLibCec = (_CreateLibCec) (GetProcAddress(g_libCEC, "CECCreate"));
if (!CreateLibCec)
return NULL;
CreateLibCec = (_CreateLibCec) (GetProcAddress(g_libCEC, "CECCreate"));
if (!CreateLibCec)
return NULL;
- return static_cast< CEC::ICECAdapter* > (CreateLibCec(strName, iLogicalAddress, iPhysicalAddress));
+ return static_cast< CEC::ICECAdapter* > (CreateLibCec(strName,
(uint8_t)
iLogicalAddress, iPhysicalAddress));
}
/*!
}
/*!
diff --git
a/src/lib/AdapterCommunication.cpp
b/src/lib/AdapterCommunication.cpp
index d56ee168b642df7d2ab173677569c0271222ecdb..4b0bcdd1b238ac26aa7882a8b4ebae1c62de90da 100644
(file)
--- a/
src/lib/AdapterCommunication.cpp
+++ b/
src/lib/AdapterCommunication.cpp
@@
-58,7
+58,7
@@
CAdapterCommunication::~CAdapterCommunication(void)
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)
@@
-121,16
+121,16
@@
void *CAdapterCommunication::Process(void)
return NULL;
}
return NULL;
}
-bool CAdapterCommunication::ReadFromDevice(
in
t iTimeout)
+bool CAdapterCommunication::ReadFromDevice(
uint64_
t iTimeout)
{
uint8_t buff[1024];
CLockObject lock(&m_commMutex);
if (!m_port)
return false;
{
uint8_t buff[1024];
CLockObject lock(&m_commMutex);
if (!m_port)
return false;
- int iBytesRead = m_port->Read(buff, sizeof(buff), iTimeout);
+ int
32_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());
@@
-138,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)
@@
-162,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());
@@
-177,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);
diff --git
a/src/lib/AdapterCommunication.h
b/src/lib/AdapterCommunication.h
index 426601767347d55c76316286e21024e586ab74f2..c95f729998d75d5505323125011397229599422b 100644
(file)
--- a/
src/lib/AdapterCommunication.h
+++ b/
src/lib/AdapterCommunication.h
@@
-45,8
+45,8
@@
namespace CEC
CAdapterCommunication(CLibCEC *controller);
virtual ~CAdapterCommunication();
CAdapterCommunication(CLibCEC *controller);
virtual ~CAdapterCommunication();
- bool Open(const char *strPort,
int iBaudRate = 38400, in
t iTimeoutMs = 10000);
- bool Read(cec_frame &msg,
in
t iTimeout = 1000);
+ bool Open(const char *strPort,
uint16_t iBaudRate = 38400, uint64_
t iTimeoutMs = 10000);
+ bool Read(cec_frame &msg,
uint64_
t iTimeout = 1000);
bool Write(const cec_frame &frame);
bool PingAdapter(void);
void Close(void);
bool Write(const cec_frame &frame);
bool PingAdapter(void);
void Close(void);
@@
-59,8
+59,8
@@
namespace CEC
bool SetAckMask(uint16_t iMask);
static void PushEscaped(cec_frame &vec, uint8_t byte);
private:
bool SetAckMask(uint16_t iMask);
static void PushEscaped(cec_frame &vec, uint8_t byte);
private:
- void AddData(uint8_t *data,
in
t iLen);
- bool ReadFromDevice(
in
t iTimeout);
+ void AddData(uint8_t *data,
uint8_
t iLen);
+ bool ReadFromDevice(
uint64_
t iTimeout);
CSerialPort * m_port;
CLibCEC * m_controller;
CSerialPort * m_port;
CLibCEC * m_controller;
diff --git
a/src/lib/CECProcessor.cpp
b/src/lib/CECProcessor.cpp
index 4a276ee760b7cc1b1b406e127a3a8e6fc37d401c..258e16419f9b79dd3b7cb3e413e651085329748c 100644
(file)
--- a/
src/lib/CECProcessor.cpp
+++ b/
src/lib/CECProcessor.cpp
@@
-112,7
+112,7
@@
bool CCECProcessor::PowerOnDevices(cec_logical_address address /* = CECDEVICE_TV
m_controller->AddLog(CEC_LOG_DEBUG, strLog.c_str());
cec_frame frame;
frame.push_back(GetSourceDestination(address));
m_controller->AddLog(CEC_LOG_DEBUG, strLog.c_str());
cec_frame frame;
frame.push_back(GetSourceDestination(address));
- frame.push_back(CEC_OPCODE_TEXT_VIEW_ON);
+ frame.push_back(
(uint8_t)
CEC_OPCODE_TEXT_VIEW_ON);
return Transmit(frame);
}
return Transmit(frame);
}
@@
-126,7
+126,7
@@
bool CCECProcessor::StandbyDevices(cec_logical_address address /* = CECDEVICE_BR
m_controller->AddLog(CEC_LOG_DEBUG, strLog.c_str());
cec_frame frame;
frame.push_back(GetSourceDestination(address));
m_controller->AddLog(CEC_LOG_DEBUG, strLog.c_str());
cec_frame frame;
frame.push_back(GetSourceDestination(address));
- frame.push_back(CEC_OPCODE_STANDBY);
+ frame.push_back(
(uint8_t)
CEC_OPCODE_STANDBY);
return Transmit(frame);
}
return Transmit(frame);
}
@@
-138,7
+138,7
@@
bool CCECProcessor::SetActiveView(void)
m_controller->AddLog(CEC_LOG_DEBUG, "setting active view");
cec_frame frame;
frame.push_back(GetSourceDestination(CECDEVICE_BROADCAST));
m_controller->AddLog(CEC_LOG_DEBUG, "setting active view");
cec_frame frame;
frame.push_back(GetSourceDestination(CECDEVICE_BROADCAST));
- frame.push_back(CEC_OPCODE_ACTIVE_SOURCE);
+ frame.push_back(
(uint8_t)
CEC_OPCODE_ACTIVE_SOURCE);
frame.push_back((m_physicaladdress >> 8) & 0xFF);
frame.push_back(m_physicaladdress & 0xFF);
return Transmit(frame);
frame.push_back((m_physicaladdress >> 8) & 0xFF);
frame.push_back(m_physicaladdress & 0xFF);
return Transmit(frame);
@@
-152,7
+152,7
@@
bool CCECProcessor::SetInactiveView(void)
m_controller->AddLog(CEC_LOG_DEBUG, "setting inactive view");
cec_frame frame;
frame.push_back(GetSourceDestination(CECDEVICE_BROADCAST));
m_controller->AddLog(CEC_LOG_DEBUG, "setting inactive view");
cec_frame frame;
frame.push_back(GetSourceDestination(CECDEVICE_BROADCAST));
- frame.push_back(CEC_OPCODE_INACTIVE_SOURCE);
+ frame.push_back(
(uint8_t)
CEC_OPCODE_INACTIVE_SOURCE);
frame.push_back((m_physicaladdress >> 8) & 0xFF);
frame.push_back(m_physicaladdress & 0xFF);
return Transmit(frame);
frame.push_back((m_physicaladdress >> 8) & 0xFF);
frame.push_back(m_physicaladdress & 0xFF);
return Transmit(frame);
@@
-232,9
+232,9
@@
void CCECProcessor::TransmitAbort(cec_logical_address address, cec_opcode opcode
m_controller->AddLog(CEC_LOG_DEBUG, "transmitting abort message");
cec_frame frame;
frame.push_back(GetSourceDestination(address));
m_controller->AddLog(CEC_LOG_DEBUG, "transmitting abort message");
cec_frame frame;
frame.push_back(GetSourceDestination(address));
- frame.push_back(CEC_OPCODE_FEATURE_ABORT);
- frame.push_back(opcode);
- frame.push_back(reason);
+ frame.push_back(
(uint8_t)
CEC_OPCODE_FEATURE_ABORT);
+ frame.push_back(
(uint8_t)
opcode);
+ frame.push_back(
(uint8_t)
reason);
Transmit(frame);
}
Transmit(frame);
}
@@
-243,7
+243,7
@@
void CCECProcessor::ReportCECVersion(cec_logical_address address /* = CECDEVICE_
cec_frame frame;
m_controller->AddLog(CEC_LOG_NOTICE, "reporting CEC version as 1.3a");
frame.push_back(GetSourceDestination(address));
cec_frame frame;
m_controller->AddLog(CEC_LOG_NOTICE, "reporting CEC version as 1.3a");
frame.push_back(GetSourceDestination(address));
- frame.push_back(CEC_OPCODE_CEC_VERSION);
+ frame.push_back(
(uint8_t)
CEC_OPCODE_CEC_VERSION);
frame.push_back(CEC_VERSION_1_3A);
Transmit(frame);
}
frame.push_back(CEC_VERSION_1_3A);
Transmit(frame);
}
@@
-257,8
+257,8
@@
void CCECProcessor::ReportPowerState(cec_logical_address address /*= CECDEVICE_T
m_controller->AddLog(CEC_LOG_NOTICE, "reporting \"Off\" power status");
frame.push_back(GetSourceDestination(address));
m_controller->AddLog(CEC_LOG_NOTICE, "reporting \"Off\" power status");
frame.push_back(GetSourceDestination(address));
- frame.push_back(CEC_OPCODE_REPORT_POWER_STATUS);
- frame.push_back(bOn ?
CEC_POWER_STATUS_ON :
CEC_POWER_STATUS_STANDBY);
+ frame.push_back(
(uint8_t)
CEC_OPCODE_REPORT_POWER_STATUS);
+ frame.push_back(bOn ?
(uint8_t) CEC_POWER_STATUS_ON : (uint8_t)
CEC_POWER_STATUS_STANDBY);
Transmit(frame);
}
Transmit(frame);
}
@@
-271,8
+271,8
@@
void CCECProcessor::ReportMenuState(cec_logical_address address /* = CECDEVICE_T
m_controller->AddLog(CEC_LOG_NOTICE, "reporting menu state as inactive");
frame.push_back(GetSourceDestination(address));
m_controller->AddLog(CEC_LOG_NOTICE, "reporting menu state as inactive");
frame.push_back(GetSourceDestination(address));
- frame.push_back(CEC_OPCODE_MENU_STATUS);
- frame.push_back(bActive ?
CEC_MENU_STATE_ACTIVATED :
CEC_MENU_STATE_DEACTIVATED);
+ frame.push_back(
(uint8_t)
CEC_OPCODE_MENU_STATUS);
+ frame.push_back(bActive ?
(uint8_t) CEC_MENU_STATE_ACTIVATED : (uint8_t)
CEC_MENU_STATE_DEACTIVATED);
Transmit(frame);
}
Transmit(frame);
}
@@
-290,7
+290,7
@@
void CCECProcessor::ReportOSDName(cec_logical_address address /* = CECDEVICE_TV
strLog.Format("reporting OSD name as %s", osdname);
m_controller->AddLog(CEC_LOG_NOTICE, strLog.c_str());
frame.push_back(GetSourceDestination(address));
strLog.Format("reporting OSD name as %s", osdname);
m_controller->AddLog(CEC_LOG_NOTICE, strLog.c_str());
frame.push_back(GetSourceDestination(address));
- frame.push_back(CEC_OPCODE_SET_OSD_NAME);
+ frame.push_back(
(uint8_t)
CEC_OPCODE_SET_OSD_NAME);
for (unsigned int i = 0; i < strlen(osdname); i++)
frame.push_back(osdname[i]);
for (unsigned int i = 0; i < strlen(osdname); i++)
frame.push_back(osdname[i]);
@@
-305,7
+305,7
@@
void CCECProcessor::ReportPhysicalAddress(void)
strLog.Format("reporting physical address as %04x", m_physicaladdress);
m_controller->AddLog(CEC_LOG_NOTICE, strLog.c_str());
frame.push_back(GetSourceDestination(CECDEVICE_BROADCAST));
strLog.Format("reporting physical address as %04x", m_physicaladdress);
m_controller->AddLog(CEC_LOG_NOTICE, strLog.c_str());
frame.push_back(GetSourceDestination(CECDEVICE_BROADCAST));
- frame.push_back(CEC_OPCODE_REPORT_PHYSICAL_ADDRESS);
+ frame.push_back(
(uint8_t)
CEC_OPCODE_REPORT_PHYSICAL_ADDRESS);
frame.push_back((m_physicaladdress >> 8) & 0xFF);
frame.push_back(m_physicaladdress & 0xFF);
frame.push_back(CEC_DEVICE_TYPE_PLAYBACK_DEVICE);
frame.push_back((m_physicaladdress >> 8) & 0xFF);
frame.push_back(m_physicaladdress & 0xFF);
frame.push_back(CEC_DEVICE_TYPE_PLAYBACK_DEVICE);
@@
-317,7
+317,7
@@
void CCECProcessor::BroadcastActiveSource(void)
cec_frame frame;
m_controller->AddLog(CEC_LOG_NOTICE, "broadcasting active source");
frame.push_back(GetSourceDestination(CECDEVICE_BROADCAST));
cec_frame frame;
m_controller->AddLog(CEC_LOG_NOTICE, "broadcasting active source");
frame.push_back(GetSourceDestination(CECDEVICE_BROADCAST));
- frame.push_back(CEC_OPCODE_ACTIVE_SOURCE);
+ frame.push_back(
(uint8_t)
CEC_OPCODE_ACTIVE_SOURCE);
frame.push_back((m_physicaladdress >> 8) & 0xFF);
frame.push_back(m_physicaladdress & 0xFF);
Transmit(frame);
frame.push_back((m_physicaladdress >> 8) & 0xFF);
frame.push_back(m_physicaladdress & 0xFF);
Transmit(frame);
diff --git
a/src/lib/LibCEC.cpp
b/src/lib/LibCEC.cpp
index 87759c153926d5343a7e8cb0be3f12e76e1e7d97..3437e451ee132f1a62e8da013825957d61fadd85 100644
(file)
--- a/
src/lib/LibCEC.cpp
+++ b/
src/lib/LibCEC.cpp
@@
-41,7
+41,7
@@
using namespace std;
using namespace CEC;
using namespace std;
using namespace CEC;
-CLibCEC::CLibCEC(const char *strDeviceName, cec_logical_address iLogicalAddress /* = CECDEVICE_PLAYBACKDEVICE1 */,
in
t iPhysicalAddress /* = CEC_DEFAULT_PHYSICAL_ADDRESS */) :
+CLibCEC::CLibCEC(const char *strDeviceName, cec_logical_address iLogicalAddress /* = CECDEVICE_PLAYBACKDEVICE1 */,
uint8_
t iPhysicalAddress /* = CEC_DEFAULT_PHYSICAL_ADDRESS */) :
m_iCurrentButton(CEC_USER_CONTROL_CODE_UNKNOWN),
m_buttontime(0)
{
m_iCurrentButton(CEC_USER_CONTROL_CODE_UNKNOWN),
m_buttontime(0)
{
@@
-58,7
+58,7
@@
CLibCEC::~CLibCEC(void)
m_comm = NULL;
}
m_comm = NULL;
}
-bool CLibCEC::Open(const char *strPort,
in
t iTimeoutMs /* = 10000 */)
+bool CLibCEC::Open(const char *strPort,
uint64_
t iTimeoutMs /* = 10000 */)
{
if (!m_comm)
return false;
{
if (!m_comm)
return false;
@@
-233,7
+233,7
@@
void CLibCEC::SetCurrentButton(cec_user_control_code iButtonCode)
m_buttontime = GetTimeMs();
}
m_buttontime = GetTimeMs();
}
-DECLSPEC void * CECCreate(const char *strDeviceName, CEC::cec_logical_address iLogicalAddress /*= CEC::CECDEVICE_PLAYBACKDEVICE1 */,
in
t iPhysicalAddress /* = CEC_DEFAULT_PHYSICAL_ADDRESS */)
+DECLSPEC void * CECCreate(const char *strDeviceName, CEC::cec_logical_address iLogicalAddress /*= CEC::CECDEVICE_PLAYBACKDEVICE1 */,
uint8_
t iPhysicalAddress /* = CEC_DEFAULT_PHYSICAL_ADDRESS */)
{
return static_cast< void* > (new CLibCEC(strDeviceName, iLogicalAddress, iPhysicalAddress));
}
{
return static_cast< void* > (new CLibCEC(strDeviceName, iLogicalAddress, iPhysicalAddress));
}
diff --git
a/src/lib/LibCEC.h
b/src/lib/LibCEC.h
index b863cb49c91a5f7922ab4b2b975779e16956e2bc..cb9eb8c6e6e538691a098bf3581d076cbfff7174 100644
(file)
--- a/
src/lib/LibCEC.h
+++ b/
src/lib/LibCEC.h
@@
-47,10
+47,10
@@
namespace CEC
* ICECAdapter implementation
*/
//@{
* ICECAdapter implementation
*/
//@{
- CLibCEC(const char *strDeviceName, cec_logical_address iLogicalAddress = CECDEVICE_PLAYBACKDEVICE1,
in
t iPhysicalAddress = CEC_DEFAULT_PHYSICAL_ADDRESS);
+ CLibCEC(const char *strDeviceName, cec_logical_address iLogicalAddress = CECDEVICE_PLAYBACKDEVICE1,
uint8_
t iPhysicalAddress = CEC_DEFAULT_PHYSICAL_ADDRESS);
virtual ~CLibCEC(void);
virtual ~CLibCEC(void);
- virtual bool Open(const char *strPort,
in
t iTimeout = 10000);
+ virtual bool Open(const char *strPort,
uint64_
t iTimeout = 10000);
virtual void Close(void);
virtual int FindAdapters(std::vector<cec_adapter> &deviceList, const char *strDevicePath = NULL);
virtual bool PingAdapter(void);
virtual void Close(void);
virtual int FindAdapters(std::vector<cec_adapter> &deviceList, const char *strDevicePath = NULL);
virtual bool PingAdapter(void);
diff --git
a/src/lib/LibCECC.cpp
b/src/lib/LibCECC.cpp
index 7f2475b5eb38118b28090f79b516f4b2e1c3284d..60ada61b749fcc13c77f39ff1e292ecfbc19bfdf 100644
(file)
--- a/
src/lib/LibCECC.cpp
+++ b/
src/lib/LibCECC.cpp
@@
-41,7
+41,7
@@
using namespace std;
//@{
ICECAdapter *cec_parser;
//@{
ICECAdapter *cec_parser;
-bool cec_init(const char *strDeviceName, cec_logical_address iLogicalAddress /* = CECDEVICE_PLAYBACKDEVICE1 */,
in
t iPhysicalAddress /* = CEC_DEFAULT_PHYSICAL_ADDRESS */)
+bool cec_init(const char *strDeviceName, cec_logical_address iLogicalAddress /* = CECDEVICE_PLAYBACKDEVICE1 */,
uint8_
t iPhysicalAddress /* = CEC_DEFAULT_PHYSICAL_ADDRESS */)
{
cec_parser = (ICECAdapter *) CECCreate(strDeviceName, iLogicalAddress, iPhysicalAddress);
return (cec_parser != NULL);
{
cec_parser = (ICECAdapter *) CECCreate(strDeviceName, iLogicalAddress, iPhysicalAddress);
return (cec_parser != NULL);
@@
-54,7
+54,7
@@
void cec_destroy(void)
cec_parser = NULL;
}
cec_parser = NULL;
}
-bool cec_open(const char *strPort,
in
t iTimeout)
+bool cec_open(const char *strPort,
uint64_
t iTimeout)
{
if (cec_parser)
return cec_parser->Open(strPort, iTimeout);
{
if (cec_parser)
return cec_parser->Open(strPort, iTimeout);
diff --git
a/src/lib/platform/baudrate.h
b/src/lib/platform/baudrate.h
index 53f04acf2a0505b2dc318926b2d3709a85d97a07..759b1f1495c3a78389757f99ea60cdb544e3035c 100644
(file)
--- a/
src/lib/platform/baudrate.h
+++ b/
src/lib/platform/baudrate.h
@@
-21,14
+21,18
@@
//every baudrate I could find is in here in an #ifdef block
//so it should compile on everything
//every baudrate I could find is in here in an #ifdef block
//so it should compile on everything
+#include "os-dependent.h"
+
+#ifndef __WINDOWS__
#include <termios.h>
#include <termios.h>
+#endif
namespace CEC
{
static struct sbaudrate
{
namespace CEC
{
static struct sbaudrate
{
- int rate;
- int symbol;
+ int
32_t
rate;
+ int
32_t
symbol;
}
baudrates[] =
{
}
baudrates[] =
{
@@
-182,11
+186,11
@@
namespace CEC
{ -1, -1}
};
{ -1, -1}
};
- static int
IntToBaudrate(in
t baudrate)
+ static int
32_t IntToBaudrate(uint32_
t baudrate)
{
for (unsigned int i = 0; i < sizeof(baudrates) / sizeof(CEC::sbaudrate) - 1; i++)
{
{
for (unsigned int i = 0; i < sizeof(baudrates) / sizeof(CEC::sbaudrate) - 1; i++)
{
- if (baudrates[i].rate == baudrate)
+ if (baudrates[i].rate ==
(int32_t)
baudrate)
return baudrates[i].symbol;
}
return baudrates[i].symbol;
}
diff --git
a/src/lib/platform/serialport.h
b/src/lib/platform/serialport.h
index 2cdc10890c9c49396dcdcea56435c5b51bcc0e01..ea6cdea15ff31eb152e5e78268e494d78cbdbe2b 100644
(file)
--- a/
src/lib/platform/serialport.h
+++ b/
src/lib/platform/serialport.h
@@
-19,7
+19,6
@@
*/
#include "os-dependent.h"
*/
#include "os-dependent.h"
-#include "baudrate.h"
#include <string>
#include <vector>
#include <stdint.h>
#include <string>
#include <vector>
#include <stdint.h>
@@
-43,22
+42,22
@@
namespace CEC
CSerialPort();
virtual ~CSerialPort();
CSerialPort();
virtual ~CSerialPort();
- bool Open(std::string name,
int baudrate, int databits = 8, int stopbits = 1, in
t parity = PAR_NONE);
+ bool Open(std::string name,
uint32_t baudrate, uint8_t databits = 8, uint8_t stopbits = 1, uint8_
t parity = PAR_NONE);
bool IsOpen();
void Close();
bool IsOpen();
void Close();
- int Write(std::vector<uint8_t> data)
+ int
32_t
Write(std::vector<uint8_t> data)
{
{
- return Write(&data[0], data.size());
+ return Write(&data[0],
(uint32_t)
data.size());
}
}
- int
Write(uint8_t* data, in
t len);
- int
Read(uint8_t* data, int len, int iTimeoutMs = -1
);
+ int
32_t Write(uint8_t* data, uint32_
t len);
+ int
32_t Read(uint8_t* data, uint32_t len, uint64_t iTimeoutMs = 0
);
std::string GetError() { return m_error; }
std::string GetName() { return m_name; }
private:
std::string GetError() { return m_error; }
std::string GetName() { return m_name; }
private:
- bool SetBaudRate(
in
t baudrate);
+ bool SetBaudRate(
uint32_
t baudrate);
std::string m_error;
std::string m_name;
std::string m_error;
std::string m_name;
@@
-69,10
+68,10
@@
namespace CEC
HANDLE m_handle;
bool m_bIsOpen;
HANDLE m_handle;
bool m_bIsOpen;
-
int
m_iBaudrate;
-
int
m_iDatabits;
-
int
m_iStopbits;
-
int
m_iParity;
+
uint32_t
m_iBaudrate;
+
uint8_t
m_iDatabits;
+
uint8_t
m_iStopbits;
+
uint8_t
m_iParity;
int64_t m_iTimeout;
CecBuffer<uint8_t> m_buffer;
HANDLE m_ovHandle;
int64_t m_iTimeout;
CecBuffer<uint8_t> m_buffer;
HANDLE m_ovHandle;
diff --git
a/src/lib/platform/windows/serialport.cpp
b/src/lib/platform/windows/serialport.cpp
index bfdc8d53d71917095b444a527f907c0ce8352fb9..ce299cf0d443177ed9ff1bf289761eede2e082e2 100644
(file)
--- a/
src/lib/platform/windows/serialport.cpp
+++ b/
src/lib/platform/windows/serialport.cpp
@@
-63,8
+63,9
@@
CSerialPort::~CSerialPort(void)
Close();
}
Close();
}
-bool CSerialPort::Open(string name,
int baudrate, int databits, int stopbits, in
t parity)
+bool CSerialPort::Open(string name,
uint32_t baudrate, uint8_t databits, uint8_t stopbits, uint8_
t parity)
{
{
+ CLockObject lock(&m_mutex);
m_handle = CreateFile(name.c_str(), GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
if (m_handle == INVALID_HANDLE_VALUE)
{
m_handle = CreateFile(name.c_str(), GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
if (m_handle == INVALID_HANDLE_VALUE)
{
@@
-157,6
+158,7
@@
bool CSerialPort::SetTimeouts(bool bBlocking)
void CSerialPort::Close(void)
{
void CSerialPort::Close(void)
{
+ CLockObject lock(&m_mutex);
if (m_bIsOpen)
{
CloseHandle(m_handle);
if (m_bIsOpen)
{
CloseHandle(m_handle);
@@
-164,8
+166,9
@@
void CSerialPort::Close(void)
}
}
}
}
-int
CSerialPort::Write(uint8_t* data, in
t len)
+int
32_t CSerialPort::Write(uint8_t* data, uint32_
t len)
{
{
+ CLockObject lock(&m_mutex);
DWORD iBytesWritten = 0;
if (!m_bIsOpen)
return -1;
DWORD iBytesWritten = 0;
if (!m_bIsOpen)
return -1;
@@
-177,31
+180,41
@@
int CSerialPort::Write(uint8_t* data, int len)
return -1;
}
return -1;
}
- return
(int)
iBytesWritten;
+ return iBytesWritten;
}
}
-int
CSerialPort::Read(uint8_t* data, int len, int iTimeoutMs /* = -1
*/)
+int
32_t CSerialPort::Read(uint8_t* data, uint32_t len, uint64_t iTimeoutMs /* = 0
*/)
{
{
+ CLockObject lock(&m_mutex);
+ int32_t iReturn(-1);
DWORD iBytesRead = 0;
if (m_handle == 0)
{
m_error = "Error while reading from COM port: invalid handle";
DWORD iBytesRead = 0;
if (m_handle == 0)
{
m_error = "Error while reading from COM port: invalid handle";
- return
-1
;
+ return
iReturn
;
}
if(!ReadFile(m_handle, data, len, &iBytesRead, NULL) != 0)
{
m_error = "unable to read from device";
FormatWindowsError(GetLastError(), m_error);
}
if(!ReadFile(m_handle, data, len, &iBytesRead, NULL) != 0)
{
m_error = "unable to read from device";
FormatWindowsError(GetLastError(), m_error);
- iBytesRead = -1;
+ iReturn = -1;
+ }
+ else
+ {
+ iReturn = (int32_t) iBytesRead;
}
}
- return
(int) iBytesRead
;
+ return
iReturn
;
}
}
-bool CSerialPort::SetBaudRate(
in
t baudrate)
+bool CSerialPort::SetBaudRate(
uint32_
t baudrate)
{
{
- m_iBaudrate = baudrate;
+ int32_t rate = IntToBaudrate(baudrate);
+ if (rate < 0)
+ m_iBaudrate = baudrate > 0 ? baudrate : 0;
+ else
+ m_iBaudrate = rate;
DCB dcb;
memset(&dcb,0,sizeof(dcb));
DCB dcb;
memset(&dcb,0,sizeof(dcb));
@@
-240,7
+253,8
@@
bool CSerialPort::SetBaudRate(int baudrate)
return true;
}
return true;
}
-bool CSerialPort::IsOpen()
const
+bool CSerialPort::IsOpen()
{
{
+ CLockObject lock(&m_mutex);
return m_bIsOpen;
}
return m_bIsOpen;
}
diff --git
a/src/lib/util/buffer.h
b/src/lib/util/buffer.h
index f284131d2ca1c511ea4932be199603e2435b5dad..d49de62554ea7ea8305c1c810ce2809d8f2228eb 100644
(file)
--- a/
src/lib/util/buffer.h
+++ b/
src/lib/util/buffer.h
@@
-40,7
+40,7
@@
namespace CEC
struct CecBuffer
{
public:
struct CecBuffer
{
public:
- CecBuffer(int iMaxSize = 100)
+ CecBuffer(
unsigned
int iMaxSize = 100)
{
m_maxSize = iMaxSize;
}
{
m_maxSize = iMaxSize;
}
@@
-72,7
+72,7
@@
namespace CEC
}
private:
}
private:
-
int
m_maxSize;
+
unsigned int
m_maxSize;
std::queue<_BType> m_buffer;
CMutex m_mutex;
};
std::queue<_BType> m_buffer;
CMutex m_mutex;
};
diff --git
a/src/testclient/main.cpp
b/src/testclient/main.cpp
index f2f2bf3e0a9678338fc8b347b38d6afc853b0006..983ba13736fff90d6b3b16c9fce8985206ead71c 100644
(file)
--- a/
src/testclient/main.cpp
+++ b/
src/testclient/main.cpp
@@
-45,11
+45,23
@@
using namespace std;
#define CEC_TEST_CLIENT_VERSION 3
#define CEC_TEST_CLIENT_VERSION 3
-inline bool HexStrToInt(const std::string& data,
in
t& value)
+inline bool HexStrToInt(const std::string& data,
uint8_
t& value)
{
{
- return sscanf(data.c_str(), "%x", &value) == 1;
-}
+ int iTmp(0);
+ if (sscanf(data.c_str(), "%x", &iTmp) == 1)
+ {
+ if (iTmp > 256)
+ value = 255;
+ else if (iTmp < 0)
+ value = 0;
+ else
+ value = (uint8_t) iTmp;
+ return true;
+ }
+
+ return false;
+}
//get the first word (separated by whitespace) from string data and place that in word
//then remove that word from string data
//get the first word (separated by whitespace) from string data and place that in word
//then remove that word from string data
@@
-254,7
+266,7
@@
int main (int argc, char *argv[])
if (command == "tx")
{
string strvalue;
if (command == "tx")
{
string strvalue;
-
int
ivalue;
+
uint8_t
ivalue;
vector<uint8_t> bytes;
while (GetWord(input, strvalue) && HexStrToInt(strvalue, ivalue))
bytes.push_back(ivalue);
vector<uint8_t> bytes;
while (GetWord(input, strvalue) && HexStrToInt(strvalue, ivalue))
bytes.push_back(ivalue);