AC_SUBST([LIBS_DL])
LIBS=$libs_pre_dl
-AC_LANG_PUSH([C++])
-AC_CHECK_HEADERS([boost/shared_ptr.hpp], [],
- [AC_MSG_ERROR(You need the Boost libraries.)])
-AC_CHECK_HEADERS([boost/enable_shared_from_this.hpp], [],
- [AC_MSG_ERROR(You need the Boost libraries.)])
-AC_LANG_POP([C++])
-
CXXFLAGS="-fPIC -Wall -Wextra $CXXFLAGS"
AC_SUBST(REQUIRES)
void CAdapterCommunication::WriteNextCommand(void)
{
- CCECAdapterMessagePtr msg;
+ CCECAdapterMessage *msg;
if (m_outBuffer.Pop(msg))
{
CLockObject lock(&msg->mutex);
}
}
-bool CAdapterCommunication::Write(CCECAdapterMessagePtr data)
+bool CAdapterCommunication::Write(CCECAdapterMessage *data)
{
data->state = ADAPTER_MESSAGE_STATE_WAITING;
m_outBuffer.Push(data);
bool CAdapterCommunication::StartBootloader(void)
{
+ bool bReturn(false);
if (!IsRunning())
- return false;
+ return bReturn;
m_controller->AddLog(CEC_LOG_DEBUG, "starting the bootloader");
- CCECAdapterMessagePtr output(new CCECAdapterMessage);
+ CCECAdapterMessage *output = new CCECAdapterMessage;
output->push_back(MSGSTART);
output->push_escaped(MSGCODE_START_BOOTLOADER);
output->push_back(MSGEND);
- if (!Write(output))
- {
+ if ((bReturn = Write(output)) == false)
m_controller->AddLog(CEC_LOG_ERROR, "could not start the bootloader");
- return false;
- }
- m_controller->AddLog(CEC_LOG_DEBUG, "bootloader start command transmitted");
- return true;
+
+ delete output;
+
+ return bReturn;
}
bool CAdapterCommunication::PingAdapter(void)
{
+ bool bReturn(false);
if (!IsRunning())
- return false;
+ return bReturn;
m_controller->AddLog(CEC_LOG_DEBUG, "sending ping");
- CCECAdapterMessagePtr output(new CCECAdapterMessage);
+ CCECAdapterMessage *output = new CCECAdapterMessage;
output->push_back(MSGSTART);
output->push_escaped(MSGCODE_PING);
output->push_back(MSGEND);
- if (!Write(output))
- {
+ if ((bReturn = Write(output)) == false)
m_controller->AddLog(CEC_LOG_ERROR, "could not send ping command");
- return false;
- }
-
- m_controller->AddLog(CEC_LOG_DEBUG, "ping tranmitted");
// TODO check for pong
- return true;
+ delete output;
+
+ return bReturn;
}
bool CAdapterCommunication::IsOpen(void) const
#include "util/buffer.h"
#include "util/StdString.h"
#include <string>
-#include <boost/enable_shared_from_this.hpp>
-#include <boost/shared_ptr.hpp>
namespace CEC
{
} cec_adapter_message_state;
- class CCECAdapterMessage : public boost::enable_shared_from_this<CCECAdapterMessage>
+ class CCECAdapterMessage
{
public:
CCECAdapterMessage(void) { clear(); }
CMutex mutex;
CCondition condition;
};
- typedef boost::shared_ptr<CCECAdapterMessage> CCECAdapterMessagePtr;
class CSerialPort;
class CLibCEC;
bool Open(const char *strPort, uint16_t iBaudRate = 38400, uint32_t iTimeoutMs = 10000);
bool Read(CCECAdapterMessage &msg, uint32_t iTimeout = 1000);
- bool Write(CCECAdapterMessagePtr data);
+ bool Write(CCECAdapterMessage *data);
bool PingAdapter(void);
void Close(void);
bool IsOpen(void) const;
CSerialPort * m_port;
CLibCEC * m_controller;
CecBuffer<uint8_t> m_inBuffer;
- CecBuffer<CCECAdapterMessagePtr> m_outBuffer;
+ CecBuffer<CCECAdapterMessage *> m_outBuffer;
CMutex m_mutex;
CCondition m_rcvCondition;
CCondition m_startCondition;
bool CCECProcessor::Transmit(const cec_command &data)
{
+ bool bReturn(false);
LogOutput(data);
- CCECAdapterMessagePtr output(new CCECAdapterMessage(data));
- return Transmit(output);
+ CCECAdapterMessage *output = new CCECAdapterMessage(data);
+ bReturn = Transmit(output);
+ delete output;
+
+ return bReturn;
}
-bool CCECProcessor::Transmit(CCECAdapterMessagePtr output)
+bool CCECProcessor::Transmit(CCECAdapterMessage *output)
{
bool bReturn(false);
CLockObject lock(&m_mutex);
bool CCECProcessor::SetAckMask(uint16_t iMask)
{
+ bool bReturn(false);
CStdString strLog;
strLog.Format("setting ackmask to %2x", iMask);
m_controller->AddLog(CEC_LOG_DEBUG, strLog.c_str());
- CCECAdapterMessagePtr output(new CCECAdapterMessage);
+ CCECAdapterMessage *output = new CCECAdapterMessage;
output->push_back(MSGSTART);
output->push_escaped(MSGCODE_SET_ACK_MASK);
output->push_escaped((uint8_t)iMask);
output->push_back(MSGEND);
- if (!Transmit(output))
- {
+ if ((bReturn = Transmit(output)) == false)
m_controller->AddLog(CEC_LOG_ERROR, "could not set the ackmask");
- return false;
- }
- return true;
+ delete output;
+
+ return bReturn;
}
virtual bool SwitchMonitoring(bool bEnable);
virtual bool Transmit(const cec_command &data);
- virtual bool Transmit(CCECAdapterMessagePtr output);
+ virtual bool Transmit(CCECAdapterMessage *output);
virtual void TransmitAbort(cec_logical_address address, cec_opcode opcode, ECecAbortReason reason = CEC_ABORT_REASON_UNRECOGNIZED_OPCODE);
virtual void SetCurrentButton(cec_user_control_code iButtonCode);
Close();
}
-int8_t CSerialPort::Write(CCECAdapterMessagePtr data)
+int8_t CSerialPort::Write(CCECAdapterMessage *data)
{
fd_set port;
bool IsOpen();
void Close();
- int8_t Write(CCECAdapterMessagePtr data);
+ int8_t Write(CCECAdapterMessage *data);
int32_t Read(uint8_t* data, uint32_t len, uint64_t iTimeoutMs = 0);
std::string GetError() { return m_error; }
}
}
-int8_t CSerialPort::Write(CCECAdapterMessagePtr data)
+int8_t CSerialPort::Write(CCECAdapterMessage *data)
{
CLockObject lock(&m_mutex);
DWORD iBytesWritten = 0;