CAdapterCommunication::CAdapterCommunication(CCECProcessor *processor) :
m_port(NULL),
- m_processor(processor)
+ m_processor(processor),
+ m_iLineTimeout(0)
{
m_port = new CSerialPort;
}
return bReturn;
}
+bool CAdapterCommunication::SetLineTimeout(uint8_t iTimeout)
+{
+ bool bReturn(m_iLineTimeout != iTimeout);
+
+ if (!bReturn)
+ {
+ CCECAdapterMessage *output = new CCECAdapterMessage;
+
+ output->push_back(MSGSTART);
+ output->push_escaped(MSGCODE_TRANSMIT_IDLETIME);
+ output->push_escaped(iTimeout);
+ output->push_back(MSGEND);
+
+ if ((bReturn = Write(output)) == false)
+ m_processor->AddLog(CEC_LOG_ERROR, "could not set the idletime");
+ delete output;
+ }
+
+ return bReturn;
+}
+
bool CAdapterCommunication::IsOpen(void) const
{
return !IsStopped() && m_port->IsOpen() && IsRunning();
m_strDeviceName(strDeviceName),
m_controller(controller),
m_bMonitor(false),
- m_busScan(NULL),
- m_iLineTimeout(0)
+ m_busScan(NULL)
{
m_communication = new CAdapterCommunication(this);
m_logicalAddresses.Clear();
m_strDeviceName(strDeviceName),
m_types(types),
m_controller(controller),
- m_bMonitor(false),
- m_iLineTimeout(0)
+ m_bMonitor(false)
{
m_communication = new CAdapterCommunication(this);
m_logicalAddresses.Clear();
return bReturn;
}
-bool CCECProcessor::SetLineTimeout(uint8_t iTimeout)
-{
- bool bReturn(m_iLineTimeout != iTimeout);
-
- if (!bReturn)
- {
- CCECAdapterMessage *output = new CCECAdapterMessage;
-
- output->push_back(MSGSTART);
- output->push_escaped(MSGCODE_TRANSMIT_IDLETIME);
- output->push_escaped(iTimeout);
- output->push_back(MSGEND);
-
- if ((bReturn = Transmit(output)) == false)
- m_controller->AddLog(CEC_LOG_ERROR, "could not set the idletime");
- delete output;
- }
-
- return bReturn;
-}
-
void *CCECProcessor::Process(void)
{
bool bParseFrame(false);
bool bReturn(false);
CLockObject lock(&m_mutex);
{
- SetLineTimeout(3);
+ m_communication->SetLineTimeout(3);
do
{
if (output->tries > 0)
- SetLineTimeout(5);
+ m_communication->SetLineTimeout(5);
CLockObject msgLock(&output->mutex);
if (!m_communication || !m_communication->Write(output))
}while (output->transmit_timeout > 0 && output->needs_retry() && ++output->tries <= output->maxTries);
}
- SetLineTimeout(3);
+ m_communication->SetLineTimeout(3);
return bReturn;
}