#include <config.h>
#include <lib/dvb/sec.h>
+#include <lib/dvb/rotor_calc.h>
+
#if HAVE_DVB_API_VERSION < 3
#define INVERSION Inversion
#define FREQUENCY Frequency
eDVBSatelliteDiseqcParameters &diseqc_ref = astra1.m_diseqc_parameters;
eDVBSatelliteSwitchParameters &switch_ref = astra1.m_switch_parameters;
- lnb_ref.m_lof_hi = 10607000;
+ lnb_ref.m_lof_hi = 10600000;
lnb_ref.m_lof_lo = 9750000;
lnb_ref.m_lof_threshold = 11700000;
diseqc_ref.m_diseqc_mode = eDVBSatelliteDiseqcParameters::V1_0;
- diseqc_ref.m_committed_cmd = eDVBSatelliteDiseqcParameters::BB;
+ diseqc_ref.m_committed_cmd = eDVBSatelliteDiseqcParameters::AA;
diseqc_ref.m_repeats = 0;
diseqc_ref.m_seq_repeat = false;
diseqc_ref.m_swap_cmds = false;
{
eDVBSatelliteDiseqcParameters &di_param = sit->second.m_diseqc_parameters;
eDVBSatelliteSwitchParameters &sw_param = sit->second.m_switch_parameters;
+ eDVBSatelliteRotorParameters &rotor_param = sit->second.m_rotor_parameters;
int hi=0,
voltage = iDVBFrontend::voltageOff,
tone = iDVBFrontend::toneOff,
lastcsw = -1,
lastucsw = -1,
lastToneburst = -1,
+ lastRotorCmd = -1,
curRotorPos = -1;
frontend.getData(0, lastcsw);
frontend.getData(1, lastucsw);
frontend.getData(2, lastToneburst);
- frontend.getData(3, curRotorPos);
+ frontend.getData(5, lastRotorCmd);
+ frontend.getData(6, curRotorPos);
if ( sat.frequency > lnb_param.m_lof_threshold )
hi = 1;
tone = iDVBFrontend::toneOff;
eSecCommandList sec_sequence;
+ bool setVoltage=true;
if (di_param.m_diseqc_mode >= eDVBSatelliteDiseqcParameters::V1_0)
{
sec_sequence.push_back( eSecCommand(eSecCommand::SET_TONE, iDVBFrontend::toneOff) );
sec_sequence.push_back( eSecCommand(eSecCommand::SET_VOLTAGE, voltage) );
sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, 30) ); // standard says 15 msek here
+ setVoltage=false;
}
if ( send_diseqc )
}
else
sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, 30) );
+
+ frontend.setData(0, csw);
+ frontend.setData(1, ucsw);
}
}
- if ( di_param.m_diseqc_mode == eDVBSatelliteDiseqcParameters::V1_2 && curRotorPos != sat.orbital_position )
- {
- }
if ( (changed_burst || send_diseqc) && di_param.m_toneburst_param != eDVBSatelliteDiseqcParameters::NO )
{
sec_sequence.push_back( eSecCommand(eSecCommand::SEND_TONEBURST, di_param.m_toneburst_param) );
sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, 30) );
+ frontend.setData(2, di_param.m_toneburst_param);
+ }
+ if ( di_param.m_diseqc_mode == eDVBSatelliteDiseqcParameters::V1_2 )
+ {
+ int RotorCmd=0;
+ bool useGotoXX = false;
+
+ std::map<int,int,eDVBSatelliteRotorParameters::Orbital_Position_Compare>::iterator it =
+ rotor_param.m_rotor_position_table.find( sat.orbital_position );
+
+ if (it != rotor_param.m_rotor_position_table.end()) // position for selected sat found ?
+ RotorCmd=it->second;
+ else // entry not in table found
+ {
+ eDebug("Entry for %d,%d° not in Rotor Table found... i try gotoXX°", sat.orbital_position / 10, sat.orbital_position % 10 );
+ useGotoXX = true;
+
+ int satDir = sat.orbital_position < 0 ?
+ eDVBSatelliteRotorParameters::WEST :
+ eDVBSatelliteRotorParameters::EAST;
+
+ double SatLon = abs(sat.orbital_position)/10.00,
+ SiteLat = rotor_param.m_gotoxx_parameters.m_latitude,
+ SiteLon = rotor_param.m_gotoxx_parameters.m_longitude;
+
+ if ( rotor_param.m_gotoxx_parameters.m_la_direction == eDVBSatelliteRotorParameters::SOUTH )
+ SiteLat = -SiteLat;
+
+ if ( rotor_param.m_gotoxx_parameters.m_lo_direction == eDVBSatelliteRotorParameters::WEST )
+ SiteLon = 360 - SiteLon;
+
+ if (satDir == eDVBSatelliteRotorParameters::WEST )
+ SatLon = 360 - SatLon;
+
+ eDebug("siteLatitude = %lf, siteLongitude = %lf, %lf degrees", SiteLat, SiteLon, SatLon );
+ double satHourAngle =
+ calcSatHourangle( SatLon, SiteLat, SiteLon );
+ eDebug("PolarmountHourAngle=%lf", satHourAngle );
+
+ static int gotoXTable[10] =
+ { 0x00, 0x02, 0x03, 0x05, 0x06, 0x08, 0x0A, 0x0B, 0x0D, 0x0E };
+
+ if (SiteLat >= 0) // Northern Hemisphere
+ {
+ int tmp=(int)round( fabs( 180 - satHourAngle ) * 10.0 );
+ RotorCmd = (tmp/10)*0x10 + gotoXTable[ tmp % 10 ];
+
+ if (satHourAngle < 180) // the east
+ RotorCmd |= 0xE000;
+ else // west
+ RotorCmd |= 0xD000;
+ }
+ else // Southern Hemisphere
+ {
+ if (satHourAngle < 180) // the east
+ {
+ int tmp=(int)round( fabs( satHourAngle ) * 10.0 );
+ RotorCmd = (tmp/10)*0x10 + gotoXTable[ tmp % 10 ];
+ RotorCmd |= 0xD000;
+ }
+ else // west
+ {
+ int tmp=(int)round( fabs( 360 - satHourAngle ) * 10.0 );
+ RotorCmd = (tmp/10)*0x10 + gotoXTable[ tmp % 10 ];
+ RotorCmd |= 0xE000;
+ }
+ }
+ eDebug("RotorCmd = %04x", RotorCmd);
+ }
+ if ( RotorCmd != lastRotorCmd )
+ {
+ eDVBDiseqcCommand diseqc;
+ diseqc.data[0] = 0xE0;
+ diseqc.data[1] = 0x31; // positioner
+ if ( useGotoXX )
+ {
+ diseqc.len = 5;
+ diseqc.data[2] = 0x6E; // drive to angular position
+ diseqc.data[3] = ((RotorCmd & 0xFF00) / 0x100);
+ diseqc.data[4] = RotorCmd & 0xFF;
+ }
+ else
+ {
+ diseqc.len = 4;
+ diseqc.data[2] = 0x6B; // goto stored sat position
+ diseqc.data[3] = RotorCmd;
+ }
+ if ( rotor_param.m_inputpower_parameters.m_use )
+ { // use measure rotor input power to detect rotor state
+ sec_sequence.push_back( eSecCommand(eSecCommand::SET_VOLTAGE, iDVBFrontend::voltage18) ); // always turn with high voltage
+ sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, 50) ); // wait 50sec after voltage change
+ sec_sequence.push_back( eSecCommand(eSecCommand::MEASURE_IDLE_INPUTPOWER) );
+ sec_sequence.push_back( eSecCommand(eSecCommand::SEND_DISEQC, diseqc) );
+ 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) );
+ 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) );
+ 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) );
+ frontend.setData(3, RotorCmd);
+ frontend.setData(4, sat.orbital_position);
+ }
+ else
+ eFatal("rotor turning without inputpowermeasure not implemented yet");
+ }
}
}
- else
+
+ if ( setVoltage )
{
sec_sequence.push_back( eSecCommand(eSecCommand::SET_VOLTAGE, voltage) );
sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, 10) );