{
if (m_sec_sequence.current() != m_sec_sequence.begin() && m_sec_sequence.current() != m_sec_sequence.end())
--m_sec_sequence.current();
- --steps;
+ ++steps;
}
return true;
}
{
case eSecCommand::SLEEP:
delay = m_sec_sequence.current()++->msec;
- eDebug("sleep %dms\n", delay);
+ eDebug("sleep %dms", delay);
break;
case eSecCommand::GOTO:
if ( !setSecSequencePos(m_sec_sequence.current()->steps) )
++m_sec_sequence.current();
break;
case eSecCommand::SET_VOLTAGE:
- setVoltage(m_sec_sequence.current()++->voltage);
eDebug("setVoltage %d", m_sec_sequence.current()->voltage);
+ setVoltage(m_sec_sequence.current()++->voltage);
break;
case eSecCommand::SET_TONE:
- setTone(m_sec_sequence.current()++->tone);
eDebug("setTone %d", m_sec_sequence.current()->tone);
+ setTone(m_sec_sequence.current()++->tone);
break;
case eSecCommand::SEND_DISEQC:
sendDiseqc(m_sec_sequence.current()->diseqc);
++m_sec_sequence.current();
break;
case eSecCommand::SEND_TONEBURST:
- sendToneburst(m_sec_sequence.current()++->toneburst);
eDebug("sendToneburst: %d", m_sec_sequence.current()->toneburst);
+ sendToneburst(m_sec_sequence.current()++->toneburst);
break;
case eSecCommand::SET_FRONTEND:
eDebug("setFrontend");
case eSecCommand::UPDATE_CURRENT_ROTORPARAMS:
m_data[5] = m_data[3];
m_data[6] = m_data[4];
- eDebug("update current rotorparams %d", m_timeoutCount);
+ eDebug("update current rotorparams %d %04x %d", m_timeoutCount, m_data[5], m_data[6]);
++m_sec_sequence.current();
break;
case eSecCommand::IF_TIMEOUT_GOTO:
else
++m_sec_sequence.current();
break;
- case eSecCommand::IF_RUNNING_GOTO:
- case eSecCommand::IF_STOPPED_GOTO:
+ case eSecCommand::IF_INPUTPOWER_DELTA_GOTO:
+ {
+ eSecCommand::rotor &cmd = m_sec_sequence.current()->measure;
+ const char *txt = cmd.direction ? "running" : "stopped";
+ eDebug("waiting for rotor %s", txt);
+ eDebug("%s %d, idle %d, delta %d",
+ txt,
+ m_runningInputpower,
+ m_idleInputpower,
+ cmd.deltaA);
+ if ( (cmd.direction && abs(m_runningInputpower - m_idleInputpower) >= cmd.deltaA)
+ || (!cmd.direction && abs(m_runningInputpower - m_idleInputpower) <= cmd.deltaA) )
+ {
+ ++cmd.okcount;
+ eDebug("rotor %s step %d ok", txt, cmd.okcount);
+ if ( cmd.okcount > 1 )
+ {
+ eDebug("rotor is %s", txt);
+ if (setSecSequencePos(cmd.steps))
+ break;
+ }
+ }
+ else
+ {
+ eDebug("rotor not %s... reset counter.. increase timeout", txt);
+ --m_timeoutCount;
+ cmd.okcount=0;
+ }
+ ++m_sec_sequence.current();
+ break;
+ }
default:
++m_sec_sequence.current();
eDebug("unhandled sec command");
RESULT eDVBFrontend::getData(int num, int &data)
{
- if ( num < 5 )
+ if ( num < 7 )
{
data = m_data[num];
return 0;
RESULT eDVBFrontend::setData(int num, int val)
{
- if ( num < 5 )
+ if ( num < 7 )
{
m_data[num] = val;
return 0;
sec_sequence.push_back( eSecCommand(eSecCommand::SET_TIMEOUT, 8) ); // 2 seconds rotor start timout
sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, 250) );
sec_sequence.push_back( eSecCommand(eSecCommand::MEASURE_RUNNING_INPUTPOWER) );
- sec_sequence.push_back( eSecCommand(eSecCommand::IF_RUNNING_GOTO, +3 ) );
+ eSecCommand::rotor cmd;
+ cmd.direction=1; // check for running rotor
+ cmd.deltaA=rotor_param.m_inputpower_parameters.m_threshold;
+ cmd.steps=+3;
+ cmd.okcount=0;
+ sec_sequence.push_back( eSecCommand(eSecCommand::IF_INPUTPOWER_DELTA_GOTO, cmd ) );
sec_sequence.push_back( eSecCommand(eSecCommand::IF_TIMEOUT_GOTO, +8 ) );
sec_sequence.push_back( eSecCommand(eSecCommand::GOTO, -4) );
sec_sequence.push_back( eSecCommand(eSecCommand::SET_TIMEOUT, 240) ); // 1 minute running timeout
sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, 250) );
sec_sequence.push_back( eSecCommand(eSecCommand::MEASURE_RUNNING_INPUTPOWER) );
- sec_sequence.push_back( eSecCommand(eSecCommand::IF_STOPPED_GOTO, +3 ) );
+ cmd.direction=0; // check for stopped rotor
+ sec_sequence.push_back( eSecCommand(eSecCommand::IF_INPUTPOWER_DELTA_GOTO, cmd ) );
sec_sequence.push_back( eSecCommand(eSecCommand::IF_TIMEOUT_GOTO, +2 ) );
sec_sequence.push_back( eSecCommand(eSecCommand::GOTO, -4) );
sec_sequence.push_back( eSecCommand(eSecCommand::UPDATE_CURRENT_ROTORPARAMS) );
enum {
NONE, SLEEP, SET_VOLTAGE, SET_TONE, GOTO,
SEND_DISEQC, SEND_TONEBURST, SET_FRONTEND,
- MEASURE_IDLE_INPUTPOWER, MEASURE_RUNNING_INPUTPOWER,
- IF_TIMEOUT_GOTO, IF_RUNNING_GOTO, IF_STOPPED_GOTO,
- UPDATE_CURRENT_ROTORPARAMS, SET_TIMEOUT,
+ MEASURE_IDLE_INPUTPOWER, MEASURE_RUNNING_INPUTPOWER,
+ IF_TIMEOUT_GOTO, IF_INPUTPOWER_DELTA_GOTO,
+ UPDATE_CURRENT_ROTORPARAMS, SET_TIMEOUT
};
int cmd;
+ struct rotor
+ {
+ int deltaA; // difference in mA between running and stopped rotor
+ int okcount; // counter
+ int steps; // goto steps
+ int direction;
+ };
union
{
int val;
int tone;
int toneburst;
int msec;
+ rotor measure;
eDVBDiseqcCommand diseqc;
};
eSecCommand( int cmd )
eSecCommand( int cmd, eDVBDiseqcCommand diseqc )
:cmd(cmd), diseqc(diseqc)
{}
+ eSecCommand( int cmd, rotor measure )
+ :cmd(cmd), measure(measure)
+ {}
eSecCommand()
:cmd(NONE)
{}
std::map< int, int, Orbital_Position_Compare > m_rotor_position_table;
/* mapping orbitalposition <-> number stored in rotor */
- void setDefaultOptions(); // set default rotor options
+ void setDefaultOptions() // set default rotor options
+ {
+ m_inputpower_parameters.m_use = true;
+ m_inputpower_parameters.m_threshold = 60;
+ m_gotoxx_parameters.m_can_use = true;
+ m_gotoxx_parameters.m_lo_direction = EAST;
+ m_gotoxx_parameters.m_la_direction = NORTH;
+ m_gotoxx_parameters.m_longitude = 0.0;
+ m_gotoxx_parameters.m_latitude = 0.0;
+ }
};
class eDVBSatelliteParameters