* @return True if the POLL was acked, false otherwise.
*/
virtual bool PollDevice(cec_logical_address iAddress) = 0;
+
+ /*!
+ * @return The devices that are active on the bus and not handled by libcec.
+ */
+ virtual cec_logical_addresses GetActiveDevices(void) = 0;
+
+ /*!
+ * @brief Check whether a device is active on the bus.
+ * @param iAddress The address to check.
+ * @return True when active, false otherwise.
+ */
+ virtual bool IsActiveDevice(cec_logical_address iAddress) = 0;
+
+ /*!
+ * @brief Check whether a device of the given type is active on the bus.
+ * @param type The type to check.
+ * @return True when active, false otherwise.
+ */
+ virtual bool IsActiveDeviceType(cec_device_type type) = 0;
};
};
extern DECLSPEC int cec_poll_device(cec_logical_address iLogicalAddress);
#endif
+#ifdef __cplusplus
+extern DECLSPEC CEC::cec_logical_addresses cec_get_active_devices(void);
+#else
+extern DECLSPEC cec_logical_addresses cec_get_active_devices(void);
+#endif
+
+#ifdef __cplusplus
+extern DECLSPEC int cec_is_active_device(CEC::cec_logical_address iAddress);
+#else
+extern DECLSPEC int cec_is_active_device(cec_logical_address iAddress);
+#endif
+
+#ifdef __cplusplus
+extern DECLSPEC int cec_is_active_device_type(CEC::cec_device_type type);
+#else
+extern DECLSPEC int cec_is_active_device_type(cec_device_type type);
+#endif
+
#ifdef __cplusplus
};
#endif
m_busDevices[(uint8_t)command.initiator]->HandleCommand(command);
}
+cec_logical_addresses CCECProcessor::GetActiveDevices(void)
+{
+ cec_logical_addresses addresses;
+ for (unsigned int iPtr = 0; iPtr < 15; iPtr++)
+ {
+ if (m_busDevices[iPtr]->GetStatus() == CEC_DEVICE_STATUS_PRESENT)
+ addresses.Set((cec_logical_address) iPtr);
+ }
+ return addresses;
+}
+
+bool CCECProcessor::IsActiveDevice(cec_logical_address address)
+{
+ return m_busDevices[address]->GetStatus() == CEC_DEVICE_STATUS_PRESENT;
+}
+
+bool CCECProcessor::IsActiveDeviceType(cec_device_type type)
+{
+ cec_logical_addresses activeDevices = GetActiveDevices();
+ for (unsigned int iPtr = 0; iPtr < 15; iPtr++)
+ if (activeDevices.IsSet((cec_logical_address) iPtr) && m_busDevices[iPtr]->GetType() == type)
+ return true;
+ return false;
+}
+
uint16_t CCECProcessor::GetPhysicalAddress(void) const
{
if (!m_logicalAddresses.IsEmpty() && m_busDevices[m_logicalAddresses.primary])
virtual cec_power_status GetDevicePowerStatus(cec_logical_address iAddress);
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 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);
virtual uint16_t GetPhysicalAddress(void) const;
virtual bool SetActiveView(void);
return false;
}
+cec_logical_addresses CLibCEC::GetActiveDevices(void)
+{
+ cec_logical_addresses addresses;
+ if (m_cec)
+ addresses = m_cec->GetActiveDevices();
+ return addresses;
+}
+
+bool CLibCEC::IsActiveDevice(cec_logical_address iAddress)
+{
+ if (m_cec && iAddress >= CECDEVICE_TV && iAddress < CECDEVICE_BROADCAST)
+ return m_cec->IsActiveDevice(iAddress);
+ return false;
+}
+
+bool CLibCEC::IsActiveDeviceType(cec_device_type type)
+{
+ if (m_cec && type >= CEC_DEVICE_TYPE_TV && type <= CEC_DEVICE_TYPE_AUDIO_SYSTEM)
+ return m_cec->IsActiveDeviceType(type);
+ return false;
+}
+
void CLibCEC::AddLog(cec_log_level level, const string &strMessage)
{
if (m_cec)
virtual uint64_t GetDeviceVendorId(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);
+ virtual bool IsActiveDevice(cec_logical_address iAddress);
+ virtual bool IsActiveDeviceType(cec_device_type type);
//@}
virtual void AddLog(cec_log_level level, const std::string &strMessage);
int cec_poll_device(cec_logical_address iLogicalAddress)
{
if (cec_parser)
- return cec_parser->PollDevice(iLogicalAddress);
+ return cec_parser->PollDevice(iLogicalAddress) ? 1 : 0;
+ return -1;
+}
+
+cec_logical_addresses cec_get_active_devices(void)
+{
+ cec_logical_addresses addresses;
+ if (cec_parser)
+ addresses = cec_parser->GetActiveDevices();
+ return addresses;
+}
+
+int cec_is_active_device(cec_logical_address iAddress)
+{
+ if (cec_parser)
+ return cec_parser->IsActiveDevice(iAddress) ? 1 : 0;
+ return -1;
+}
+
+int cec_is_active_device_type(cec_device_type type)
+{
+ if (cec_parser)
+ return cec_parser->IsActiveDeviceType(type) ? 1 : 0;
return -1;
}
endl <<
"tx {bytes} transfer bytes over the CEC line." << endl <<
"txn {bytes} transfer bytes but don't wait for transmission ACK." << endl <<
- "[tx 40 00 FF 11 22 33] sends bytes 0x40 0x00 0xFF 0x11 0x22 0x33" << endl <<
- endl <<
"on {address} power on the device with the given logical address." << endl <<
- "[on 5] power on a connected audio system" << endl <<
- endl <<
"standby {address} put the device with the given address in standby mode." << endl <<
- "[standby 0] powers off the TV" << endl <<
- endl <<
"la {logical_address} change the logical address of the CEC adapter." << endl <<
- "[la 4] logical address 4" << endl <<
- endl <<
"pa {physical_address} change the physical address of the CEC adapter." << endl <<
- "[pa 10 00] physical address 1.0.0.0" << endl <<
- endl <<
"osd {addr} {string} set OSD message on the specified device." << endl <<
- "[osd 0 Test Message] displays 'Test Message' on the TV" << endl <<
- endl <<
"ver {addr} get the CEC version of the specified device." << endl <<
- "[ver 0] get the CEC version of the TV" << endl <<
- endl <<
"ven {addr} get the vendor ID of the specified device." << endl <<
- "[ven 0] get the vendor ID of the TV" << endl <<
- endl <<
"lang {addr} get the menu language of the specified device." << endl <<
- "[lang 0] get the menu language of the TV" << endl <<
- endl <<
"pow {addr} get the power status of the specified device." << endl <<
- "[pow 0] get the power status of the TV" << endl <<
- endl <<
"poll {addr} poll the specified device." << endl <<
- "[poll 0] sends a poll message to the TV" << endl <<
- endl <<
+ "lad lists active devices on the bus" << endl <<
+ "ad {addr} checks whether the specified device is active." << endl <<
+ "at {type} checks whether the specified device type is active." << endl <<
"[mon] {1|0} enable or disable CEC bus monitoring." << endl <<
"[log] {1 - 31} change the log level. see cectypes.h for values." << endl <<
"[ping] send a ping command to the CEC adapter." << endl <<
}
}
}
+ else if (command == "lad")
+ {
+ cout << "listing active devices:" << endl;
+ cec_logical_addresses addresses = parser->GetActiveDevices();
+ for (unsigned iPtr = 0; iPtr < 16; iPtr++)
+ if (addresses[iPtr])
+ cout << "logical address " << iPtr << endl;
+ }
+ else if (command == "ad")
+ {
+ CStdString strDev;
+ if (GetWord(input, strDev))
+ {
+ int iDev = atoi(strDev);
+ if (iDev >= 0 && iDev < 15)
+ cout << "logical address " << iDev << " is " << (parser->IsActiveDevice((cec_logical_address)iDev) ? "active" : "not active") << endl;
+ }
+ }
+ else if (command == "at")
+ {
+ CStdString strType;
+ if (GetWord(input, strType))
+ {
+ cec_device_type type = CEC_DEVICE_TYPE_TV;
+ if (strType.Equals("a"))
+ type = CEC_DEVICE_TYPE_AUDIO_SYSTEM;
+ else if (strType.Equals("p"))
+ type = CEC_DEVICE_TYPE_PLAYBACK_DEVICE;
+ else if (strType.Equals("r"))
+ type = CEC_DEVICE_TYPE_RECORDING_DEVICE;
+ else if (strType.Equals("t"))
+ type = CEC_DEVICE_TYPE_TUNER;
+ cout << "device " << type << " is " << (parser->IsActiveDeviceType(type) ? "active" : "not active") << endl;
+ }
+ }
else if (command == "r")
{
cout << "closing the connection" << endl;