-#include <config.h>
#include <lib/dvb/dvb.h>
#include <lib/base/eerror.h>
#include <errno.h>
return -1; // already opened
m_state=0;
- m_curVoltage=voltageOff;
m_tuning=0;
#if HAVE_DVB_API_VERSION < 3
setVoltage(iDVBFrontend::voltageOff);
::close(m_fd);
m_fd=-1;
+ m_data[0] = m_data[1] = m_data[2] = -1;
}
#if HAVE_DVB_API_VERSION < 3
if (m_secfd >= 0)
void eDVBFrontend::timeout()
{
- int state;
+ m_tuning = 0;
if (m_state == stateTuning)
{
- state = stateFailed;
- eDebug("DVBFrontend: timeout");
- if (m_state != state)
- {
- m_state = state;
- m_stateChanged(this);
- }
- m_tuning = 0;
- } else
- m_tuning = 0;
+ m_state = stateFailed;
+ m_stateChanged(this);
+ }
}
int eDVBFrontend::readFrontendData(int type)
setVoltage(voltage);
break;
}
+ case eSecCommand::IF_VOLTAGE_GOTO:
+ {
+ eSecCommand::pair &compare = m_sec_sequence.current()->compare;
+ if ( compare.voltage == m_curVoltage && setSecSequencePos(compare.steps) )
+ break;
+ ++m_sec_sequence.current();
+ break;
+ }
+ case eSecCommand::IF_NOT_VOLTAGE_GOTO:
+ {
+ eSecCommand::pair &compare = m_sec_sequence.current()->compare;
+ if ( compare.voltage != m_curVoltage && setSecSequencePos(compare.steps) )
+ break;
+ ++m_sec_sequence.current();
+ break;
+ }
case eSecCommand::SET_TONE:
eDebug("[SEC] setTone %d", m_sec_sequence.current()->tone);
setTone(m_sec_sequence.current()++->tone);
setFrontend();
++m_sec_sequence.current();
break;
- case eSecCommand::MEASURE_IDLE_INPUTPOWER:
- {
- int idx = m_sec_sequence.current()++->val;
- if ( idx == 0 || idx == 1 )
- {
- m_idleInputpower[idx] = readInputpower();
- eDebug("[SEC] idleInputpower[%d] is %d", idx, m_idleInputpower[idx]);
- }
- else
- eDebug("[SEC] idleInputpower measure index(%d) out of bound !!!", idx);
- break;
- }
- case eSecCommand::MEASURE_RUNNING_INPUTPOWER:
- m_runningInputpower = readInputpower();
- eDebug("[SEC] runningInputpower is %d", m_runningInputpower);
- ++m_sec_sequence.current();
- break;
case eSecCommand::SET_TIMEOUT:
m_timeoutCount = m_sec_sequence.current()++->val;
eDebug("[SEC] set timeout %d", m_timeoutCount);
break;
- case eSecCommand::UPDATE_CURRENT_ROTORPARAMS:
- m_data[5] = m_data[3];
- m_data[6] = m_data[4];
- eDebug("[SEC] update current rotorparams %d %04x %d", m_timeoutCount, m_data[5], m_data[6]);
- ++m_sec_sequence.current();
- break;
case eSecCommand::IF_TIMEOUT_GOTO:
if (!m_timeoutCount)
{
else
++m_sec_sequence.current();
break;
- case eSecCommand::SET_POWER_LIMITING_MODE:
+ case eSecCommand::MEASURE_IDLE_INPUTPOWER:
{
- int fd = m_fe ?
- ::open("/dev/i2c/1", O_RDWR) :
- ::open("/dev/i2c/0", O_RDWR);
-
- unsigned char data[2];
- ::ioctl(fd, I2C_SLAVE_FORCE, 0x10 >> 1);
- if(::read(fd, data, 1) != 1)
- eDebug("[SEC] error read lnbp (%m)");
- if ( m_sec_sequence.current()->mode == eSecCommand::modeStatic )
+ int idx = m_sec_sequence.current()++->val;
+ if ( idx == 0 || idx == 1 )
{
- data[0] |= 0x80; // enable static current limiting
- eDebug("[SEC] set static current limiting");
+ m_idleInputpower[idx] = readInputpower();
+ eDebug("[SEC] idleInputpower[%d] is %d", idx, m_idleInputpower[idx]);
}
else
+ eDebug("[SEC] idleInputpower measure index(%d) out of bound !!!", idx);
+ break;
+ }
+ case eSecCommand::IF_MEASURE_IDLE_WAS_NOT_OK_GOTO:
+ {
+ eSecCommand::pair &compare = m_sec_sequence.current()->compare;
+ int idx = compare.voltage;
+ if ( idx == 0 || idx == 1 )
{
- data[0] &= ~0x80; // enable dynamic current limiting
- eDebug("[SEC] set dynamic current limiting");
+ int idle = readInputpower();
+ int diff = abs(idle-m_idleInputpower[idx]);
+ if ( diff > 0)
+ {
+ eDebug("measure idle(%d) was not okay.. (%d - %d = %d) retry", idx, m_idleInputpower[idx], idle, diff);
+ setSecSequencePos(compare.steps);
+ break;
+ }
}
- if(::write(fd, data, 1) != 1)
- eDebug("[SEC] error write lnbp (%m)");
- ::close(fd);
++m_sec_sequence.current();
break;
}
- case eSecCommand::IF_IDLE_INPUTPOWER_AVAIL_GOTO:
- if (m_idleInputpower[0] && m_idleInputpower[1] && setSecSequencePos(m_sec_sequence.current()->steps))
- break;
+ case eSecCommand::MEASURE_RUNNING_INPUTPOWER:
+ m_runningInputpower = readInputpower();
+ eDebug("[SEC] runningInputpower is %d", m_runningInputpower);
++m_sec_sequence.current();
break;
case eSecCommand::IF_INPUTPOWER_DELTA_GOTO:
{
eDebug("[SEC] rotor not %s... reset counter.. increase timeout", txt);
--m_timeoutCount;
+ if (!m_timeoutCount && m_retryCount > 0)
+ --m_retryCount;
cmd.okcount=0;
}
++m_sec_sequence.current();
break;
}
- case eSecCommand::IF_VOLTAGE_GOTO:
+ case eSecCommand::IF_ROTORPOS_VALID_GOTO:
+ if (m_data[5] != -1 && m_data[6] != -1)
+ setSecSequencePos(m_sec_sequence.current()->steps);
+ else
+ ++m_sec_sequence.current();
+ break;
+ case eSecCommand::INVALIDATE_CURRENT_ROTORPARMS:
+ m_data[5] = m_data[6] = -1;
+ eDebug("[SEC] invalidate current rotorparams");
+ ++m_sec_sequence.current();
+ break;
+ case eSecCommand::UPDATE_CURRENT_ROTORPARAMS:
+ m_data[5] = m_data[3];
+ m_data[6] = m_data[4];
+ eDebug("[SEC] update current rotorparams %d %04x %d", m_timeoutCount, m_data[5], m_data[6]);
+ ++m_sec_sequence.current();
+ break;
+ case eSecCommand::SET_ROTOR_DISEQC_RETRYS:
+ m_retryCount = m_sec_sequence.current()++->val;
+ eDebug("[SEC] set rotor retries %d", m_retryCount);
+ break;
+ case eSecCommand::IF_NO_MORE_ROTOR_DISEQC_RETRYS_GOTO:
+ if (!m_retryCount)
+ {
+ eDebug("[SEC] no more rotor retrys");
+ setSecSequencePos(m_sec_sequence.current()->steps);
+ }
+ else
+ ++m_sec_sequence.current();
+ break;
+ case eSecCommand::SET_POWER_LIMITING_MODE:
{
- eSecCommand::pair &compare = m_sec_sequence.current()->compare;
- if ( compare.voltage == m_curVoltage && setSecSequencePos(compare.steps) )
- break;
+ int fd = m_fe ?
+ ::open("/dev/i2c/1", O_RDWR) :
+ ::open("/dev/i2c/0", O_RDWR);
+
+ unsigned char data[2];
+ ::ioctl(fd, I2C_SLAVE_FORCE, 0x10 >> 1);
+ if(::read(fd, data, 1) != 1)
+ eDebug("[SEC] error read lnbp (%m)");
+ if ( m_sec_sequence.current()->mode == eSecCommand::modeStatic )
+ {
+ data[0] |= 0x80; // enable static current limiting
+ eDebug("[SEC] set static current limiting");
+ }
+ else
+ {
+ data[0] &= ~0x80; // enable dynamic current limiting
+ eDebug("[SEC] set dynamic current limiting");
+ }
+ if(::write(fd, data, 1) != 1)
+ eDebug("[SEC] error write lnbp (%m)");
+ ::close(fd);
++m_sec_sequence.current();
break;
}
perror("FE_SET_FRONTEND failed");
return;
}
-
- if (m_state != stateTuning)
- {
- m_tuning = 1;
- m_state = stateTuning;
- m_stateChanged(this);
- }
m_timeout->start(5000, 1); // 5 sec timeout. TODO: symbolrate dependent
}
m_sec_sequence.push_back( eSecCommand(eSecCommand::SET_FRONTEND) );
m_tuneTimer->start(0,true);
+ m_timeout->stop();
m_sec_sequence.current() = m_sec_sequence.begin();
+ if (m_state != stateTuning)
+ {
+ m_tuning = 1;
+ m_state = stateTuning;
+ m_stateChanged(this);
+ }
+
return 0;
}