X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Flib%2FAdapterCommunication.h;h=badeae9cf0fe3285b636deb941fe7fac1a81f48b;hb=50aa01e6895383ff8e96af9b9d0b4641cc3b61f2;hp=270d96b9f5303746ecc0b7d42d9813f4dc478a69;hpb=828682d35c298ff062422521689258c363ea3579;p=deb_libcec.git diff --git a/src/lib/AdapterCommunication.h b/src/lib/AdapterCommunication.h index 270d96b..badeae9 100644 --- a/src/lib/AdapterCommunication.h +++ b/src/lib/AdapterCommunication.h @@ -31,46 +31,46 @@ * http://www.pulse-eight.net/ */ -#include -#include -#include "../../include/CECExports.h" -#include "../../include/CECTypes.h" +#include +#include "platform/threads.h" #include "util/buffer.h" -#include "util/threads.h" - -class CSerialPort; +#include namespace CEC { - class CCECParser; + class CSerialPort; + class CLibCEC; - class CAdapterCommunication : CThread + class CAdapterCommunication : private CThread { public: - CAdapterCommunication(CCECParser *parser); + CAdapterCommunication(CLibCEC *controller); virtual ~CAdapterCommunication(); - bool Open(const char *strPort, int iBaudRate = 38400, int iTimeoutMs = 10000); - bool Read(cec_frame &msg, int iTimeout = 1000); - bool Write(const cec_frame &frame); + bool Open(const char *strPort, uint16_t iBaudRate = 38400, uint32_t iTimeoutMs = 10000); + bool Read(cec_adapter_message &msg, uint32_t iTimeout = 1000); + bool Write(const cec_adapter_message &frame); + bool PingAdapter(void); void Close(void); - bool IsOpen(void) const { return !m_bStop && m_bStarted; } + bool IsOpen(void) const; std::string GetError(void) const; void *Process(void); + + bool StartBootloader(void); + bool SetAckMask(uint16_t iMask); + static void PushEscaped(cec_adapter_message &vec, uint8_t byte); + static void FormatAdapterMessage(const cec_command &command, cec_adapter_message &packet); + private: - void AddData(uint8_t *data, int iLen); - bool ReadFromDevice(int iTimeout); + void AddData(uint8_t *data, uint8_t iLen); + bool ReadFromDevice(uint32_t iTimeout); CSerialPort * m_port; - CCECParser * m_parser; - uint8_t* m_inbuf; - int m_iInbufSize; - int m_iInbufUsed; - bool m_bStarted; - bool m_bStop; - CMutex m_commMutex; + CLibCEC * m_controller; + CecBuffer m_inBuffer; CMutex m_bufferMutex; - CCondition m_condition; + CMutex m_commMutex; + CCondition m_rcvCondition; }; };