* @see cec_get_device_power_status
*/
virtual cec_power_status GetDevicePowerStatus(cec_logical_address iAddress) = 0;
+
+ /*!
+ * @see cec_poll_device
+ */
+ virtual bool PollDevice(cec_logical_address iAddress) = 0;
};
};
extern DECLSPEC cec_power_status cec_get_device_power_status(cec_logical_address iLogicalAddress);
#endif
+/*!
+ * @brief Sends a POLL message to a device.
+ * @param iAddress The device to send the message to.
+ * @return True if the POLL was acked, false otherwise.
+ */
+#ifdef __cplusplus
+extern DECLSPEC int cec_poll_device(CEC::cec_logical_address iLogicalAddress);
+#else
+extern DECLSPEC int cec_poll_device(cec_logical_address iLogicalAddress);
+#endif
+
#ifdef __cplusplus
};
#endif
CEC_OPCODE_SET_SYSTEM_AUDIO_MODE = 0x72,
CEC_OPCODE_SYSTEM_AUDIO_MODE_REQUEST = 0x70,
CEC_OPCODE_SYSTEM_AUDIO_MODE_STATUS = 0x7E,
- CEC_OPCODE_SET_AUDIO_RATE = 0x9A
+ CEC_OPCODE_SET_AUDIO_RATE = 0x9A,
+ CEC_OPCODE_NONE = 0xFD /* when this opcode is set, no opcode will be sent to the device. this is one of the reserved numbers */
} cec_opcode;
typedef enum cec_log_level
static void format(cec_command &command, cec_logical_address initiator, cec_logical_address destination, cec_opcode opcode)
{
command.clear();
- command.initiator = initiator;
- command.destination = destination;
- command.opcode = opcode;
- command.opcode_set = 1;
+ command.initiator = initiator;
+ command.destination = destination;
+ if (opcode != CEC_OPCODE_NONE)
+ {
+ command.opcode = opcode;
+ command.opcode_set = 1;
+ }
}
void push_back(uint8_t data)
// add source and destination
push_back(MSGSTART);
- push_escaped(MSGCODE_TRANSMIT);
+ push_escaped(command.opcode_set == 0 ? (uint8_t)MSGCODE_TRANSMIT_EOM : (uint8_t)MSGCODE_TRANSMIT);
push_back(((uint8_t)command.initiator << 4) + (uint8_t)command.destination);
push_back(MSGEND);
// add opcode
- push_back(MSGSTART);
- push_escaped(command.parameters.empty() ? (uint8_t)MSGCODE_TRANSMIT_EOM : (uint8_t)MSGCODE_TRANSMIT);
- push_back((uint8_t) command.opcode);
- push_back(MSGEND);
-
- // add parameters
- for (int8_t iPtr = 0; iPtr < command.parameters.size; iPtr++)
+ if (command.opcode_set == 1)
{
push_back(MSGSTART);
+ push_escaped(command.parameters.empty() ? (uint8_t)MSGCODE_TRANSMIT_EOM : (uint8_t)MSGCODE_TRANSMIT);
+ push_back((uint8_t) command.opcode);
+ push_back(MSGEND);
- if (iPtr == command.parameters.size - 1)
- push_escaped( MSGCODE_TRANSMIT_EOM);
- else
- push_escaped(MSGCODE_TRANSMIT);
+ // add parameters
+ for (int8_t iPtr = 0; iPtr < command.parameters.size; iPtr++)
+ {
+ push_back(MSGSTART);
- push_escaped(command.parameters[iPtr]);
+ if (iPtr == command.parameters.size - 1)
+ push_escaped( MSGCODE_TRANSMIT_EOM);
+ else
+ push_escaped(MSGCODE_TRANSMIT);
- push_back(MSGEND);
+ push_escaped(command.parameters[iPtr]);
+
+ push_back(MSGEND);
+ }
}
// set timeout
void CCECProcessor::LogOutput(const cec_command &data)
{
CStdString strTx;
- strTx.Format("<< %02x:%02x", ((uint8_t)data.initiator << 4) + (uint8_t)data.destination, (uint8_t)data.opcode);
+ strTx.Format("<< %02x", ((uint8_t)data.initiator << 4) + (uint8_t)data.destination);
+ if (data.opcode_set)
+ strTx.AppendFormat(":%02x", (uint8_t)data.opcode);
for (uint8_t iPtr = 0; iPtr < data.parameters.size; iPtr++)
strTx.AppendFormat(":%02x", data.parameters[iPtr]);
return SetAckMask(0x1 << (uint8_t)m_iLogicalAddress);
}
+bool CCECProcessor::PollDevice(cec_logical_address iAddress)
+{
+ if (iAddress != CECDEVICE_UNKNOWN && m_busDevices[iAddress])
+ return m_busDevices[iAddress]->PollDevice();
+ return false;
+}
+
cec_version CCECProcessor::GetDeviceCecVersion(cec_logical_address iAddress)
{
return m_busDevices[iAddress]->GetCecVersion();
virtual bool SetLogicalAddress(cec_logical_address iLogicalAddress);
virtual bool SetPhysicalAddress(uint16_t iPhysicalAddress);
virtual bool SwitchMonitoring(bool bEnable);
+ virtual bool PollDevice(cec_logical_address iAddress);
virtual bool Transmit(const cec_command &data);
virtual bool Transmit(CCECAdapterMessage *output);
return CEC_POWER_STATUS_UNKNOWN;
}
+bool CLibCEC::PollDevice(cec_logical_address iAddress)
+{
+ if (m_cec && iAddress >= CECDEVICE_TV && iAddress < CECDEVICE_BROADCAST)
+ return m_cec->PollDevice(iAddress);
+ return false;
+}
+
void CLibCEC::AddLog(cec_log_level level, const string &strMessage)
{
if (m_cec)
virtual bool GetDeviceMenuLanguage(cec_logical_address iAddress, cec_menu_language *language);
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 void AddLog(cec_log_level level, const std::string &strMessage);
return CEC_POWER_STATUS_UNKNOWN;
}
+int cec_poll_device(cec_logical_address iLogicalAddress)
+{
+ if (cec_parser)
+ return cec_parser->PollDevice(iLogicalAddress);
+ return -1;
+}
+
//@}
return m_powerStatus;
}
+
+bool CCECBusDevice::PollDevice(void)
+{
+ bool bReturn(false);
+
+ CStdString strLog;
+ strLog.Format("<< sending POLL from device %1x to device %1x", (int8_t)GetMyLogicalAddress(), m_iLogicalAddress);
+ AddLog(CEC_LOG_DEBUG, strLog);
+
+ cec_command command;
+ cec_command::format(command, GetMyLogicalAddress(), m_iLogicalAddress, CEC_OPCODE_NONE);
+ CLockObject lock(&m_mutex);
+
+ bReturn = m_processor->Transmit(command);
+ AddLog(CEC_LOG_DEBUG, bReturn ? ">> POLL sent" : ">> POLL not sent");
+ return bReturn;
+}
virtual cec_version GetCecVersion(bool bRefresh = true);
virtual cec_menu_language & GetMenuLanguage(bool bRefresh = true);
virtual cec_power_status GetPowerStatus(bool bRefresh = true);
+ virtual bool PollDevice(void);
virtual bool PowerOn(void);
virtual bool Standby(void);
"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 <<
"[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 <<
cout << "invalid destination" << endl;
}
}
+ else if (command == "poll")
+ {
+ string strValue;
+ uint8_t iValue = 0;
+ if (GetWord(input, strValue) && HexStrToInt(strValue, iValue) && iValue <= 0xF)
+ {
+ if (parser->PollDevice((cec_logical_address) iValue))
+ cout << "POLL message sent" << endl;
+ else
+ cout << "POLL message not sent" << endl;
+ }
+ else
+ {
+ cout << "invalid destination" << endl;
+ }
+ }
else if (command == "la")
{
string strvalue;