cec: add GetDevicePhysicalAddress()/cec_get_device_physical_address()
authorLars Op den Kamp <lars@opdenkamp.eu>
Wed, 7 Dec 2011 21:21:37 +0000 (22:21 +0100)
committerLars Op den Kamp <lars@opdenkamp.eu>
Wed, 7 Dec 2011 21:23:21 +0000 (22:23 +0100)
include/cec.h
include/cecc.h
src/lib/CECProcessor.cpp
src/lib/CECProcessor.h
src/lib/LibCEC.cpp
src/lib/LibCEC.h
src/lib/LibCECC.cpp
src/testclient/main.cpp

index 44bf0244abdb8e6f5dbe29f59be811a28431223f..c5f0522c20b22d7a255cafeb656e90913f45bef2 100644 (file)
@@ -251,6 +251,13 @@ namespace CEC
      */
     virtual cec_power_status GetDevicePowerStatus(cec_logical_address iAddress) = 0;
 
+    /*!
+     * @brief Get the physical address of the device with the given logical address.
+     * @param iLogicalAddress The device to get the vendor id for.
+     * @return The physical address or 0 if it wasn't found.
+     */
+    virtual uint16_t GetDevicePhysicalAddress(cec_logical_address iAddress) = 0;
+
     /*!
      * @brief Sends a POLL message to a device.
      * @param iAddress The device to send the message to.
index d433b3ebc50cfcf65482de567a116cf9cd5efafd..65086068aee6cf76cd6346ad3a1203b216ecef41 100644 (file)
@@ -173,6 +173,12 @@ extern DECLSPEC uint64_t cec_get_device_vendor_id(CEC::cec_logical_address iLogi
 extern DECLSPEC uint64_t cec_get_device_vendor_id(cec_logical_address iLogicalAddress);
 #endif
 
+#ifdef __cplusplus
+extern DECLSPEC uint16_t cec_get_device_physical_address(CEC::cec_logical_address iLogicalAddress);
+#else
+extern DECLSPEC uint16_t cec_get_device_physical_address(cec_logical_address iLogicalAddress);
+#endif
+
 #ifdef __cplusplus
 extern DECLSPEC CEC::cec_power_status cec_get_device_power_status(CEC::cec_logical_address iLogicalAddress);
 #else
index 1daa7b60d2d8d421f879fa9b530ce07039725b1f..46e3419d484c38ddc2a8aea86b9cd99c5157ed92 100644 (file)
@@ -521,6 +521,7 @@ bool CCECProcessor::SetPhysicalAddress(uint16_t iPhysicalAddress)
     for (uint8_t iPtr = 0; iPtr < 15; iPtr++)
       if (m_logicalAddresses[iPtr])
       {
+        m_busDevices[iPtr]->SetInactiveDevice();
         m_busDevices[iPtr]->SetPhysicalAddress(iPhysicalAddress);
         m_busDevices[iPtr]->TransmitPhysicalAddress();
       }
@@ -669,6 +670,13 @@ uint64_t CCECProcessor::GetDeviceVendorId(cec_logical_address iAddress)
   return false;
 }
 
+uint16_t CCECProcessor::GetDevicePhysicalAddress(cec_logical_address iAddress)
+{
+  if (m_busDevices[iAddress])
+    return m_busDevices[iAddress]->GetPhysicalAddress(false);
+  return false;
+}
+
 cec_power_status CCECProcessor::GetDevicePowerStatus(cec_logical_address iAddress)
 {
   if (m_busDevices[iAddress])
index 75196eacaba51f516e1490e87694d0120ec94210..bdf5233631b69400c5bcae03f9f27ac7eb3b6cf1 100644 (file)
@@ -68,6 +68,7 @@ namespace CEC
       virtual cec_logical_address   GetLogicalAddress(void) const { return m_logicalAddresses.primary; }
       virtual cec_logical_addresses GetLogicalAddresses(void) const { return m_logicalAddresses; }
       virtual cec_logical_addresses GetActiveDevices(void);
+      virtual uint16_t              GetDevicePhysicalAddress(cec_logical_address iAddress);
       virtual bool                  HasLogicalAddress(cec_logical_address address) const { return m_logicalAddresses.IsSet(address); }
       virtual bool                  IsActiveDevice(cec_logical_address address);
       virtual bool                  IsActiveDeviceType(cec_device_type type);
index ebaae2db4584f4f04693adced24a9fc3fdf2f8ee..adf0132682213835563ba404429b8f1722a55f53 100644 (file)
@@ -222,6 +222,13 @@ uint64_t CLibCEC::GetDeviceVendorId(cec_logical_address iAddress)
   return 0;
 }
 
+uint16_t CLibCEC::GetDevicePhysicalAddress(cec_logical_address iAddress)
+{
+  if (m_cec && iAddress >= CECDEVICE_TV && iAddress < CECDEVICE_BROADCAST)
+    return m_cec->GetDevicePhysicalAddress(iAddress);
+  return 0;
+}
+
 cec_power_status CLibCEC::GetDevicePowerStatus(cec_logical_address iAddress)
 {
   if (m_cec && iAddress >= CECDEVICE_TV && iAddress < CECDEVICE_BROADCAST)
index a0a4ddc373cdd97fdeb2c50996acdf9a4e28d9ef..9bff00f28fd4dd5dde5ecdab64182bbcf30971f6 100644 (file)
@@ -82,6 +82,7 @@ namespace CEC
       virtual cec_version GetDeviceCecVersion(cec_logical_address iAddress);
       virtual bool GetDeviceMenuLanguage(cec_logical_address iAddress, cec_menu_language *language);
       virtual uint64_t GetDeviceVendorId(cec_logical_address iAddress);
+      virtual uint16_t GetDevicePhysicalAddress(cec_logical_address iAddress);
       virtual cec_power_status GetDevicePowerStatus(cec_logical_address iAddress);
       virtual bool PollDevice(cec_logical_address iAddress);
       virtual cec_logical_addresses GetActiveDevices(void);
index dc63c2927794ae768d1fd0698af1686036f6d778..ffa8f5561dfc7fd3c4755c1ac1bf652a5148c0a5 100644 (file)
@@ -247,6 +247,13 @@ uint64_t cec_get_device_vendor_id(cec_logical_address iLogicalAddress)
   return 0;
 }
 
+uint16_t cec_get_device_physical_address(cec_logical_address iLogicalAddress)
+{
+  if (cec_parser)
+    return cec_parser->GetDevicePhysicalAddress(iLogicalAddress);
+  return 0;
+}
+
 cec_power_status cec_get_device_power_status(cec_logical_address iLogicalAddress)
 {
   if (cec_parser)
index 7837c12a6a970554a7b569a52e069a78065fd426..c1f3bf7536952edcd7f95de304bea5c4012f7d22 100644 (file)
@@ -720,15 +720,19 @@ bool ProcessCommandSCAN(ICECAdapter *parser, const string &command, string &argu
     {
       if (addresses[iPtr])
       {
-        uint64_t iVendorId      = parser->GetDeviceVendorId((cec_logical_address)iPtr);
-        cec_version iCecVersion = parser->GetDeviceCecVersion((cec_logical_address)iPtr);
-        cec_power_status power  = parser->GetDevicePowerStatus((cec_logical_address)iPtr);
-        cec_osd_name osdName    = parser->GetOSDName((cec_logical_address)iPtr);
+        uint16_t iPhysicalAddress = parser->GetDevicePhysicalAddress((cec_logical_address)iPtr);
+        uint64_t iVendorId        = parser->GetDeviceVendorId((cec_logical_address)iPtr);
+        cec_version iCecVersion   = parser->GetDeviceCecVersion((cec_logical_address)iPtr);
+        cec_power_status power    = parser->GetDevicePowerStatus((cec_logical_address)iPtr);
+        cec_osd_name osdName      = parser->GetOSDName((cec_logical_address)iPtr);
+        CStdString strAddr;
+        strAddr.Format("%04x", iPhysicalAddress);
         cec_menu_language lang;
         lang.device = CECDEVICE_UNKNOWN;
         parser->GetDeviceMenuLanguage((cec_logical_address)iPtr, &lang);
 
         cout << "device #" << (int)iPtr << ": " << parser->ToString((cec_logical_address)iPtr) << endl;
+        cout << "address:      " << strAddr.c_str() << endl;
         cout << "vendor:       " << parser->ToString((cec_vendor_id)iVendorId) << endl;
         cout << "osd string:   " << osdName.name << endl;
         cout << "CEC version:  " << parser->ToString(iCecVersion) << endl;