X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Flib%2FAdapterCommunication.h;h=31de379e1350ac131529590e095ae2dd7bac2ee6;hb=5d5a2dc2f0200aff181c385ce71672e1c50b7de1;hp=91e5ee64a0de2a283e2af2832d01334e45b886ea;hpb=e41b06f9e1fc5c8af372eabf338dbb691ee7ac4c;p=deb_libcec.git diff --git a/src/lib/AdapterCommunication.h b/src/lib/AdapterCommunication.h index 91e5ee6..31de379 100644 --- a/src/lib/AdapterCommunication.h +++ b/src/lib/AdapterCommunication.h @@ -36,8 +36,6 @@ #include "util/buffer.h" #include "util/StdString.h" #include -#include -#include namespace CEC { @@ -51,19 +49,20 @@ namespace CEC } cec_adapter_message_state; - class CCECAdapterMessage : public boost::enable_shared_from_this + class CCECAdapterMessage { public: CCECAdapterMessage(void) { clear(); } CCECAdapterMessage(const cec_command &command); CCECAdapterMessage &operator =(const CCECAdapterMessage &msg); CStdString ToString(void) const; + CStdString MessageCodeAsString(void) const; bool empty(void) const { return packet.empty(); } uint8_t operator[](uint8_t pos) const { return packet[pos]; } uint8_t at(uint8_t pos) const { return packet[pos]; } uint8_t size(void) const { return packet.size; } - void clear(void) { state = ADAPTER_MESSAGE_STATE_UNKNOWN; packet.clear(); } + void clear(void) { state = ADAPTER_MESSAGE_STATE_UNKNOWN; transmit_timeout = 0; packet.clear(); } void shift(uint8_t iShiftBy) { packet.shift(iShiftBy); } void push_back(uint8_t add) { packet.push_back(add); } cec_adapter_messagecode message(void) const { return packet.size >= 1 ? (cec_adapter_messagecode) (packet.at(0) & ~(MSGCODE_FRAME_EOM | MSGCODE_FRAME_ACK)) : MSGCODE_NOTHING; } @@ -76,10 +75,10 @@ namespace CEC cec_datapacket packet; cec_adapter_message_state state; + int32_t transmit_timeout; CMutex mutex; CCondition condition; }; - typedef boost::shared_ptr CCECAdapterMessagePtr; class CSerialPort; class CLibCEC; @@ -92,7 +91,7 @@ namespace CEC 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; @@ -101,7 +100,6 @@ namespace CEC void *Process(void); bool StartBootloader(void); - bool SetAckMask(uint16_t iMask); private: void WriteNextCommand(void); @@ -111,7 +109,7 @@ namespace CEC CSerialPort * m_port; CLibCEC * m_controller; CecBuffer m_inBuffer; - CecBuffer m_outBuffer; + CecBuffer m_outBuffer; CMutex m_mutex; CCondition m_rcvCondition; CCondition m_startCondition;