From: Lars Op den Kamp Date: Tue, 25 Oct 2011 22:19:09 +0000 (+0200) Subject: cec: added SwitchMonitoring()/cec_switch_monitoring() to the interface. when monitori... X-Git-Tag: upstream/2.2.0~1^2~222 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=8b7e5ff605864004b8a66520202bf05aecb4fc6c;p=deb_libcec.git cec: added SwitchMonitoring()/cec_switch_monitoring() to the interface. when monitoring is enabled, the device will only log the data it received, but will not respond to any message --- diff --git a/include/cec.h b/include/cec.h index c23c35a..6356455 100644 --- a/include/cec.h +++ b/include/cec.h @@ -134,6 +134,11 @@ namespace CEC * @see cec_set_osd_string */ virtual bool SetOSDString(cec_logical_address iLogicalAddress, cec_display_control duration, const char *strMessage) = 0; + + /*! + * @see cec_switch_monitoring + */ + virtual bool SwitchMonitoring(bool bEnable) = 0; }; }; diff --git a/include/cecc.h b/include/cecc.h index c319c19..1c9a987 100644 --- a/include/cecc.h +++ b/include/cecc.h @@ -213,6 +213,8 @@ extern DECLSPEC int cec_set_osd_string(CEC::cec_logical_address iLogicalAddress, extern DECLSPEC int cec_set_osd_string(cec_logical_address iLogicalAddress, cec_display_control duration, const char *strMessage); #endif +extern DECLSPEC int cec_switch_monitoring(int bEnable); + #ifdef __cplusplus }; #endif diff --git a/include/cectypes.h b/include/cectypes.h index 004ea06..e6c953e 100644 --- a/include/cectypes.h +++ b/include/cectypes.h @@ -700,7 +700,7 @@ typedef enum cec_vendor_id #define MSGESC 0xFD #define ESCOFFSET 3 #define CEC_MIN_VERSION 6 -#define CEC_LIB_VERSION 7 +#define CEC_LIB_VERSION 8 #define CEC_BUTTON_TIMEOUT 500 #ifdef __cplusplus diff --git a/src/lib/CECProcessor.cpp b/src/lib/CECProcessor.cpp index c19890b..31f8803 100644 --- a/src/lib/CECProcessor.cpp +++ b/src/lib/CECProcessor.cpp @@ -45,7 +45,8 @@ CCECProcessor::CCECProcessor(CLibCEC *controller, CAdapterCommunication *serComm m_iLogicalAddress(iLogicalAddress), m_strDeviceName(strDeviceName), m_communication(serComm), - m_controller(controller) + m_controller(controller), + m_bMonitor(false) { for (uint8_t iPtr = 0; iPtr < 16; iPtr++) m_vendorIds[iPtr] = CEC_VENDOR_UNKNOWN; @@ -237,6 +238,19 @@ bool CCECProcessor::SetOSDString(cec_logical_address iLogicalAddress, cec_displa return Transmit(command); } +bool CCECProcessor::SwitchMonitoring(bool bEnable) +{ + CStdString strLog; + strLog.Format("== %s monitoring mode ==", bEnable ? "enabling" : "disabling"); + m_controller->AddLog(CEC_LOG_NOTICE, strLog.c_str()); + + m_bMonitor = bEnable; + if (bEnable) + return m_communication && m_communication->SetAckMask(0); + else + return m_communication && m_communication->SetAckMask(0x1 << (uint8_t)m_iLogicalAddress); +} + bool CCECProcessor::TransmitFormatted(const cec_adapter_message &data, bool bWaitForAck /* = true */) { CLockObject lock(&m_mutex); @@ -538,6 +552,9 @@ void CCECProcessor::ParseCommand(cec_command &command) } m_controller->AddLog(CEC_LOG_DEBUG, dataStr.c_str()); + if (m_bMonitor) + return; + if (command.destination == m_iLogicalAddress) { switch(command.opcode) diff --git a/src/lib/CECProcessor.h b/src/lib/CECProcessor.h index dd0596e..5ff3e62 100644 --- a/src/lib/CECProcessor.h +++ b/src/lib/CECProcessor.h @@ -60,6 +60,7 @@ namespace CEC virtual bool SetLogicalAddress(cec_logical_address iLogicalAddress); virtual bool SetPhysicalAddress(uint16_t iPhysicalAddress); virtual bool SetOSDString(cec_logical_address iLogicalAddress, cec_display_control duration, const char *strMessage); + virtual bool SwitchMonitoring(bool bEnable); static const char *CECVendorIdToString(const uint64_t iVendorId); @@ -91,5 +92,6 @@ namespace CEC CLibCEC *m_controller; uint64_t m_vendorIds[16]; uint8_t m_vendorClasses[16]; + bool m_bMonitor; }; }; diff --git a/src/lib/LibCEC.cpp b/src/lib/LibCEC.cpp index 7c0f792..9742795 100644 --- a/src/lib/LibCEC.cpp +++ b/src/lib/LibCEC.cpp @@ -198,6 +198,11 @@ bool CLibCEC::SetOSDString(cec_logical_address iLogicalAddress, cec_display_cont return m_cec ? m_cec->SetOSDString(iLogicalAddress, duration, strMessage) : false; } +bool CLibCEC::SwitchMonitoring(bool bEnable) +{ + return m_cec ? m_cec->SwitchMonitoring(bEnable) : false; +} + void CLibCEC::AddLog(cec_log_level level, const string &strMessage) { if (m_cec) diff --git a/src/lib/LibCEC.h b/src/lib/LibCEC.h index 8ea0c98..968d615 100644 --- a/src/lib/LibCEC.h +++ b/src/lib/LibCEC.h @@ -72,6 +72,7 @@ namespace CEC virtual bool SetActiveView(void); virtual bool SetInactiveView(void); virtual bool SetOSDString(cec_logical_address iLogicalAddress, cec_display_control duration, const char *strMessage); + virtual bool SwitchMonitoring(bool bEnable); //@} virtual void AddLog(cec_log_level level, const std::string &strMessage); diff --git a/src/lib/LibCECC.cpp b/src/lib/LibCECC.cpp index d062dff..7915765 100644 --- a/src/lib/LibCECC.cpp +++ b/src/lib/LibCECC.cpp @@ -180,4 +180,11 @@ int cec_set_osd_string(cec_logical_address iLogicalAddress, cec_display_control return -1; } +int cec_switch_monitoring(int bEnable) +{ + if (cec_parser) + return cec_parser->SwitchMonitoring(bEnable == 1) ? 1 : 0; + return -1; +} + //@} diff --git a/src/testclient/main.cpp b/src/testclient/main.cpp index 2939c60..b13f446 100644 --- a/src/testclient/main.cpp +++ b/src/testclient/main.cpp @@ -43,7 +43,7 @@ using namespace CEC; using namespace std; -#define CEC_TEST_CLIENT_VERSION 7 +#define CEC_TEST_CLIENT_VERSION 8 #include @@ -186,6 +186,7 @@ void show_console_help(void) "osd {addr} {string} set OSD message on the specified device." << endl << "[osd 0 Test Message] displays 'Test Message' on the TV" << endl << endl << + "[mon] {1|0} enable or disable CEC bus monitoring." << endl << "[ping] send a ping command to the CEC adapter." << endl << "[bl] to let the adapter enter the bootloader, to upgrade" << endl << " the flash rom." << endl << @@ -365,6 +366,14 @@ int main (int argc, char *argv[]) { parser->PingAdapter(); } + else if (command == "mon") + { + CStdString strEnable; + if (GetWord(input, strEnable) && (strEnable.Equals("0") || strEnable.Equals("1"))) + { + parser->SwitchMonitoring(strEnable.Equals("1")); + } + } else if (command == "bl") { parser->StartBootloader();