CLockObject lock(m_mutex);
/* set the ackmask to 0 before closing the connection */
- if (IsRunning() && m_port->IsOpen() && m_port->GetErrorNumber() == 0)
+ if (IsOpen() && m_port->GetErrorNumber() == 0)
{
LIB_CEC->AddLog(CEC_LOG_DEBUG, "%s - closing the connection", __FUNCTION__);
SetAckMask(0);
bool CUSBCECAdapterCommunication::WriteToDevice(CCECAdapterMessage *message)
{
CLockObject adapterLock(m_mutex);
- if (!m_port->IsOpen())
+ if (!IsOpen())
{
LIB_CEC->AddLog(CEC_LOG_DEBUG, "error writing command '%s' to serial port '%s': the connection is closed", CCECAdapterMessage::ToString(message->Message()), m_port->GetName().c_str());
message->state = ADAPTER_MESSAGE_STATE_ERROR;
/* read from the serial port */
{
CLockObject lock(m_mutex);
- if (!m_port || !m_port->IsOpen())
+ if (!IsOpen())
return false;
iBytesRead = m_port->Read(buff, sizeof(uint8_t) * iSize, iTimeout);
CCECAdapterMessage *CUSBCECAdapterCommunication::SendCommand(cec_adapter_messagecode msgCode, CCECAdapterMessage ¶ms, bool bIsRetry /* = false */)
{
- if (!m_port || !m_port->IsOpen() ||
- !m_adapterMessageQueue)
+ if (!m_port->IsOpen() || !m_adapterMessageQueue)
return NULL;
/* create the adapter message for this command */
if (m_iAckMask == iMask)
return true;
- if (m_port && m_port->IsOpen() && m_commands->SetAckMask(iMask))
+ if (IsOpen() && m_commands->SetAckMask(iMask))
{
m_iAckMask = iMask;
return true;
}
+ LIB_CEC->AddLog(CEC_LOG_ERROR, "couldn't change the ackmask: the connection is closed");
return false;
}
bool CUSBCECAdapterCommunication::PingAdapter(void)
{
- return m_port->IsOpen() ? m_commands->PingAdapter() : false;
+ return IsOpen() ? m_commands->PingAdapter() : false;
}
uint16_t CUSBCECAdapterCommunication::GetFirmwareVersion(void)
{
- return m_commands->GetFirmwareVersion();
+ return IsOpen() ? m_commands->GetFirmwareVersion() : CEC_FW_VERSION_UNKNOWN;
}
uint32_t CUSBCECAdapterCommunication::GetFirmwareBuildDate(void)
{
- return m_commands->RequestBuildDate();
+ return IsOpen() ? m_commands->RequestBuildDate() : 0;
}
bool CUSBCECAdapterCommunication::IsRunningLatestFirmware(void)
bool CUSBCECAdapterCommunication::PersistConfiguration(const libcec_configuration &configuration)
{
- return m_port->IsOpen() ? m_commands->PersistConfiguration(configuration) : false;
+ return IsOpen() ? m_commands->PersistConfiguration(configuration) : false;
}
bool CUSBCECAdapterCommunication::GetConfiguration(libcec_configuration &configuration)
{
- return m_port->IsOpen() ? m_commands->GetConfiguration(configuration) : false;
+ return IsOpen() ? m_commands->GetConfiguration(configuration) : false;
}
CStdString CUSBCECAdapterCommunication::GetPortName(void)
bool CUSBCECAdapterCommunication::SetControlledMode(bool controlled)
{
- return m_port->IsOpen() ? m_commands->SetControlledMode(controlled) : false;
+ return IsOpen() ? m_commands->SetControlledMode(controlled) : false;
}
void *CAdapterPingThread::Process(void)