fix compiler error due to invalid conversion (g++ 4.4.1)
[enigma2.git] / lib / dvb / frontend.cpp
index 79c9ad0bccbc9556b3c4ab0ad53aca06292a4979..abbb8d294ab6f2e89d25fda3e8f8e796120a206b 100644 (file)
@@ -1,4 +1,5 @@
 #include <lib/dvb/dvb.h>
+#include <lib/dvb/frontendparms.h>
 #include <lib/base/eerror.h>
 #include <lib/base/nconfig.h> // access to python config
 #include <errno.h>
@@ -48,9 +49,7 @@
 #define parm_u_ofdm_transmission_mode parm.u.ofdm.transmission_mode
 #define parm_u_ofdm_guard_interval parm.u.ofdm.guard_interval
 #define parm_u_ofdm_hierarchy_information parm.u.ofdm.hierarchy_information
-#ifdef FEC_9_10
-       #warning "FEC_9_10 already exist in dvb api ... it seems it is now ready for DVB-S2"
-#else
+#if HAVE_DVB_API_VERSION < 5
        #define FEC_S2_QPSK_1_2 (fe_code_rate_t)(FEC_AUTO+1)
        #define FEC_S2_QPSK_2_3 (fe_code_rate_t)(FEC_S2_QPSK_1_2+1)
        #define FEC_S2_QPSK_3_4 (fe_code_rate_t)(FEC_S2_QPSK_2_3+1)
        #define FEC_S2_8PSK_3_5 (fe_code_rate_t)(FEC_S2_8PSK_8_9+1)
        #define FEC_S2_8PSK_4_5 (fe_code_rate_t)(FEC_S2_8PSK_3_5+1)
        #define FEC_S2_8PSK_9_10 (fe_code_rate_t)(FEC_S2_8PSK_4_5+1)
+#else
+       #define FEC_S2_QPSK_1_2 (fe_code_rate_t)(FEC_1_2)
+       #define FEC_S2_QPSK_2_3 (fe_code_rate_t)(FEC_2_3)
+       #define FEC_S2_QPSK_3_4 (fe_code_rate_t)(FEC_3_4)
+       #define FEC_S2_QPSK_5_6 (fe_code_rate_t)(FEC_5_6)
+       #define FEC_S2_QPSK_7_8 (fe_code_rate_t)(FEC_7_8)
+       #define FEC_S2_QPSK_8_9 (fe_code_rate_t)(FEC_8_9)
+       #define FEC_S2_QPSK_3_5 (fe_code_rate_t)(FEC_3_5)
+       #define FEC_S2_QPSK_4_5 (fe_code_rate_t)(FEC_4_5)
+       #define FEC_S2_QPSK_9_10 (fe_code_rate_t)(FEC_9_10)
 #endif
 #endif
 
 #include <dvbsi++/cable_delivery_system_descriptor.h>
 #include <dvbsi++/terrestrial_delivery_system_descriptor.h>
 
+#define eDebugNoSimulate(x...) \
+       do { \
+               if (!m_simulate) \
+                       eDebug(x); \
+       } while(0)
+#if 0
+               else \
+               { \
+                       eDebugNoNewLine("SIMULATE:"); \
+                       eDebug(x); \
+               }
+#endif
+
+#define eDebugNoSimulateNoNewLine(x...) \
+       do { \
+               if (!m_simulate) \
+                       eDebugNoNewLine(x); \
+       } while(0)
+#if 0
+               else \
+               { \
+                       eDebugNoNewLine("SIMULATE:"); \
+                       eDebugNoNewLine(x); \
+               }
+#endif
+
 void eDVBDiseqcCommand::setCommandString(const char *str)
 {
        if (!str)
@@ -122,10 +157,10 @@ void eDVBFrontendParametersSatellite::set(const SatelliteDeliverySystemDescripto
        symbol_rate  = descriptor.getSymbolRate() * 100;
        polarisation = descriptor.getPolarization();
        fec = descriptor.getFecInner();
-       if ( fec != FEC::fNone && fec > FEC::f9_10 )
-               fec = FEC::fAuto;
-       inversion = Inversion::Unknown;
-       pilot = Pilot::Unknown;
+       if ( fec != eDVBFrontendParametersSatellite::FEC_None && fec > eDVBFrontendParametersSatellite::FEC_9_10 )
+               fec = eDVBFrontendParametersSatellite::FEC_Auto;
+       inversion = eDVBFrontendParametersSatellite::Inversion_Unknown;
+       pilot = eDVBFrontendParametersSatellite::Pilot_Unknown;
        orbital_position  = ((descriptor.getOrbitalPosition() >> 12) & 0xF) * 1000;
        orbital_position += ((descriptor.getOrbitalPosition() >> 8) & 0xF) * 100;
        orbital_position += ((descriptor.getOrbitalPosition() >> 4) & 0xF) * 10;
@@ -134,13 +169,13 @@ void eDVBFrontendParametersSatellite::set(const SatelliteDeliverySystemDescripto
                orbital_position = 3600 - orbital_position;
        system = descriptor.getModulationSystem();
        modulation = descriptor.getModulation();
-       if (system == System::DVB_S && modulation == Modulation::M8PSK)
+       if (system == eDVBFrontendParametersSatellite::System_DVB_S && modulation == eDVBFrontendParametersSatellite::Modulation_8PSK)
        {
                eDebug("satellite_delivery_descriptor non valid modulation type.. force QPSK");
-               modulation=QPSK;
+               modulation=eDVBFrontendParametersSatellite::Modulation_QPSK;
        }
        rolloff = descriptor.getRollOff();
-       if (system == System::DVB_S2)
+       if (system == eDVBFrontendParametersSatellite::System_DVB_S2)
        {
                eDebug("SAT DVB-S2 freq %d, %s, pos %d, sr %d, fec %d, modulation %d, rolloff %d",
                        frequency,
@@ -165,12 +200,12 @@ void eDVBFrontendParametersCable::set(const CableDeliverySystemDescriptor &descr
        frequency = descriptor.getFrequency() / 10;
        symbol_rate = descriptor.getSymbolRate() * 100;
        fec_inner = descriptor.getFecInner();
-       if ( fec_inner == 0xF )
-               fec_inner = FEC::fNone;
+       if ( fec_inner != eDVBFrontendParametersCable::FEC_None && fec_inner > eDVBFrontendParametersCable::FEC_8_9 )
+               fec_inner = eDVBFrontendParametersCable::FEC_Auto;
        modulation = descriptor.getModulation();
        if ( modulation > 0x5 )
-               modulation = Modulation::Auto;
-       inversion = Inversion::Unknown;
+               modulation = eDVBFrontendParametersCable::Modulation_Auto;
+       inversion = eDVBFrontendParametersCable::Inversion_Unknown;
        eDebug("Cable freq %d, mod %d, sr %d, fec %d",
                frequency,
                modulation, symbol_rate, fec_inner);
@@ -181,30 +216,31 @@ void eDVBFrontendParametersTerrestrial::set(const TerrestrialDeliverySystemDescr
        frequency = descriptor.getCentreFrequency() * 10;
        bandwidth = descriptor.getBandwidth();
        if ( bandwidth > 2 ) // 5Mhz forced to auto
-               bandwidth = Bandwidth::BwAuto;
+               bandwidth = eDVBFrontendParametersTerrestrial::Bandwidth_Auto;
        code_rate_HP = descriptor.getCodeRateHpStream();
        if (code_rate_HP > 4)
-               code_rate_HP = FEC::fAuto;
+               code_rate_HP = eDVBFrontendParametersTerrestrial::FEC_Auto;
        code_rate_LP = descriptor.getCodeRateLpStream();
        if (code_rate_LP > 4)
-               code_rate_LP = FEC::fAuto;
+               code_rate_LP = eDVBFrontendParametersTerrestrial::FEC_Auto;
        transmission_mode = descriptor.getTransmissionMode();
        if (transmission_mode > 1) // TM4k forced to auto
-               transmission_mode = TransmissionMode::TMAuto;
+               transmission_mode = eDVBFrontendParametersTerrestrial::TransmissionMode_Auto;
        guard_interval = descriptor.getGuardInterval();
        if (guard_interval > 3)
-               guard_interval = GuardInterval::GI_Auto;
+               guard_interval = eDVBFrontendParametersTerrestrial::GuardInterval_Auto;
        hierarchy = descriptor.getHierarchyInformation()&3;
        modulation = descriptor.getConstellation();
        if (modulation > 2)
-               modulation = Modulation::Auto;
-       inversion = Inversion::Unknown;
+               modulation = eDVBFrontendParametersTerrestrial::Modulation_Auto;
+       inversion = eDVBFrontendParametersTerrestrial::Inversion_Unknown;
        eDebug("Terr freq %d, bw %d, cr_hp %d, cr_lp %d, tm_mode %d, guard %d, hierarchy %d, const %d",
                frequency, bandwidth, code_rate_HP, code_rate_LP, transmission_mode,
                guard_interval, hierarchy, modulation);
 }
 
-eDVBFrontendParameters::eDVBFrontendParameters(): m_type(-1)
+eDVBFrontendParameters::eDVBFrontendParameters()
+       :m_type(-1), m_flags(0)
 {
 }
 
@@ -289,9 +325,9 @@ RESULT eDVBFrontendParameters::calculateDifference(const iDVBFrontendParameters
                        diff = 1<<29;
                else if (sat.polarisation != osat.polarisation)
                        diff = 1<<28;
-               else if (exact && sat.fec != osat.fec && sat.fec != eDVBFrontendParametersSatellite::FEC::fAuto && osat.fec != eDVBFrontendParametersSatellite::FEC::fAuto)
+               else if (exact && sat.fec != osat.fec && sat.fec != eDVBFrontendParametersSatellite::FEC_Auto && osat.fec != eDVBFrontendParametersSatellite::FEC_Auto)
                        diff = 1<<27;
-               else if (exact && sat.modulation != osat.modulation && sat.modulation != eDVBFrontendParametersSatellite::Modulation::Auto && osat.modulation != eDVBFrontendParametersSatellite::Modulation::Auto)
+               else if (exact && sat.modulation != osat.modulation && sat.modulation != eDVBFrontendParametersSatellite::Modulation_Auto && osat.modulation != eDVBFrontendParametersSatellite::Modulation_Auto)
                        diff = 1<<27;
                else
                {
@@ -306,10 +342,10 @@ RESULT eDVBFrontendParameters::calculateDifference(const iDVBFrontendParameters
                        return -2;
 
                if (exact && cable.modulation != ocable.modulation
-                       && cable.modulation != eDVBFrontendParametersCable::Modulation::Auto
-                       && ocable.modulation != eDVBFrontendParametersCable::Modulation::Auto)
+                       && cable.modulation != eDVBFrontendParametersCable::Modulation_Auto
+                       && ocable.modulation != eDVBFrontendParametersCable::Modulation_Auto)
                        diff = 1 << 29;
-               else if (exact && cable.fec_inner != ocable.fec_inner && cable.fec_inner != eDVBFrontendParametersCable::FEC::fAuto && ocable.fec_inner != eDVBFrontendParametersCable::FEC::fAuto)
+               else if (exact && cable.fec_inner != ocable.fec_inner && cable.fec_inner != eDVBFrontendParametersCable::FEC_Auto && ocable.fec_inner != eDVBFrontendParametersCable::FEC_Auto)
                        diff = 1 << 27;
                else
                {
@@ -322,37 +358,36 @@ RESULT eDVBFrontendParameters::calculateDifference(const iDVBFrontendParameters
                if (parm->getDVBT(oterrestrial))
                        return -2;
 
-
                if (exact && oterrestrial.bandwidth != terrestrial.bandwidth &&
-                       oterrestrial.bandwidth != eDVBFrontendParametersTerrestrial::Bandwidth::BwAuto &&
-                       terrestrial.bandwidth != eDVBFrontendParametersTerrestrial::Bandwidth::BwAuto)
+                       oterrestrial.bandwidth != eDVBFrontendParametersTerrestrial::Bandwidth_Auto &&
+                       terrestrial.bandwidth != eDVBFrontendParametersTerrestrial::Bandwidth_Auto)
                        diff = 1 << 30;
                else if (exact && oterrestrial.modulation != terrestrial.modulation &&
-                       oterrestrial.modulation != eDVBFrontendParametersTerrestrial::Modulation::Auto &&
-                       terrestrial.modulation != eDVBFrontendParametersTerrestrial::Modulation::Auto)
+                       oterrestrial.modulation != eDVBFrontendParametersTerrestrial::Modulation_Auto &&
+                       terrestrial.modulation != eDVBFrontendParametersTerrestrial::Modulation_Auto)
                        diff = 1 << 30;
                else if (exact && oterrestrial.transmission_mode != terrestrial.transmission_mode &&
-                       oterrestrial.transmission_mode != eDVBFrontendParametersTerrestrial::TransmissionMode::TMAuto &&
-                       terrestrial.transmission_mode != eDVBFrontendParametersTerrestrial::TransmissionMode::TMAuto)
+                       oterrestrial.transmission_mode != eDVBFrontendParametersTerrestrial::TransmissionMode_Auto &&
+                       terrestrial.transmission_mode != eDVBFrontendParametersTerrestrial::TransmissionMode_Auto)
                        diff = 1 << 30;
                else if (exact && oterrestrial.guard_interval != terrestrial.guard_interval &&
-                       oterrestrial.guard_interval != eDVBFrontendParametersTerrestrial::GuardInterval::GI_Auto &&
-                       terrestrial.guard_interval != eDVBFrontendParametersTerrestrial::GuardInterval::GI_Auto)
+                       oterrestrial.guard_interval != eDVBFrontendParametersTerrestrial::GuardInterval_Auto &&
+                       terrestrial.guard_interval != eDVBFrontendParametersTerrestrial::GuardInterval_Auto)
                        diff = 1 << 30;
                else if (exact && oterrestrial.hierarchy != terrestrial.hierarchy &&
-                       oterrestrial.hierarchy != eDVBFrontendParametersTerrestrial::Hierarchy::HAuto &&
-                       terrestrial.hierarchy != eDVBFrontendParametersTerrestrial::Hierarchy::HAuto)
+                       oterrestrial.hierarchy != eDVBFrontendParametersTerrestrial::Hierarchy_Auto &&
+                       terrestrial.hierarchy != eDVBFrontendParametersTerrestrial::Hierarchy_Auto)
                        diff = 1 << 30;
                else if (exact && oterrestrial.code_rate_LP != terrestrial.code_rate_LP &&
-                       oterrestrial.code_rate_LP != eDVBFrontendParametersTerrestrial::FEC::fAuto &&
-                       terrestrial.code_rate_LP != eDVBFrontendParametersTerrestrial::FEC::fAuto)
+                       oterrestrial.code_rate_LP != eDVBFrontendParametersTerrestrial::FEC_Auto &&
+                       terrestrial.code_rate_LP != eDVBFrontendParametersTerrestrial::FEC_Auto)
                        diff = 1 << 30;
                else if (exact && oterrestrial.code_rate_HP != terrestrial.code_rate_HP &&
-                       oterrestrial.code_rate_HP != eDVBFrontendParametersTerrestrial::FEC::fAuto &&
-                       terrestrial.code_rate_HP != eDVBFrontendParametersTerrestrial::FEC::fAuto)
+                       oterrestrial.code_rate_HP != eDVBFrontendParametersTerrestrial::FEC_Auto &&
+                       terrestrial.code_rate_HP != eDVBFrontendParametersTerrestrial::FEC_Auto)
                        diff = 1 << 30;
                else
-                       diff = abs(terrestrial.frequency - oterrestrial.frequency);
+                       diff = abs(terrestrial.frequency - oterrestrial.frequency) / 1000;
                return 0;
        default:
                return -1;
@@ -376,7 +411,7 @@ RESULT eDVBFrontendParameters::getHash(unsigned long &hash) const
                return 0;
        case iDVBFrontend::feTerrestrial:
                hash = 0xEEEE0000;
-               hash |= (terrestrial.frequency/1000)&0xFFFF;
+               hash |= (terrestrial.frequency/1000000)&0xFFFF;
                return 0;
        default:
                return -1;
@@ -418,10 +453,10 @@ DEFINE_REF(eDVBFrontend);
 
 int eDVBFrontend::PriorityOrder=0;
 
-eDVBFrontend::eDVBFrontend(int adap, int fe, int &ok)
-       :m_enabled(false), m_type(-1), m_dvbid(fe), m_slotid(fe)
-       ,m_fd(-1), m_need_rotor_workaround(false), m_can_handle_dvbs2(false)
-       ,m_sn(0), m_timeout(0), m_tuneTimer(0)
+eDVBFrontend::eDVBFrontend(int adap, int fe, int &ok, bool simulate)
+       :m_simulate(simulate), m_enabled(false), m_type(-1), m_dvbid(fe), m_slotid(fe)
+       ,m_fd(-1), m_rotor_mode(false), m_need_rotor_workaround(false), m_can_handle_dvbs2(false)
+       ,m_state(stateClosed), m_timeout(0), m_tuneTimer(0)
 #if HAVE_DVB_API_VERSION < 3
        ,m_secfd(-1)
 #endif
@@ -432,10 +467,11 @@ eDVBFrontend::eDVBFrontend(int adap, int fe, int &ok)
 #else
        sprintf(m_filename, "/dev/dvb/adapter%d/frontend%d", adap, fe);
 #endif
-       m_timeout = new eTimer(eApp);
+
+       m_timeout = eTimer::create(eApp);
        CONNECT(m_timeout->timeout, eDVBFrontend::timeout);
 
-       m_tuneTimer = new eTimer(eApp);
+       m_tuneTimer = eTimer::create(eApp);
        CONNECT(m_tuneTimer->timeout, eDVBFrontend::tuneLoop);
 
        for (int i=0; i<eDVBFrontend::NUM_DATA_ENTRIES; ++i)
@@ -447,9 +483,16 @@ eDVBFrontend::eDVBFrontend(int adap, int fe, int &ok)
        closeFrontend();
 }
 
+void eDVBFrontend::reopenFrontend()
+{
+       sleep(1);
+       m_type = -1;
+       openFrontend();
+}
+
 int eDVBFrontend::openFrontend()
 {
-       if (m_sn)
+       if (m_state != stateClosed)
                return -1;  // already opened
 
        m_state=stateIdle;
@@ -460,14 +503,17 @@ int eDVBFrontend::openFrontend()
 #else
        dvb_frontend_info fe_info;
 #endif
-       eDebug("opening frontend %d", m_dvbid);
+       eDebugNoSimulate("opening frontend %d", m_dvbid);
        if (m_fd < 0)
        {
-               m_fd = ::open(m_filename, O_RDWR|O_NONBLOCK);
-               if (m_fd < 0)
+               if (!m_simulate || m_type == -1)
                {
-                       eWarning("failed! (%s) %m", m_filename);
-                       return -1;
+                       m_fd = ::open(m_filename, O_RDWR|O_NONBLOCK);
+                       if (m_fd < 0)
+                       {
+                               eWarning("failed! (%s) %m", m_filename);
+                               return -1;
+                       }
                }
        }
        else
@@ -499,7 +545,7 @@ int eDVBFrontend::openFrontend()
                        m_fd = -1;
                        return -1;
                }
-               eDebug("detected %s frontend", "satellite\0cable\0    terrestrial"+fe_info.type*10);
+               eDebugNoSimulate("detected %s frontend", "satellite\0cable\0    terrestrial"+fe_info.type*10);
        }
 
 #if HAVE_DVB_API_VERSION < 3
@@ -507,13 +553,16 @@ int eDVBFrontend::openFrontend()
        {
                        if (m_secfd < 0)
                        {
-                               m_secfd = ::open(m_sec_filename, O_RDWR);
-                               if (m_secfd < 0)
+                               if (!m_simulate)
                                {
-                                       eWarning("failed! (%s) %m", m_sec_filename);
-                                       ::close(m_fd);
-                                       m_fd=-1;
-                                       return -1;
+                                       m_secfd = ::open(m_sec_filename, O_RDWR);
+                                       if (m_secfd < 0)
+                                       {
+                                               eWarning("failed! (%s) %m", m_sec_filename);
+                                               ::close(m_fd);
+                                               m_fd=-1;
+                                               return -1;
+                                       }
                                }
                        }
                        else
@@ -524,13 +573,16 @@ int eDVBFrontend::openFrontend()
        setTone(iDVBFrontend::toneOff);
        setVoltage(iDVBFrontend::voltageOff);
 
-       m_sn = new eSocketNotifier(eApp, m_fd, eSocketNotifier::Read, false);
-       CONNECT(m_sn->activated, eDVBFrontend::feEvent);
+       if (!m_simulate)
+       {
+               m_sn = eSocketNotifier::create(eApp, m_fd, eSocketNotifier::Read, false);
+               CONNECT(m_sn->activated, eDVBFrontend::feEvent);
+       }
 
        return 0;
 }
 
-int eDVBFrontend::closeFrontend(bool force)
+int eDVBFrontend::closeFrontend(bool force, bool no_delayed)
 {
        if (!force && m_data[CUR_VOLTAGE] != -1 && m_data[CUR_VOLTAGE] != iDVBFrontend::voltageOff)
        {
@@ -540,26 +592,59 @@ int eDVBFrontend::closeFrontend(bool force)
                        eDVBRegisteredFrontend *linked_fe = (eDVBRegisteredFrontend*)tmp;
                        if (linked_fe->m_inuse)
                        {
-                               eDebug("dont close frontend %d until the linked frontend %d in slot %d is still in use",
+                               eDebugNoSimulate("dont close frontend %d until the linked frontend %d in slot %d is still in use",
                                        m_dvbid, linked_fe->m_frontend->getDVBID(), linked_fe->m_frontend->getSlotID());
                                return -1;
                        }
                        linked_fe->m_frontend->getData(LINKED_NEXT_PTR, tmp);
                }
        }
+
        if (m_fd >= 0)
        {
-               eDebug("close frontend %d", m_dvbid);
-               m_tuneTimer->stop();
+               eDebugNoSimulate("close frontend %d", m_dvbid);
+               if (m_data[SATCR] != -1)
+               {
+                       if (!no_delayed)
+                       {
+                               m_sec->prepareTurnOffSatCR(*this, m_data[SATCR]);
+                               m_tuneTimer->start(0, true);
+                               if(!m_tuneTimer->isActive())
+                               {
+                                       int timeout=0;
+                                       eDebug("[turnOffSatCR] no mainloop");
+                                       while(true)
+                                       {
+                                               timeout = tuneLoopInt();
+                                               if (timeout == -1)
+                                                       break;
+                                               usleep(timeout*1000); // blockierendes wait.. eTimer gibts ja nicht mehr
+                                       }
+                               }
+                               else
+                                       eDebug("[turnOffSatCR] running mainloop");
+                               return 0;
+                       }
+                       else
+                               m_data[ROTOR_CMD] = -1;
+               }
+
                setTone(iDVBFrontend::toneOff);
                setVoltage(iDVBFrontend::voltageOff);
-               if (m_sec)
-                       m_sec->setRotorMoving(false);
+               m_tuneTimer->stop();
+
+               if (m_sec && !m_simulate)
+                       m_sec->setRotorMoving(m_slotid, false);
                if (!::close(m_fd))
                        m_fd=-1;
                else
                        eWarning("couldnt close frontend %d", m_dvbid);
        }
+       else if (m_simulate)
+       {
+               setTone(iDVBFrontend::toneOff);
+               setVoltage(iDVBFrontend::voltageOff);
+       }
 #if HAVE_DVB_API_VERSION < 3
        if (m_secfd >= 0)
        {
@@ -569,7 +654,6 @@ int eDVBFrontend::closeFrontend(bool force)
                        eWarning("couldnt close sec %d", m_dvbid);
        }
 #endif
-       delete m_sn;
        m_sn=0;
        m_state = stateClosed;
 
@@ -580,12 +664,18 @@ eDVBFrontend::~eDVBFrontend()
 {
        m_data[LINKED_PREV_PTR] = m_data[LINKED_NEXT_PTR] = -1;
        closeFrontend();
-       delete m_timeout;
-       delete m_tuneTimer;
 }
 
 void eDVBFrontend::feEvent(int w)
 {
+       eDVBFrontend *sec_fe = this;
+       long tmp = m_data[LINKED_PREV_PTR];
+       while (tmp != -1)
+       {
+               eDVBRegisteredFrontend *linked_fe = (eDVBRegisteredFrontend*)tmp;
+               sec_fe = linked_fe->m_frontend;
+               sec_fe->getData(LINKED_NEXT_PTR, tmp);
+       }
        while (1)
        {
 #if HAVE_DVB_API_VERSION < 3
@@ -600,42 +690,40 @@ void eDVBFrontend::feEvent(int w)
                if (res && (errno == EAGAIN))
                        break;
 
-               if (res)
-               {
-                       eWarning("FE_GET_EVENT failed! %m");
-                       return;
-               }
-
                if (w < 0)
                        continue;
 
 #if HAVE_DVB_API_VERSION < 3
                if (event.type == FE_COMPLETION_EV)
 #else
-               eDebug("(%d)fe event: status %x, inversion %s", m_dvbid, event.status, (event.parameters.inversion == INVERSION_ON) ? "on" : "off");
+               eDebug("(%d)fe event: status %x, inversion %s, m_tuning %d", m_dvbid, event.status, (event.parameters.inversion == INVERSION_ON) ? "on" : "off", m_tuning);
                if (event.status & FE_HAS_LOCK)
 #endif
                {
                        state = stateLock;
                } else
                {
-                       if (m_tuning)
+                       if (m_tuning) {
                                state = stateTuning;
+#if HAVE_DVB_API_VERSION >= 3
+                               if (event.status & FE_TIMEDOUT) {
+                                       eDebug("FE_TIMEDOUT! ..abort");
+                                       m_tuneTimer->stop();
+                                       timeout();
+                                       return;
+                               }
+                               ++m_tuning;
+#else
+                               m_tuneTimer->stop();
+                               timeout();
+#endif
+                       }
                        else
                        {
-                               eDVBFrontend *sec_fe = this;
-                               long tmp = m_data[LINKED_PREV_PTR];
-
                                eDebug("stateLostLock");
                                state = stateLostLock;
-
-                               while (tmp != -1)
-                               {
-                                       eDVBRegisteredFrontend *linked_fe = (eDVBRegisteredFrontend*)tmp;
-                                       sec_fe = linked_fe->m_frontend;
-                                       sec_fe->getData(LINKED_NEXT_PTR, tmp);
-                               }
-                               sec_fe->m_data[CSW] = sec_fe->m_data[UCSW] = sec_fe->m_data[TONEBURST] = -1; // reset diseqc
+                               if (!m_rotor_mode)
+                                       sec_fe->m_data[CSW] = sec_fe->m_data[UCSW] = sec_fe->m_data[TONEBURST] = -1; // reset diseqc
                        }
                }
                if (m_state != state)
@@ -658,6 +746,12 @@ void eDVBFrontend::timeout()
 
 #define INRANGE(X,Y,Z) (((X<=Y) && (Y<=Z))||((Z<=Y) && (Y<=X)) ? 1 : 0)
 
+/* unsigned 32 bit division */
+static inline uint32_t fe_udiv(uint32_t a, uint32_t b)
+{
+       return (a + b / 2) / b;
+}
+
 int eDVBFrontend::readFrontendData(int type)
 {
        switch(type)
@@ -665,62 +759,88 @@ int eDVBFrontend::readFrontendData(int type)
                case bitErrorRate:
                {
                        uint32_t ber=0;
-                       if (ioctl(m_fd, FE_READ_BER, &ber) < 0 && errno != ERANGE)
-                               eDebug("FE_READ_BER failed (%m)");
+                       if (!m_simulate)
+                       {
+                               if (ioctl(m_fd, FE_READ_BER, &ber) < 0 && errno != ERANGE)
+                                       eDebug("FE_READ_BER failed (%m)");
+                       }
                        return ber;
                }
                case signalQuality:
-               {
-                       uint16_t snr=0;
-                       if (ioctl(m_fd, FE_READ_SNR, &snr) < 0 && errno != ERANGE)
-                               eDebug("FE_READ_SNR failed (%m)");
-                       return snr;
-               }
                case signalQualitydB: /* this will move into the driver */
                {
+                       int sat_max = 1600; // for stv0288 / bsbe2
+                       int ret = 0x12345678;
                        uint16_t snr=0;
+                       if (m_simulate)
+                               return 0;
                        if (ioctl(m_fd, FE_READ_SNR, &snr) < 0 && errno != ERANGE)
                                eDebug("FE_READ_SNR failed (%m)");
-                       if (!strcmp(m_description, "BCM4501 (internal)"))
+                       else if (!strcmp(m_description, "BCM4501 (internal)"))
                        {
-                               unsigned int SDS_SNRE = snr << 16;
-
-                               static float SNR_COEFF[6] = {
-                                       100.0 / 4194304.0,
-                                       -7136.0 / 4194304.0,
-                                       197418.0 / 4194304.0,
-                                       -2602183.0 / 4194304.0,
-                                       20377212.0 / 4194304.0,
-                                       -37791203.0 / 4194304.0,
-                               };
-                       
-                               float fval1, fval2, snr_in_db;
-                               int i;
-                               fval1 = 12.44714 - (2.0 * log10(SDS_SNRE / 256.0));
-                               fval2 = pow(10.0, fval1)-1;
-                               fval1 = 10.0 * log10(fval2);
-                       
-                               if (fval1 < 10.0)
+                               float SDS_SNRE = snr << 16;
+                               float snr_in_db;
+
+                               if (oparm.sat.system == eDVBFrontendParametersSatellite::System_DVB_S) // DVB-S1 / QPSK
                                {
-                                       fval2 = SNR_COEFF[0];
-                                       for (i=0; i<6; ++i)
+                                       static float SNR_COEFF[6] = {
+                                               100.0 / 4194304.0,
+                                               -7136.0 / 4194304.0,
+                                               197418.0 / 4194304.0,
+                                               -2602183.0 / 4194304.0,
+                                               20377212.0 / 4194304.0,
+                                               -37791203.0 / 4194304.0,
+                                       };
+                                       float fval1 = 12.44714 - (2.0 * log10(SDS_SNRE / 256.0)),
+                                         fval2 = pow(10.0, fval1)-1;
+                                       fval1 = 10.0 * log10(fval2);
+
+                                       if (fval1 < 10.0)
                                        {
-                                               fval2 *= fval1;
-                                               fval2 += SNR_COEFF[i];
+                                               fval2 = SNR_COEFF[0];
+                                               for (int i=1; i<6; ++i)
+                                               {
+                                                       fval2 *= fval1;
+                                                       fval2 += SNR_COEFF[i];
+                                               }
+                                               fval1 = fval2;
                                        }
-                                       fval1 = fval2;
+                                       snr_in_db = fval1;
                                }
-                               snr_in_db = fval1;
-                       
-                               return (int)(snr_in_db * 100.0);
+#if HAVE_DVB_API_VERSION >= 3
+                               else
+                               {
+                                       float fval1 = SDS_SNRE / 268435456.0,
+                                                 fval2, fval3, fval4;
+
+                                       if (parm_u_qpsk_fec_inner <= FEC_S2_QPSK_9_10) // DVB-S2 QPSK
+                                       {
+                                               fval2 = 6.76;
+                                               fval3 = 4.35;
+                                       }
+                                       else // 8PSK
+                                       {
+                                               fval1 *= 0.5;
+                                               fval2 = 8.06;
+                                               fval3 = 6.18;
+                                       }
+                                       fval4 = -10.0 * log10(fval1);
+                                       fval1 = fval4;
+                                       for (int i=0; i < 5; ++i)
+                                               fval1 = fval4 - fval2 * log10(1.0+pow(10.0, (fval3-fval1)/fval2));
+                                       snr_in_db = fval1;
+                               }
+#endif
+                               sat_max = 1750;
+                               ret = (int)(snr_in_db * 100);
                        }
                        else if (strstr(m_description, "Alps BSBE1 C01A") ||
-                               !strcmp(m_description, "Alps -S(STV0288)"))
+                               strstr(m_description, "Alps -S(STV0288)"))
                        {
                                if (snr == 0)
-                                       return 0;
+                                       ret = 0;
                                else if (snr == 0xFFFF) // i think this should not happen
-                                       return 100*100;
+                                       ret = 100*100;
                                else
                                {
                                        enum { REALVAL, REGVAL };
@@ -733,13 +853,13 @@ int eDVBFrontend::readFrontendData(int type)
                                                {250,1123}, {260,1058}, {270,1004}, {280,957}, {290,920},
                                                {300,890}
                                        };
-                                       long regval = 0xFFFF - ((snr / 3) + 0xA100), // revert some dvb api calulations to get the real register value
+                                       int add=strchr(m_description, '.') ? 0xA250 : 0xA100;
+                                       long regval = 0xFFFF - ((snr / 3) + add), // revert some dvb api calulations to get the real register value
                                                Imin=0,
                                                Imax=30,
                                                i;
                                        if(INRANGE(CN_lookup[Imin][REGVAL],regval,CN_lookup[Imax][REGVAL]))
                                        {
-                                               long val;
                                                while((Imax-Imin)>1)
                                                {
                                                        i=(Imax+Imin)/2;
@@ -748,34 +868,84 @@ int eDVBFrontend::readFrontendData(int type)
                                                        else
                                                                Imin = i;
                                                }
-                                               return (((regval - CN_lookup[Imin][REGVAL])
+                                               ret = (((regval - CN_lookup[Imin][REGVAL])
                                                                * (CN_lookup[Imax][REALVAL] - CN_lookup[Imin][REALVAL])
                                                                / (CN_lookup[Imax][REGVAL] - CN_lookup[Imin][REGVAL]))
                                                                + CN_lookup[Imin][REALVAL]) * 10;
                                        }
-                                       return 100;
+                                       else
+                                               ret = 100;
                                }
-                               return 0;
                        }
                        else if (!strcmp(m_description, "Alps BSBE1 702A") ||  // some frontends with STV0299
                                !strcmp(m_description, "Alps -S") ||
                                !strcmp(m_description, "Philips -S") ||
                                !strcmp(m_description, "LG -S") )
                        {
-                               float snr_in_db=(snr-39075)/1764.7;
-                               return (int)(snr_in_db * 100.0);
+                               sat_max = 1500;
+                               ret = (int)((snr-39075)/17.647);
                        } else if (!strcmp(m_description, "Alps BSBE2"))
                        {
-                               return (int)((snr >> 7) * 10.0);
-                       } /* else
+                               ret = (int)((snr >> 7) * 10);
+                       } else if (!strcmp(m_description, "Philips CU1216Mk3"))
+                       {
+                               int mse = (~snr) & 0xFF;
+                               switch (parm_u_qam_modulation) {
+                               case QAM_16: ret = fe_udiv(1950000, (32 * mse) + 138) + 1000; break;
+                               case QAM_32: ret = fe_udiv(2150000, (40 * mse) + 500) + 1350; break;
+                               case QAM_64: ret = fe_udiv(2100000, (40 * mse) + 500) + 1250; break;
+                               case QAM_128: ret = fe_udiv(1850000, (38 * mse) + 400) + 1380; break;
+                               case QAM_256: ret = fe_udiv(1800000, (100 * mse) + 40) + 2030; break;
+                               default: break;
+                               }
+                       } else if (!strcmp(m_description, "Philips TU1216"))
+                       {
+                               snr = 0xFF - (snr & 0xFF);
+                               if (snr != 0)
+                                       ret = 10 * (int)(-100 * (log10(snr) - log10(255)));
+                       }
+                       else if (strstr(m_description, "BCM4506") || strstr(m_description, "BCM4505"))
+                               ret = (snr * 100) >> 8;
+                       else if (!strcmp(m_description, "CXD1981"))
+                       {
+                               int mse = (~snr) & 0xFF;
+                               switch (parm_u_qam_modulation) {
+                                       case QAM_16:
+                                       case QAM_64:
+                                       case QAM_256: ret = (int)(-950 * log(((double)mse) / 760)); break;
+                                       case QAM_32:
+                                       case QAM_128: ret = (int)(-875 * log(((double)mse) / 650)); break;
+
+                                       default: break;
+                               }
+                       }
+
+                       if (type == signalQuality)
+                       {
+                               if (ret == 0x12345678) // no snr db calculation avail.. return untouched snr value..
+                                       return snr;
+                               switch(m_type)
+                               {
+                                       case feSatellite:
+                                               return ret >= sat_max ? 65536 : ret * 65536 / sat_max;
+                                       case feCable: // we assume a max of 42db here
+                                               return ret >= 4200 ? 65536 : ret * 65536 / 4200;
+                                       case feTerrestrial: // we assume a max of 24db here
+                                               return ret >= 2400 ? 65536 : ret * 65536 / 2400;
+                               }
+                       }
+/* else
                                eDebug("no SNR dB calculation for frontendtype %s yet", m_description); */
-                       return 0x12345678;
+                       return ret;
                }
                case signalPower:
                {
                        uint16_t strength=0;
-                       if (ioctl(m_fd, FE_READ_SIGNAL_STRENGTH, &strength) < 0 && errno != ERANGE)
-                               eDebug("FE_READ_SIGNAL_STRENGTH failed (%m)");
+                       if (!m_simulate)
+                       {
+                               if (ioctl(m_fd, FE_READ_SIGNAL_STRENGTH, &strength) < 0 && errno != ERANGE)
+                                       eDebug("FE_READ_SIGNAL_STRENGTH failed (%m)");
+                       }
                        return strength;
                }
                case locked:
@@ -785,9 +955,13 @@ int eDVBFrontend::readFrontendData(int type)
 #else
                        fe_status_t status;
 #endif
-                       if ( ioctl(m_fd, FE_READ_STATUS, &status) < 0 && errno != ERANGE )
-                               eDebug("FE_READ_STATUS failed (%m)");
-                       return !!(status&FE_HAS_LOCK);
+                       if (!m_simulate)
+                       {
+                               if ( ioctl(m_fd, FE_READ_STATUS, &status) < 0 && errno != ERANGE )
+                                       eDebug("FE_READ_STATUS failed (%m)");
+                               return !!(status&FE_HAS_LOCK);
+                       }
+                       return 1;
                }
                case synced:
                {
@@ -796,9 +970,13 @@ int eDVBFrontend::readFrontendData(int type)
 #else
                        fe_status_t status;
 #endif
-                       if ( ioctl(m_fd, FE_READ_STATUS, &status) < 0 && errno != ERANGE )
-                               eDebug("FE_READ_STATUS failed (%m)");
-                       return !!(status&FE_HAS_SYNC);
+                       if (!m_simulate)
+                       {
+                               if ( ioctl(m_fd, FE_READ_STATUS, &status) < 0 && errno != ERANGE )
+                                       eDebug("FE_READ_STATUS failed (%m)");
+                               return !!(status&FE_HAS_SYNC);
+                       }
+                       return 1;
                }
                case frontendNumber:
                        return m_slotid;
@@ -844,126 +1022,191 @@ void PutToDict(ePyObject &dict, const char*key, const char *value)
                eDebug("could not create PyObject for %s", key);
 }
 
-void fillDictWithSatelliteData(ePyObject dict, const FRONTENDPARAMETERS &parm, eDVBFrontend *fe)
+void PutSatelliteDataToDict(ePyObject &dict, eDVBFrontendParametersSatellite &feparm)
+{
+       PutToDict(dict, "tuner_type", "DVB-S");
+       PutToDict(dict, "frequency", feparm.frequency);
+       PutToDict(dict, "symbol_rate", feparm.symbol_rate);
+       PutToDict(dict, "orbital_position", feparm.orbital_position);
+       PutToDict(dict, "inversion", feparm.inversion);
+       PutToDict(dict, "fec_inner", feparm.fec);
+       PutToDict(dict, "modulation", feparm.modulation);
+       PutToDict(dict, "polarization", feparm.polarisation);
+       if (feparm.system == eDVBFrontendParametersSatellite::System_DVB_S2)
+       {
+               PutToDict(dict, "rolloff", feparm.rolloff);
+               PutToDict(dict, "pilot", feparm.pilot);
+       }
+       PutToDict(dict, "system", feparm.system);
+}
+
+void PutTerrestrialDataToDict(ePyObject &dict, eDVBFrontendParametersTerrestrial &feparm)
+{
+       PutToDict(dict, "tuner_type", "DVB-T");
+       PutToDict(dict, "frequency", feparm.frequency);
+       PutToDict(dict, "bandwidth", feparm.bandwidth);
+       PutToDict(dict, "code_rate_lp", feparm.code_rate_LP);
+       PutToDict(dict, "code_rate_hp", feparm.code_rate_HP);
+       PutToDict(dict, "constellation", feparm.modulation);
+       PutToDict(dict, "transmission_mode", feparm.transmission_mode);
+       PutToDict(dict, "guard_interval", feparm.guard_interval);
+       PutToDict(dict, "hierarchy_information", feparm.hierarchy);
+       PutToDict(dict, "inversion", feparm.inversion);
+}
+
+void PutCableDataToDict(ePyObject &dict, eDVBFrontendParametersCable &feparm)
+{
+       PutToDict(dict, "tuner_type", "DVB-C");
+       PutToDict(dict, "frequency", feparm.frequency);
+       PutToDict(dict, "symbol_rate", feparm.symbol_rate);
+       PutToDict(dict, "modulation", feparm.modulation);
+       PutToDict(dict, "inversion", feparm.inversion);
+       PutToDict(dict, "fec_inner", feparm.fec_inner);
+}
+
+#if HAVE_DVB_API_VERSION >= 5
+static void fillDictWithSatelliteData(ePyObject dict, const FRONTENDPARAMETERS &parm, struct dtv_property *p, long freq_offset, int orb_pos, int polarization)
 {
-       long freq_offset=0;
-       const char *tmp=0;
-       fe->getData(eDVBFrontend::FREQ_OFFSET, freq_offset);
+       long tmp=0;
        int frequency = parm_frequency + freq_offset;
        PutToDict(dict, "frequency", frequency);
        PutToDict(dict, "symbol_rate", parm_u_qpsk_symbol_rate);
+       PutToDict(dict, "orbital_position", orb_pos);
+       PutToDict(dict, "polarization", polarization);
+
        switch(parm_u_qpsk_fec_inner)
        {
-       case FEC_1_2:
-               tmp = "FEC_1_2";
-               break;
-       case FEC_2_3:
-               tmp = "FEC_2_3";
-               break;
-       case FEC_3_4:
-               tmp = "FEC_3_4";
-               break;
-       case FEC_5_6:
-               tmp = "FEC_5_6";
-               break;
-       case FEC_7_8:
-               tmp = "FEC_7_8";
-               break;
-       case FEC_NONE:
-               tmp = "FEC_NONE";
+       case FEC_1_2: tmp = eDVBFrontendParametersSatellite::FEC_1_2; break;
+       case FEC_2_3: tmp = eDVBFrontendParametersSatellite::FEC_2_3; break;
+       case FEC_3_4: tmp = eDVBFrontendParametersSatellite::FEC_3_4; break;
+       case FEC_3_5: tmp = eDVBFrontendParametersSatellite::FEC_3_5; break;
+       case FEC_4_5: tmp = eDVBFrontendParametersSatellite::FEC_4_5; break;
+       case FEC_5_6: tmp = eDVBFrontendParametersSatellite::FEC_5_6; break;
+       case FEC_7_8: tmp = eDVBFrontendParametersSatellite::FEC_7_8; break;
+       case FEC_8_9: tmp = eDVBFrontendParametersSatellite::FEC_8_9; break;
+       case FEC_9_10: tmp = eDVBFrontendParametersSatellite::FEC_9_10; break;
+       case FEC_NONE: tmp = eDVBFrontendParametersSatellite::FEC_None; break;
+       case FEC_AUTO: tmp = eDVBFrontendParametersSatellite::FEC_Auto; break;
+       default: eDebug("got unsupported FEC from frontend! report as FEC_AUTO!\n");
+       }
+       PutToDict(dict, "fec_inner", tmp);
+
+       switch (p[0].u.data)
+       {
+       default: eDebug("got unsupported system from frontend! report as DVBS!");
+       case SYS_DVBS: tmp = eDVBFrontendParametersSatellite::System_DVB_S; break;
+       case SYS_DVBS2:
+       {
+               switch (p[2].u.data)
+               {
+               default: eDebug("got unsupported rolloff from frontend! report as 0_20!");
+               case ROLLOFF_20: tmp = eDVBFrontendParametersSatellite::RollOff_alpha_0_20; break;
+               case ROLLOFF_25: tmp = eDVBFrontendParametersSatellite::RollOff_alpha_0_25; break;
+               case ROLLOFF_35: tmp = eDVBFrontendParametersSatellite::RollOff_alpha_0_35; break;
+               }
+               PutToDict(dict, "rolloff", tmp);
+
+               switch (p[3].u.data)
+               {
+               case PILOT_OFF: tmp = eDVBFrontendParametersSatellite::Pilot_Off; break;
+               case PILOT_ON: tmp = eDVBFrontendParametersSatellite::Pilot_On; break;
+               case PILOT_AUTO: tmp = eDVBFrontendParametersSatellite::Pilot_Unknown; break;
+               }
+               PutToDict(dict, "pilot", tmp);
+
+               tmp = eDVBFrontendParametersSatellite::System_DVB_S2; break;
+       }
+       }
+       PutToDict(dict, "system", tmp);
+
+       switch (p[1].u.data)
+       {
+       default: eDebug("got unsupported modulation from frontend! report as QPSK!");
+       case QPSK: tmp = eDVBFrontendParametersSatellite::Modulation_QPSK; break;
+       case PSK_8: tmp = eDVBFrontendParametersSatellite::Modulation_8PSK; break;
+       }
+       PutToDict(dict, "modulation", tmp);
+}
+
+#else
+static void fillDictWithSatelliteData(ePyObject dict, const FRONTENDPARAMETERS &parm, long freq_offset, int orb_pos, int polarization)
+{
+       long tmp=0;
+       int frequency = parm_frequency + freq_offset;
+       PutToDict(dict, "frequency", frequency);
+       PutToDict(dict, "symbol_rate", parm_u_qpsk_symbol_rate);
+       PutToDict(dict, "orbital_position", orb_pos);
+       PutToDict(dict, "polarization", polarization);
+
+       switch((int)parm_u_qpsk_fec_inner)
+       {
+       case FEC_1_2: tmp = eDVBFrontendParametersSatellite::FEC_1_2; break;
+       case FEC_2_3: tmp = eDVBFrontendParametersSatellite::FEC_2_3; break;
+       case FEC_3_4: tmp = eDVBFrontendParametersSatellite::FEC_3_4; break;
+       case FEC_5_6: tmp = eDVBFrontendParametersSatellite::FEC_5_6; break;
+       case FEC_7_8: tmp = eDVBFrontendParametersSatellite::FEC_7_8; break;
+       case FEC_NONE: tmp = eDVBFrontendParametersSatellite::FEC_None; break;
        default:
-       case FEC_AUTO:
-               tmp = "FEC_AUTO";
-               break;
+       case FEC_AUTO: tmp = eDVBFrontendParametersSatellite::FEC_Auto; break;
 #if HAVE_DVB_API_VERSION >=3
        case FEC_S2_8PSK_1_2:
-       case FEC_S2_QPSK_1_2:
-               tmp = "FEC_1_2";
-               break;
+       case FEC_S2_QPSK_1_2: tmp = eDVBFrontendParametersSatellite::FEC_1_2; break;
        case FEC_S2_8PSK_2_3:
-       case FEC_S2_QPSK_2_3:
-               tmp = "FEC_2_3";
-               break;
+       case FEC_S2_QPSK_2_3: tmp = eDVBFrontendParametersSatellite::FEC_2_3; break;
        case FEC_S2_8PSK_3_4:
-       case FEC_S2_QPSK_3_4:
-               tmp = "FEC_3_4";
-               break;
+       case FEC_S2_QPSK_3_4: tmp = eDVBFrontendParametersSatellite::FEC_3_4; break;
        case FEC_S2_8PSK_5_6:
-       case FEC_S2_QPSK_5_6:
-               tmp = "FEC_5_6";
-               break;
+       case FEC_S2_QPSK_5_6: tmp = eDVBFrontendParametersSatellite::FEC_5_6; break;
        case FEC_S2_8PSK_7_8:
-       case FEC_S2_QPSK_7_8:
-               tmp = "FEC_7_8";
-               break;
+       case FEC_S2_QPSK_7_8: tmp = eDVBFrontendParametersSatellite::FEC_7_8; break;
        case FEC_S2_8PSK_8_9:
-       case FEC_S2_QPSK_8_9:
-               tmp = "FEC_8_9";
-               break;
+       case FEC_S2_QPSK_8_9: tmp = eDVBFrontendParametersSatellite::FEC_8_9; break;
        case FEC_S2_8PSK_3_5:
-       case FEC_S2_QPSK_3_5:
-               tmp = "FEC_3_5";
-               break;
+       case FEC_S2_QPSK_3_5: tmp = eDVBFrontendParametersSatellite::FEC_3_5; break;
        case FEC_S2_8PSK_4_5:
-       case FEC_S2_QPSK_4_5:
-               tmp = "FEC_4_5";
-               break;
+       case FEC_S2_QPSK_4_5: tmp = eDVBFrontendParametersSatellite::FEC_4_5; break;
        case FEC_S2_8PSK_9_10:
-       case FEC_S2_QPSK_9_10:
-               tmp = "FEC_9_10";
-               break;
+       case FEC_S2_QPSK_9_10: tmp = eDVBFrontendParametersSatellite::FEC_9_10; break;
 #endif
        }
        PutToDict(dict, "fec_inner", tmp);
 #if HAVE_DVB_API_VERSION >=3
        PutToDict(dict, "modulation",
-               parm_u_qpsk_fec_inner > FEC_S2_QPSK_9_10 ? "8PSK": "QPSK" );
+               parm_u_qpsk_fec_inner > FEC_S2_QPSK_9_10 ?
+                       eDVBFrontendParametersSatellite::Modulation_8PSK :
+                       eDVBFrontendParametersSatellite::Modulation_QPSK );
        if (parm_u_qpsk_fec_inner > FEC_AUTO)
        {
                switch(parm_inversion & 0xc)
                {
                default: // unknown rolloff
-               case 0: // 0.35
-                       tmp = "ROLLOFF_0_35";
-                       break;
-               case 4: // 0.25
-                       tmp = "ROLLOFF_0_25";
-                       break;
-               case 8: // 0.20
-                       tmp = "ROLLOFF_0_20";
-                       break;
+               case 0: tmp = eDVBFrontendParametersSatellite::RollOff_alpha_0_35; break;
+               case 4: tmp = eDVBFrontendParametersSatellite::RollOff_alpha_0_25; break;
+               case 8: tmp = eDVBFrontendParametersSatellite::RollOff_alpha_0_20; break;
                }
                PutToDict(dict, "rolloff", tmp);
-               if (parm_u_qpsk_fec_inner > FEC_S2_QPSK_9_10)
+               switch(parm_inversion & 0x30)
                {
-                       switch(parm_inversion & 0x30)
-                       {
-                       case 0: // pilot off
-                               tmp = "PILOT_OFF";
-                               break;
-                       case 0x10: // pilot on
-                               tmp = "PILOT_ON";
-                               break;
-                       case 0x20: // pilot auto
-                               tmp = "PILOT_AUTO";
-                               break;
-                       }
-                       PutToDict(dict, "pilot", tmp);
+               case 0: tmp = eDVBFrontendParametersSatellite::Pilot_Off; break;
+               case 0x10: tmp = eDVBFrontendParametersSatellite::Pilot_On; break;
+               case 0x20: tmp = eDVBFrontendParametersSatellite::Pilot_Unknown; break;
                }
-               tmp = "DVB-S2";
+               PutToDict(dict, "pilot", tmp);
+               tmp = eDVBFrontendParametersSatellite::System_DVB_S2;
        }
        else
-               tmp = "DVB-S";
+               tmp = eDVBFrontendParametersSatellite::System_DVB_S;
 #else
-       PutToDict(dict, "modulation", "QPSK" );
-       tmp = "DVB-S";
+       PutToDict(dict, "modulation", eDVBFrontendParametersSatellite::Modulation_QPSK );
+       tmp = eDVBFrontendParametersSatellite::System_DVB_S;
 #endif
        PutToDict(dict, "system", tmp);
 }
+#endif
 
-void fillDictWithCableData(ePyObject dict, const FRONTENDPARAMETERS &parm)
+static void fillDictWithCableData(ePyObject dict, const FRONTENDPARAMETERS &parm)
 {
-       const char *tmp=0;
+       long tmp=0;
 #if HAVE_DVB_API_VERSION < 3
        PutToDict(dict, "frequency", parm_frequency);
 #else
@@ -972,196 +1215,102 @@ void fillDictWithCableData(ePyObject dict, const FRONTENDPARAMETERS &parm)
        PutToDict(dict, "symbol_rate", parm_u_qam_symbol_rate);
        switch(parm_u_qam_fec_inner)
        {
-       case FEC_NONE:
-               tmp = "FEC_NONE";
-               break;
-       case FEC_1_2:
-               tmp = "FEC_1_2";
-               break;
-       case FEC_2_3:
-               tmp = "FEC_2_3";
-               break;
-       case FEC_3_4:
-               tmp = "FEC_3_4";
-               break;
-       case FEC_5_6:
-               tmp = "FEC_5_6";
-               break;
-       case FEC_7_8:
-               tmp = "FEC_7_8";
-               break;
+       case FEC_NONE: tmp = eDVBFrontendParametersCable::FEC_None; break;
+       case FEC_1_2: tmp = eDVBFrontendParametersCable::FEC_1_2; break;
+       case FEC_2_3: tmp = eDVBFrontendParametersCable::FEC_2_3; break;
+       case FEC_3_4: tmp = eDVBFrontendParametersCable::FEC_3_4; break;
+       case FEC_5_6: tmp = eDVBFrontendParametersCable::FEC_5_6; break;
+       case FEC_7_8: tmp = eDVBFrontendParametersCable::FEC_7_8; break;
 #if HAVE_DVB_API_VERSION >= 3
-       case FEC_8_9:
-               tmp = "FEC_8_9";
-               break;
+       case FEC_8_9: tmp = eDVBFrontendParametersCable::FEC_7_8; break;
 #endif
        default:
-       case FEC_AUTO:
-               tmp = "FEC_AUTO";
-               break;
+       case FEC_AUTO: tmp = eDVBFrontendParametersCable::FEC_Auto; break;
        }
        PutToDict(dict, "fec_inner", tmp);
        switch(parm_u_qam_modulation)
        {
-       case QAM_16:
-               tmp = "QAM_16";
-               break;
-       case QAM_32:
-               tmp = "QAM_32";
-               break;
-       case QAM_64:
-               tmp = "QAM_64";
-               break;
-       case QAM_128:
-               tmp = "QAM_128";
-               break;
-       case QAM_256:
-               tmp = "QAM_256";
-               break;
+       case QAM_16: tmp = eDVBFrontendParametersCable::Modulation_QAM16; break;
+       case QAM_32: tmp = eDVBFrontendParametersCable::Modulation_QAM32; break;
+       case QAM_64: tmp = eDVBFrontendParametersCable::Modulation_QAM64; break;
+       case QAM_128: tmp = eDVBFrontendParametersCable::Modulation_QAM128; break;
+       case QAM_256: tmp = eDVBFrontendParametersCable::Modulation_QAM256; break;
        default:
-       case QAM_AUTO:
-               tmp = "QAM_AUTO";
-               break;
+       case QAM_AUTO:   tmp = eDVBFrontendParametersCable::Modulation_Auto; break;
        }
        PutToDict(dict, "modulation", tmp);
 }
 
-void fillDictWithTerrestrialData(ePyObject dict, const FRONTENDPARAMETERS &parm)
+static void fillDictWithTerrestrialData(ePyObject dict, const FRONTENDPARAMETERS &parm)
 {
-       const char *tmp=0;
+       long tmp=0;
        PutToDict(dict, "frequency", parm_frequency);
        switch (parm_u_ofdm_bandwidth)
        {
-       case BANDWIDTH_8_MHZ:
-               tmp = "BANDWIDTH_8_MHZ";
-               break;
-       case BANDWIDTH_7_MHZ:
-               tmp = "BANDWIDTH_7_MHZ";
-               break;
-       case BANDWIDTH_6_MHZ:
-               tmp = "BANDWIDTH_6_MHZ";
-               break;
+       case BANDWIDTH_8_MHZ: tmp = eDVBFrontendParametersTerrestrial::Bandwidth_8MHz; break;
+       case BANDWIDTH_7_MHZ: tmp = eDVBFrontendParametersTerrestrial::Bandwidth_7MHz; break;
+       case BANDWIDTH_6_MHZ: tmp = eDVBFrontendParametersTerrestrial::Bandwidth_6MHz; break;
        default:
-       case BANDWIDTH_AUTO:
-               tmp = "BANDWIDTH_AUTO";
-               break;
+       case BANDWIDTH_AUTO: tmp = eDVBFrontendParametersTerrestrial::Bandwidth_Auto; break;
        }
        PutToDict(dict, "bandwidth", tmp);
        switch (parm_u_ofdm_code_rate_LP)
        {
-       case FEC_1_2:
-               tmp = "FEC_1_2";
-               break;
-       case FEC_2_3:
-               tmp = "FEC_2_3";
-               break;
-       case FEC_3_4:
-               tmp = "FEC_3_4";
-               break;
-       case FEC_5_6:
-               tmp = "FEC_5_6";
-               break;
-       case FEC_7_8:
-               tmp = "FEC_7_8";
-               break;
+       case FEC_1_2: tmp = eDVBFrontendParametersTerrestrial::FEC_1_2; break;
+       case FEC_2_3: tmp = eDVBFrontendParametersTerrestrial::FEC_2_3; break;
+       case FEC_3_4: tmp = eDVBFrontendParametersTerrestrial::FEC_3_4; break;
+       case FEC_5_6: tmp = eDVBFrontendParametersTerrestrial::FEC_5_6; break;
+       case FEC_7_8: tmp = eDVBFrontendParametersTerrestrial::FEC_7_8; break;
        default:
-       case FEC_AUTO:
-               tmp = "FEC_AUTO";
-               break;
+       case FEC_AUTO: tmp = eDVBFrontendParametersTerrestrial::FEC_Auto; break;
        }
        PutToDict(dict, "code_rate_lp", tmp);
        switch (parm_u_ofdm_code_rate_HP)
        {
-       case FEC_1_2:
-               tmp = "FEC_1_2";
-               break;
-       case FEC_2_3:
-               tmp = "FEC_2_3";
-               break;
-       case FEC_3_4:
-               tmp = "FEC_3_4";
-               break;
-       case FEC_5_6:
-               tmp = "FEC_5_6";
-               break;
-       case FEC_7_8:
-               tmp = "FEC_7_8";
-               break;
+       case FEC_1_2: tmp = eDVBFrontendParametersTerrestrial::FEC_1_2; break;
+       case FEC_2_3: tmp = eDVBFrontendParametersTerrestrial::FEC_2_3; break;
+       case FEC_3_4: tmp = eDVBFrontendParametersTerrestrial::FEC_3_4; break;
+       case FEC_5_6: tmp = eDVBFrontendParametersTerrestrial::FEC_5_6; break;
+       case FEC_7_8: tmp = eDVBFrontendParametersTerrestrial::FEC_7_8; break;
        default:
-       case FEC_AUTO:
-               tmp = "FEC_AUTO";
-               break;
+       case FEC_AUTO: tmp = eDVBFrontendParametersTerrestrial::FEC_Auto; break;
        }
        PutToDict(dict, "code_rate_hp", tmp);
        switch (parm_u_ofdm_constellation)
        {
-       case QPSK:
-               tmp = "QPSK";
-               break;
-       case QAM_16:
-               tmp = "QAM_16";
-               break;
-       case QAM_64:
-               tmp = "QAM_64";
-               break;
+       case QPSK: tmp = eDVBFrontendParametersTerrestrial::Modulation_QPSK; break;
+       case QAM_16: tmp = eDVBFrontendParametersTerrestrial::Modulation_QAM16; break;
+       case QAM_64: tmp = eDVBFrontendParametersTerrestrial::Modulation_QAM64; break;
        default:
-       case QAM_AUTO:
-               tmp = "QAM_AUTO";
-               break;
+       case QAM_AUTO: tmp = eDVBFrontendParametersTerrestrial::Modulation_Auto; break;
        }
        PutToDict(dict, "constellation", tmp);
        switch (parm_u_ofdm_transmission_mode)
        {
-       case TRANSMISSION_MODE_2K:
-               tmp = "TRANSMISSION_MODE_2K";
-               break;
-       case TRANSMISSION_MODE_8K:
-               tmp = "TRANSMISSION_MODE_8K";
-               break;
+       case TRANSMISSION_MODE_2K: tmp = eDVBFrontendParametersTerrestrial::TransmissionMode_2k; break;
+       case TRANSMISSION_MODE_8K: tmp = eDVBFrontendParametersTerrestrial::TransmissionMode_8k; break;
        default:
-       case TRANSMISSION_MODE_AUTO:
-               tmp = "TRANSMISSION_MODE_AUTO";
-               break;
+       case TRANSMISSION_MODE_AUTO: tmp = eDVBFrontendParametersTerrestrial::TransmissionMode_Auto; break;
        }
        PutToDict(dict, "transmission_mode", tmp);
        switch (parm_u_ofdm_guard_interval)
        {
-               case GUARD_INTERVAL_1_32:
-                       tmp = "GUARD_INTERVAL_1_32";
-                       break;
-               case GUARD_INTERVAL_1_16:
-                       tmp = "GUARD_INTERVAL_1_16";
-                       break;
-               case GUARD_INTERVAL_1_8:
-                       tmp = "GUARD_INTERVAL_1_8";
-                       break;
-               case GUARD_INTERVAL_1_4:
-                       tmp = "GUARD_INTERVAL_1_4";
-                       break;
+               case GUARD_INTERVAL_1_32: tmp = eDVBFrontendParametersTerrestrial::GuardInterval_1_32; break;
+               case GUARD_INTERVAL_1_16: tmp = eDVBFrontendParametersTerrestrial::GuardInterval_1_16; break;
+               case GUARD_INTERVAL_1_8: tmp = eDVBFrontendParametersTerrestrial::GuardInterval_1_8; break;
+               case GUARD_INTERVAL_1_4: tmp = eDVBFrontendParametersTerrestrial::GuardInterval_1_4; break;
                default:
-               case GUARD_INTERVAL_AUTO:
-                       tmp = "GUARD_INTERVAL_AUTO";
-                       break;
+               case GUARD_INTERVAL_AUTO: tmp = eDVBFrontendParametersTerrestrial::GuardInterval_Auto; break;
        }
        PutToDict(dict, "guard_interval", tmp);
        switch (parm_u_ofdm_hierarchy_information)
        {
-               case HIERARCHY_NONE:
-                       tmp = "HIERARCHY_NONE";
-                       break;
-               case HIERARCHY_1:
-                       tmp = "HIERARCHY_1";
-                       break;
-               case HIERARCHY_2:
-                       tmp = "HIERARCHY_2";
-                       break;
-               case HIERARCHY_4:
-                       tmp = "HIERARCHY_4";
-                       break;
+               case HIERARCHY_NONE: tmp = eDVBFrontendParametersTerrestrial::Hierarchy_None; break;
+               case HIERARCHY_1: tmp = eDVBFrontendParametersTerrestrial::Hierarchy_1; break;
+               case HIERARCHY_2: tmp = eDVBFrontendParametersTerrestrial::Hierarchy_2; break;
+               case HIERARCHY_4: tmp = eDVBFrontendParametersTerrestrial::Hierarchy_4; break;
                default:
-               case HIERARCHY_AUTO:
-                       tmp = "HIERARCHY_AUTO";
-                       break;
+               case HIERARCHY_AUTO: tmp = eDVBFrontendParametersTerrestrial::Hierarchy_Auto; break;
        }
        PutToDict(dict, "hierarchy_information", tmp);
 }
@@ -1211,51 +1360,80 @@ void eDVBFrontend::getFrontendStatus(ePyObject dest)
 
 void eDVBFrontend::getTransponderData(ePyObject dest, bool original)
 {
-       if (m_fd != -1 && dest && PyDict_Check(dest))
+       if (dest && PyDict_Check(dest))
        {
-               switch(m_type)
+               FRONTENDPARAMETERS front;
+#if HAVE_DVB_API_VERSION >= 5
+               struct dtv_property p[4];
+               struct dtv_properties cmdseq;
+               cmdseq.props = p;
+               cmdseq.num = 4;
+               p[0].cmd = DTV_DELIVERY_SYSTEM;
+               p[1].cmd = DTV_MODULATION;
+               p[2].cmd = DTV_ROLLOFF;
+               p[3].cmd = DTV_PILOT;
+#endif
+               if (m_simulate || m_fd == -1 || original)
+                       original = true;
+#if HAVE_DVB_API_VERSION >= 5
+               else if (m_type == feSatellite && // yet just use new api for DVB-S(2) only
+                       ioctl(m_fd, FE_GET_PROPERTY, &cmdseq)<0)
                {
-                       case feSatellite:
-                       case feCable:
-                       case feTerrestrial:
+                       eDebug("FE_GET_PROPERTY failed (%m)");
+                       original = true;
+               }
+#endif
+               else if (ioctl(m_fd, FE_GET_FRONTEND, &front)<0)
+               {
+                       eDebug("FE_GET_FRONTEND failed (%m)");
+                       original = true;
+               }
+               if (original)
+               {
+                       switch(m_type)
                        {
-                               FRONTENDPARAMETERS front;
-                               if (!original && ioctl(m_fd, FE_GET_FRONTEND, &front)<0)
-                                       eDebug("FE_GET_FRONTEND (%m)");
-                               else
-                               {
-                                       const FRONTENDPARAMETERS &parm = original ? this->parm : front;
-                                       const char *tmp = "INVERSION_AUTO";
-                                       switch(parm_inversion)
-                                       {
-                                               case INVERSION_ON:
-                                                       tmp = "INVERSION_ON";
-                                                       break;
-                                               case INVERSION_OFF:
-                                                       tmp = "INVERSION_OFF";
-                                                       break;
-                                               default:
-                                                       break;
-                                       }
-                                       if (tmp)
-                                               PutToDict(dest, "inversion", tmp);
-
-                                       switch(m_type)
-                                       {
-                                               case feSatellite:
-                                                       fillDictWithSatelliteData(dest, original?parm:front, this);
-                                                       break;
-                                               case feCable:
-                                                       fillDictWithCableData(dest, original?parm:front);
-                                                       break;
-                                               case feTerrestrial:
-                                                       fillDictWithTerrestrialData(dest, original?parm:front);
-                                                       break;
-                                       }
-                               }
+                               case feSatellite:
+                                       PutSatelliteDataToDict(dest, oparm.sat);
+                                       break;
+                               case feCable:
+                                       PutCableDataToDict(dest, oparm.cab);
+                                       break;
+                               case feTerrestrial:
+                                       PutTerrestrialDataToDict(dest, oparm.ter);
+                                       break;
+                       }
+               }
+               else
+               {
+                       FRONTENDPARAMETERS &parm = front;
+                       long tmp = eDVBFrontendParametersSatellite::Inversion_Unknown;
+                       switch(parm_inversion & 3)
+                       {
+                               case INVERSION_ON:
+                                       tmp = eDVBFrontendParametersSatellite::Inversion_On;
+                                       break;
+                               case INVERSION_OFF:
+                                       tmp = eDVBFrontendParametersSatellite::Inversion_Off;
+                               default:
+                                       break;
+                       }
+                       PutToDict(dest, "inversion", tmp);
+                       switch(m_type)
+                       {
+                               case feSatellite:
+#if HAVE_DVB_API_VERSION >= 5
+                                       fillDictWithSatelliteData(dest, parm, p, m_data[FREQ_OFFSET], oparm.sat.orbital_position, oparm.sat.polarisation);
+#else
+                                       fillDictWithSatelliteData(dest, parm, m_data[FREQ_OFFSET], oparm.sat.orbital_position, oparm.sat.polarisation);
+#endif
+                                       break;
+                               case feCable:
+                                       fillDictWithCableData(dest, parm);
+                                       break;
+                               case feTerrestrial:
+                                       fillDictWithTerrestrialData(dest, parm);
+                                       break;
                        }
-                       default:
-                               break;
                }
        }
 }
@@ -1290,11 +1468,15 @@ void eDVBFrontend::getFrontendData(ePyObject dest)
 #endif
 int eDVBFrontend::readInputpower()
 {
+       if (m_simulate)
+               return 0;
        int power=m_slotid;  // this is needed for read inputpower from the correct tuner !
        char proc_name[64];
-       sprintf(proc_name, "/proc/stb/fp/lnb_sense%d", m_slotid);
-       FILE *f=fopen(proc_name, "r");
-       if (f)
+       char proc_name2[64];
+       sprintf(proc_name, "/proc/stb/frontend/%d/lnb_sense", m_slotid);
+       sprintf(proc_name2, "/proc/stb/fp/lnb_sense%d", m_slotid);
+       FILE *f;
+       if ((f=fopen(proc_name, "r")) || (f=fopen(proc_name2, "r")))
        {
                if (fscanf(f, "%d", &power) != 1)
                        eDebug("read %s failed!! (%m)", proc_name);
@@ -1325,7 +1507,7 @@ int eDVBFrontend::readInputpower()
 
 bool eDVBFrontend::setSecSequencePos(int steps)
 {
-       eDebug("set sequence pos %d", steps);
+       eDebugNoSimulate("set sequence pos %d", steps);
        if (!steps)
                return false;
        while( steps > 0 )
@@ -1343,9 +1525,14 @@ bool eDVBFrontend::setSecSequencePos(int steps)
        return true;
 }
 
-void eDVBFrontend::tuneLoop()  // called by m_tuneTimer
+void eDVBFrontend::tuneLoop()
+{
+       tuneLoopInt();
+}
+
+int eDVBFrontend::tuneLoopInt()  // called by m_tuneTimer
 {
-       int delay=0;
+       int delay=-1;
        eDVBFrontend *sec_fe = this;
        eDVBRegisteredFrontend *regFE = 0;
        long tmp = m_data[LINKED_PREV_PTR];
@@ -1356,12 +1543,14 @@ void eDVBFrontend::tuneLoop()  // called by m_tuneTimer
                tmp = prev->m_frontend->m_data[LINKED_PREV_PTR];
                if (tmp == -1 && sec_fe != this && !prev->m_inuse) {
                        int state = sec_fe->m_state;
+                       // workaround to put the kernel frontend thread into idle state!
                        if (state != eDVBFrontend::stateIdle && state != stateClosed)
                        {
                                sec_fe->closeFrontend(true);
                                state = sec_fe->m_state;
                        }
-                       if (state == eDVBFrontend::stateClosed)
+                       // sec_fe is closed... we must reopen it here..
+                       if (state == stateClosed)
                        {
                                regFE = prev;
                                prev->inc_use();
@@ -1372,12 +1561,13 @@ void eDVBFrontend::tuneLoop()  // called by m_tuneTimer
        if ( m_sec_sequence && m_sec_sequence.current() != m_sec_sequence.end() )
        {
                long *sec_fe_data = sec_fe->m_data;
-//             eDebug("tuneLoop %d\n", m_sec_sequence.current()->cmd);
+//             eDebugNoSimulate("tuneLoop %d\n", m_sec_sequence.current()->cmd);
+               delay = 0;
                switch (m_sec_sequence.current()->cmd)
                {
                        case eSecCommand::SLEEP:
                                delay = m_sec_sequence.current()++->msec;
-                               eDebug("[SEC] sleep %dms", delay);
+                               eDebugNoSimulate("[SEC] sleep %dms", delay);
                                break;
                        case eSecCommand::GOTO:
                                if ( !setSecSequencePos(m_sec_sequence.current()->steps) )
@@ -1386,7 +1576,7 @@ void eDVBFrontend::tuneLoop()  // called by m_tuneTimer
                        case eSecCommand::SET_VOLTAGE:
                        {
                                int voltage = m_sec_sequence.current()++->voltage;
-                               eDebug("[SEC] setVoltage %d", voltage);
+                               eDebugNoSimulate("[SEC] setVoltage %d", voltage);
                                sec_fe->setVoltage(voltage);
                                break;
                        }
@@ -1423,41 +1613,50 @@ void eDVBFrontend::tuneLoop()  // called by m_tuneTimer
                                break;
                        }
                        case eSecCommand::SET_TONE:
-                               eDebug("[SEC] setTone %d", m_sec_sequence.current()->tone);
+                               eDebugNoSimulate("[SEC] setTone %d", m_sec_sequence.current()->tone);
                                sec_fe->setTone(m_sec_sequence.current()++->tone);
                                break;
                        case eSecCommand::SEND_DISEQC:
                                sec_fe->sendDiseqc(m_sec_sequence.current()->diseqc);
-                               eDebugNoNewLine("[SEC] sendDiseqc: ");
+                               eDebugNoSimulateNoNewLine("[SEC] sendDiseqc: ");
                                for (int i=0; i < m_sec_sequence.current()->diseqc.len; ++i)
-                                   eDebugNoNewLine("%02x", m_sec_sequence.current()->diseqc.data[i]);
-                               eDebug("");
+                                   eDebugNoSimulateNoNewLine("%02x", m_sec_sequence.current()->diseqc.data[i]);
+                               if (!memcmp(m_sec_sequence.current()->diseqc.data, "\xE0\x00\x00", 3))
+                                       eDebugNoSimulate("(DiSEqC reset)");
+                               else if (!memcmp(m_sec_sequence.current()->diseqc.data, "\xE0\x00\x03", 3))
+                                       eDebugNoSimulate("(DiSEqC peripherial power on)");
+                               else
+                                       eDebugNoSimulate("");
                                ++m_sec_sequence.current();
                                break;
                        case eSecCommand::SEND_TONEBURST:
-                               eDebug("[SEC] sendToneburst: %d", m_sec_sequence.current()->toneburst);
+                               eDebugNoSimulate("[SEC] sendToneburst: %d", m_sec_sequence.current()->toneburst);
                                sec_fe->sendToneburst(m_sec_sequence.current()++->toneburst);
                                break;
                        case eSecCommand::SET_FRONTEND:
-                               eDebug("[SEC] setFrontend");
-                               setFrontend();
-                               ++m_sec_sequence.current();
+                       {
+                               int enableEvents = (m_sec_sequence.current()++)->val;
+                               eDebugNoSimulate("[SEC] setFrontend %d", enableEvents);
+                               setFrontend(enableEvents);
                                break;
+                       }
                        case eSecCommand::START_TUNE_TIMEOUT:
                        {
-                               m_timeout->start(m_sec_sequence.current()->timeout, 1);
+                               int tuneTimeout = m_sec_sequence.current()->timeout;
+                               eDebugNoSimulate("[SEC] startTuneTimeout %d", tuneTimeout);
+                               if (!m_simulate)
+                                       m_timeout->start(tuneTimeout, 1);
                                ++m_sec_sequence.current();
                                break;
                        }
                        case eSecCommand::SET_TIMEOUT:
                                m_timeoutCount = m_sec_sequence.current()++->val;
-                               eDebug("[SEC] set timeout %d", m_timeoutCount);
+                               eDebugNoSimulate("[SEC] set timeout %d", m_timeoutCount);
                                break;
                        case eSecCommand::IF_TIMEOUT_GOTO:
                                if (!m_timeoutCount)
                                {
-                                       eDebug("[SEC] rotor timout");
-                                       m_sec->setRotorMoving(false);
+                                       eDebugNoSimulate("[SEC] rotor timout");
                                        setSecSequencePos(m_sec_sequence.current()->steps);
                                }
                                else
@@ -1469,23 +1668,23 @@ void eDVBFrontend::tuneLoop()  // called by m_tuneTimer
                                if ( idx == 0 || idx == 1 )
                                {
                                        m_idleInputpower[idx] = sec_fe->readInputpower();
-                                       eDebug("[SEC] idleInputpower[%d] is %d", idx, m_idleInputpower[idx]);
+                                       eDebugNoSimulate("[SEC] idleInputpower[%d] is %d", idx, m_idleInputpower[idx]);
                                }
                                else
-                                       eDebug("[SEC] idleInputpower measure index(%d) out of bound !!!", idx);
+                                       eDebugNoSimulate("[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.val;
-                               if ( idx == 0 || idx == 1 )
+                               if ( !m_simulate && (idx == 0 || idx == 1) )
                                {
                                        int idle = sec_fe->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);
+                                               eDebugNoSimulate("measure idle(%d) was not okay.. (%d - %d = %d) retry", idx, m_idleInputpower[idx], idle, diff);
                                                setSecSequencePos(compare.steps);
                                                break;
                                        }
@@ -1496,39 +1695,80 @@ void eDVBFrontend::tuneLoop()  // called by m_tuneTimer
                        case eSecCommand::IF_TUNER_LOCKED_GOTO:
                        {
                                eSecCommand::rotor &cmd = m_sec_sequence.current()->measure;
-                               if (readFrontendData(locked))
+                               if (m_simulate)
                                {
-                                       eDebug("[SEC] locked step %d ok", cmd.okcount);
+                                       setSecSequencePos(cmd.steps);
+                                       break;
+                               }
+                               int signal = 0;
+                               int isLocked = readFrontendData(locked);
+                               m_idleInputpower[0] = m_idleInputpower[1] = 0;
+                               --m_timeoutCount;
+                               if (!m_timeoutCount && m_retryCount > 0)
+                                       --m_retryCount;
+                               if (isLocked && ((abs((signal = readFrontendData(signalQualitydB)) - cmd.lastSignal) < 40) || !cmd.lastSignal))
+                               {
+                                       if (cmd.lastSignal)
+                                               eDebugNoSimulate("[SEC] locked step %d ok (%d %d)", cmd.okcount, signal, cmd.lastSignal);
+                                       else
+                                       {
+                                               eDebugNoSimulate("[SEC] locked step %d ok", cmd.okcount);
+                                               if (!cmd.okcount)
+                                                       cmd.lastSignal = signal;
+                                       }
                                        ++cmd.okcount;
-                                       if (cmd.okcount > 12)
+                                       if (cmd.okcount > 4)
                                        {
-                                               eDebug("ok > 12 .. goto %d\n",m_sec_sequence.current()->steps);
+                                               eDebugNoSimulate("ok > 4 .. goto %d\n", cmd.steps);
                                                setSecSequencePos(cmd.steps);
+                                               m_state = stateLock;
+                                               m_stateChanged(this);
+                                               feEvent(-1); // flush events
+                                               m_sn->start();
                                                break;
                                        }
                                }
                                else
                                {
-                                       eDebug("[SEC] rotor locked step %d failed", cmd.okcount);
-                                       --m_timeoutCount;
-                                       if (!m_timeoutCount && m_retryCount > 0)
-                                               --m_retryCount;
+                                       if (isLocked)
+                                               eDebugNoSimulate("[SEC] rotor locked step %d failed (oldSignal %d, curSignal %d)", cmd.okcount, signal, cmd.lastSignal);
+                                       else
+                                               eDebugNoSimulate("[SEC] rotor locked step %d failed (not locked)", cmd.okcount);
                                        cmd.okcount=0;
+                                       cmd.lastSignal=0;
                                }
                                ++m_sec_sequence.current();
                                break;
                        }
                        case eSecCommand::MEASURE_RUNNING_INPUTPOWER:
                                m_runningInputpower = sec_fe->readInputpower();
-                               eDebug("[SEC] runningInputpower is %d", m_runningInputpower);
+                               eDebugNoSimulate("[SEC] runningInputpower is %d", m_runningInputpower);
+                               ++m_sec_sequence.current();
+                               break;
+                       case eSecCommand::SET_ROTOR_MOVING:
+                               if (!m_simulate)
+                                       m_sec->setRotorMoving(m_slotid, true);
+                               ++m_sec_sequence.current();
+                               break;
+                       case eSecCommand::SET_ROTOR_STOPPED:
+                               if (!m_simulate)
+                                       m_sec->setRotorMoving(m_slotid, false);
                                ++m_sec_sequence.current();
                                break;
                        case eSecCommand::IF_INPUTPOWER_DELTA_GOTO:
                        {
-                               int idleInputpower = m_idleInputpower[ (sec_fe_data[CUR_VOLTAGE]&1) ? 0 : 1];
                                eSecCommand::rotor &cmd = m_sec_sequence.current()->measure;
+                               if (m_simulate)
+                               {
+                                       setSecSequencePos(cmd.steps);
+                                       break;
+                               }
+                               int idleInputpower = m_idleInputpower[ (sec_fe_data[CUR_VOLTAGE]&1) ? 0 : 1];
                                const char *txt = cmd.direction ? "running" : "stopped";
-                               eDebug("[SEC] waiting for rotor %s %d, idle %d, delta %d",
+                               --m_timeoutCount;
+                               if (!m_timeoutCount && m_retryCount > 0)
+                                       --m_retryCount;
+                               eDebugNoSimulate("[SEC] waiting for rotor %s %d, idle %d, delta %d",
                                        txt,
                                        m_runningInputpower,
                                        idleInputpower,
@@ -1537,21 +1777,17 @@ void eDVBFrontend::tuneLoop()  // called by m_tuneTimer
                                        || (!cmd.direction && abs(m_runningInputpower - idleInputpower) <= cmd.deltaA) )
                                {
                                        ++cmd.okcount;
-                                       eDebug("[SEC] rotor %s step %d ok", txt, cmd.okcount);
+                                       eDebugNoSimulate("[SEC] rotor %s step %d ok", txt, cmd.okcount);
                                        if ( cmd.okcount > 6 )
                                        {
-                                               m_sec->setRotorMoving(cmd.direction);
-                                               eDebug("[SEC] rotor is %s", txt);
+                                               eDebugNoSimulate("[SEC] rotor is %s", txt);
                                                if (setSecSequencePos(cmd.steps))
                                                        break;
                                        }
                                }
                                else
                                {
-                                       eDebug("[SEC] rotor not %s... reset counter.. increase timeout", txt);
-                                       --m_timeoutCount;
-                                       if (!m_timeoutCount && m_retryCount > 0)
-                                               --m_retryCount;
+                                       eDebugNoSimulate("[SEC] rotor not %s... reset counter.. increase timeout", txt);
                                        cmd.okcount=0;
                                }
                                ++m_sec_sequence.current();
@@ -1564,7 +1800,7 @@ void eDVBFrontend::tuneLoop()  // called by m_tuneTimer
                                        ++m_sec_sequence.current();
                                break;
                        case eSecCommand::INVALIDATE_CURRENT_SWITCHPARMS:
-                               eDebug("[SEC] invalidate current switch params");
+                               eDebugNoSimulate("[SEC] invalidate current switch params");
                                sec_fe_data[CSW] = -1;
                                sec_fe_data[UCSW] = -1;
                                sec_fe_data[TONEBURST] = -1;
@@ -1574,11 +1810,11 @@ void eDVBFrontend::tuneLoop()  // called by m_tuneTimer
                                sec_fe_data[CSW] = sec_fe_data[NEW_CSW];
                                sec_fe_data[UCSW] = sec_fe_data[NEW_UCSW];
                                sec_fe_data[TONEBURST] = sec_fe_data[NEW_TONEBURST];
-                               eDebug("[SEC] update current switch params");
+                               eDebugNoSimulate("[SEC] update current switch params");
                                ++m_sec_sequence.current();
                                break;
                        case eSecCommand::INVALIDATE_CURRENT_ROTORPARMS:
-                               eDebug("[SEC] invalidate current rotorparams");
+                               eDebugNoSimulate("[SEC] invalidate current rotorparams");
                                sec_fe_data[ROTOR_CMD] = -1;
                                sec_fe_data[ROTOR_POS] = -1;
                                ++m_sec_sequence.current();
@@ -1586,17 +1822,17 @@ void eDVBFrontend::tuneLoop()  // called by m_tuneTimer
                        case eSecCommand::UPDATE_CURRENT_ROTORPARAMS:
                                sec_fe_data[ROTOR_CMD] = sec_fe_data[NEW_ROTOR_CMD];
                                sec_fe_data[ROTOR_POS] = sec_fe_data[NEW_ROTOR_POS];
-                               eDebug("[SEC] update current rotorparams %d %04lx %ld", m_timeoutCount, sec_fe_data[ROTOR_CMD], sec_fe_data[ROTOR_POS]);
+                               eDebugNoSimulate("[SEC] update current rotorparams %d %04lx %ld", m_timeoutCount, sec_fe_data[ROTOR_CMD], sec_fe_data[ROTOR_POS]);
                                ++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);
+                               eDebugNoSimulate("[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");
+                                       eDebugNoSimulate("[SEC] no more rotor retrys");
                                        setSecSequencePos(m_sec_sequence.current()->steps);
                                }
                                else
@@ -1604,72 +1840,152 @@ void eDVBFrontend::tuneLoop()  // called by m_tuneTimer
                                break;
                        case eSecCommand::SET_POWER_LIMITING_MODE:
                        {
-                               char proc_name[64];
-                               sprintf(proc_name, "/proc/stb/frontend/%d/static_current_limiting", sec_fe->m_dvbid);
-                               FILE *f=fopen(proc_name, "w");
-                               if (f) // new interface exist?
-                               {
-                                       bool slimiting = m_sec_sequence.current()->mode == eSecCommand::modeStatic;
-                                       if (fprintf(f, "%s", slimiting ? "on" : "off") <= 0)
-                                               eDebug("write %s failed!! (%m)", proc_name);
-                                       else
-                                               eDebug("[SEC] set %s current limiting", slimiting ? "static" : "dynamic");
-                                       fclose(f);
-                               }
-                               else if (sec_fe->m_need_rotor_workaround)
+                               if (!m_simulate)
                                {
-                                       char dev[16];
-                                       int slotid = sec_fe->m_slotid;
-                                       // FIXMEEEEEE hardcoded i2c devices for dm7025 and dm8000
-                                       if (slotid < 2)
-                                               sprintf(dev, "/dev/i2c/%d", slotid);
-                                       else if (slotid == 2)
-                                               sprintf(dev, "/dev/i2c/2"); // first nim socket on DM8000 use /dev/i2c/2
-                                       else if (slotid == 3)
-                                               sprintf(dev, "/dev/i2c/4"); // second nim socket on DM8000 use /dev/i2c/4
-                                       int fd = ::open(dev, 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 )
+                                       char proc_name[64];
+                                       sprintf(proc_name, "/proc/stb/frontend/%d/static_current_limiting", sec_fe->m_dvbid);
+                                       FILE *f=fopen(proc_name, "w");
+                                       if (f) // new interface exist?
                                        {
-                                               data[0] |= 0x80;  // enable static current limiting
-                                               eDebug("[SEC] set static current limiting");
+                                               bool slimiting = m_sec_sequence.current()->mode == eSecCommand::modeStatic;
+                                               if (fprintf(f, "%s", slimiting ? "on" : "off") <= 0)
+                                                       eDebugNoSimulate("write %s failed!! (%m)", proc_name);
+                                               else
+                                                       eDebugNoSimulate("[SEC] set %s current limiting", slimiting ? "static" : "dynamic");
+                                               fclose(f);
                                        }
-                                       else
+                                       else if (sec_fe->m_need_rotor_workaround)
                                        {
-                                               data[0] &= ~0x80;  // enable dynamic current limiting
-                                               eDebug("[SEC] set dynamic current limiting");
+                                               char dev[16];
+                                               int slotid = sec_fe->m_slotid;
+                                               // FIXMEEEEEE hardcoded i2c devices for dm7025 and dm8000
+                                               if (slotid < 2)
+                                                       sprintf(dev, "/dev/i2c/%d", slotid);
+                                               else if (slotid == 2)
+                                                       sprintf(dev, "/dev/i2c/2"); // first nim socket on DM8000 use /dev/i2c/2
+                                               else if (slotid == 3)
+                                                       sprintf(dev, "/dev/i2c/4"); // second nim socket on DM8000 use /dev/i2c/4
+                                               int fd = ::open(dev, O_RDWR);
+
+                                               unsigned char data[2];
+                                               ::ioctl(fd, I2C_SLAVE_FORCE, 0x10 >> 1);
+                                               if(::read(fd, data, 1) != 1)
+                                                       eDebugNoSimulate("[SEC] error read lnbp (%m)");
+                                               if ( m_sec_sequence.current()->mode == eSecCommand::modeStatic )
+                                               {
+                                                       data[0] |= 0x80;  // enable static current limiting
+                                                       eDebugNoSimulate("[SEC] set static current limiting");
+                                               }
+                                               else
+                                               {
+                                                       data[0] &= ~0x80;  // enable dynamic current limiting
+                                                       eDebugNoSimulate("[SEC] set dynamic current limiting");
+                                               }
+                                               if(::write(fd, data, 1) != 1)
+                                                       eDebugNoSimulate("[SEC] error write lnbp (%m)");
+                                               ::close(fd);
                                        }
-                                       if(::write(fd, data, 1) != 1)
-                                               eDebug("[SEC] error write lnbp (%m)");
-                                       ::close(fd);
                                }
                                ++m_sec_sequence.current();
                                break;
                        }
+                       case eSecCommand::DELAYED_CLOSE_FRONTEND:
+                       {
+                               eDebugNoSimulate("[SEC] delayed close frontend");
+                               closeFrontend(false, true);
+                               ++m_sec_sequence.current();
+                               break;
+                       }
                        default:
-                               eDebug("[SEC] unhandled sec command %d",
+                               eDebugNoSimulate("[SEC] unhandled sec command %d",
                                        ++m_sec_sequence.current()->cmd);
                                ++m_sec_sequence.current();
                }
-               m_tuneTimer->start(delay,true);
+               if (!m_simulate)
+                       m_tuneTimer->start(delay,true);
        }
        if (regFE)
                regFE->dec_use();
+       if (m_simulate && m_sec_sequence.current() != m_sec_sequence.end())
+               tuneLoop();
+       return delay;
 }
 
-void eDVBFrontend::setFrontend()
+void eDVBFrontend::setFrontend(bool recvEvents)
 {
-       eDebug("setting frontend %d", m_dvbid);
-       m_sn->start();
-       feEvent(-1);
-       if (ioctl(m_fd, FE_SET_FRONTEND, &parm) == -1)
-       {
-               perror("FE_SET_FRONTEND failed");
-               return;
+       if (!m_simulate)
+       {
+               eDebug("setting frontend %d", m_dvbid);
+               if (recvEvents)
+                       m_sn->start();
+               feEvent(-1); // flush events
+#if HAVE_DVB_API_VERSION >= 5
+               if (m_type == iDVBFrontend::feSatellite)
+               {
+                       fe_rolloff_t rolloff = ROLLOFF_35;
+                       fe_pilot_t pilot = PILOT_OFF;
+                       fe_modulation_t modulation = QPSK;
+                       fe_delivery_system_t system = SYS_DVBS;
+                       switch(oparm.sat.system)
+                       {
+                       case eDVBFrontendParametersSatellite::System_DVB_S: system = SYS_DVBS; break;
+                       case eDVBFrontendParametersSatellite::System_DVB_S2: system = SYS_DVBS2; break;
+                       };
+                       switch(oparm.sat.modulation)
+                       {
+                       case eDVBFrontendParametersSatellite::Modulation_QPSK: modulation = QPSK; break;
+                       case eDVBFrontendParametersSatellite::Modulation_8PSK: modulation = PSK_8; break;
+                       case eDVBFrontendParametersSatellite::Modulation_QAM16: modulation = QAM_16; break;
+                       };
+                       switch(oparm.sat.pilot)
+                       {
+                       case eDVBFrontendParametersSatellite::Pilot_Off: pilot = PILOT_OFF; break;
+                       case eDVBFrontendParametersSatellite::Pilot_On: pilot = PILOT_ON; break;
+                       case eDVBFrontendParametersSatellite::Pilot_Unknown: pilot = PILOT_AUTO; break;
+                       };
+                       switch(oparm.sat.rolloff)
+                       {
+                       case eDVBFrontendParametersSatellite::RollOff_alpha_0_20: rolloff = ROLLOFF_20; break;
+                       case eDVBFrontendParametersSatellite::RollOff_alpha_0_25: rolloff = ROLLOFF_25; break;
+                       case eDVBFrontendParametersSatellite::RollOff_alpha_0_35: rolloff = ROLLOFF_35; break;
+                       };
+                       struct dtv_property p[10];
+                       struct dtv_properties cmdseq;
+                       cmdseq.props = p;
+                       p[0].cmd = DTV_CLEAR;
+                       p[1].cmd = DTV_DELIVERY_SYSTEM, p[1].u.data = system;
+                       p[2].cmd = DTV_FREQUENCY,       p[2].u.data = parm_frequency;
+                       p[3].cmd = DTV_MODULATION,      p[3].u.data = modulation;
+                       p[4].cmd = DTV_SYMBOL_RATE,     p[4].u.data = parm_u_qpsk_symbol_rate;
+                       p[5].cmd = DTV_INNER_FEC,       p[5].u.data = parm_u_qpsk_fec_inner;
+                       p[6].cmd = DTV_INVERSION,       p[6].u.data = parm_inversion;
+                       if (system == SYS_DVBS2)
+                       {
+                               p[7].cmd = DTV_ROLLOFF,         p[7].u.data = rolloff;
+                               p[8].cmd = DTV_PILOT,           p[8].u.data = pilot;
+                               p[9].cmd = DTV_TUNE;
+                               cmdseq.num = 10;
+                       }
+                       else
+                       {
+                               p[7].cmd = DTV_TUNE;
+                               cmdseq.num = 8;
+                       }
+                       if (ioctl(m_fd, FE_SET_PROPERTY, &cmdseq) == -1)
+                       {
+                               perror("FE_SET_PROPERTY failed");
+                               return;
+                       }
+               }
+               else
+#endif
+               {
+                       if (ioctl(m_fd, FE_SET_FRONTEND, &parm) == -1)
+                       {
+                               perror("FE_SET_FRONTEND failed");
+                               return;
+                       }
+               }
        }
 }
 
@@ -1692,7 +2008,21 @@ RESULT eDVBFrontend::prepare_sat(const eDVBFrontendParametersSatellite &feparm,
        res = m_sec->prepare(*this, parm, feparm, 1 << m_slotid, tunetimeout);
        if (!res)
        {
-               eDebug("prepare_sat System %d Freq %d Pol %d SR %d INV %d FEC %d orbpos %d",
+#if HAVE_DVB_API_VERSION >= 3
+               eDebugNoSimulate("prepare_sat System %d Freq %d Pol %d SR %d INV %d FEC %d orbpos %d system %d modulation %d pilot %d, rolloff %d",
+                       feparm.system,
+                       feparm.frequency,
+                       feparm.polarisation,
+                       feparm.symbol_rate,
+                       feparm.inversion,
+                       feparm.fec,
+                       feparm.orbital_position,
+                       feparm.system,
+                       feparm.modulation,
+                       feparm.pilot,
+                       feparm.rolloff);
+#else
+               eDebugNoSimulate("prepare_sat System %d Freq %d Pol %d SR %d INV %d FEC %d orbpos %d",
                        feparm.system,
                        feparm.frequency,
                        feparm.polarisation,
@@ -1700,99 +2030,106 @@ RESULT eDVBFrontend::prepare_sat(const eDVBFrontendParametersSatellite &feparm,
                        feparm.inversion,
                        feparm.fec,
                        feparm.orbital_position);
+#endif
                parm_u_qpsk_symbol_rate = feparm.symbol_rate;
                switch (feparm.inversion)
                {
-                       case eDVBFrontendParametersSatellite::Inversion::On:
+                       case eDVBFrontendParametersSatellite::Inversion_On:
                                parm_inversion = INVERSION_ON;
                                break;
-                       case eDVBFrontendParametersSatellite::Inversion::Off:
+                       case eDVBFrontendParametersSatellite::Inversion_Off:
                                parm_inversion = INVERSION_OFF;
                                break;
                        default:
-                       case eDVBFrontendParametersSatellite::Inversion::Unknown:
+                       case eDVBFrontendParametersSatellite::Inversion_Unknown:
                                parm_inversion = INVERSION_AUTO;
                                break;
                }
-               if (feparm.system == eDVBFrontendParametersSatellite::System::DVB_S)
+               if (feparm.system == eDVBFrontendParametersSatellite::System_DVB_S)
+               {
                        switch (feparm.fec)
                        {
-                               case eDVBFrontendParametersSatellite::FEC::fNone:
+                               case eDVBFrontendParametersSatellite::FEC_None:
                                        parm_u_qpsk_fec_inner = FEC_NONE;
                                        break;
-                               case eDVBFrontendParametersSatellite::FEC::f1_2:
+                               case eDVBFrontendParametersSatellite::FEC_1_2:
                                        parm_u_qpsk_fec_inner = FEC_1_2;
                                        break;
-                               case eDVBFrontendParametersSatellite::FEC::f2_3:
+                               case eDVBFrontendParametersSatellite::FEC_2_3:
                                        parm_u_qpsk_fec_inner = FEC_2_3;
                                        break;
-                               case eDVBFrontendParametersSatellite::FEC::f3_4:
+                               case eDVBFrontendParametersSatellite::FEC_3_4:
                                        parm_u_qpsk_fec_inner = FEC_3_4;
                                        break;
-                               case eDVBFrontendParametersSatellite::FEC::f5_6:
+                               case eDVBFrontendParametersSatellite::FEC_5_6:
                                        parm_u_qpsk_fec_inner = FEC_5_6;
                                        break;
-                               case eDVBFrontendParametersSatellite::FEC::f7_8:
+                               case eDVBFrontendParametersSatellite::FEC_7_8:
                                        parm_u_qpsk_fec_inner = FEC_7_8;
                                        break;
                                default:
-                                       eDebug("no valid fec for DVB-S set.. assume auto");
-                               case eDVBFrontendParametersSatellite::FEC::fAuto:
+                                       eDebugNoSimulate("no valid fec for DVB-S set.. assume auto");
+                               case eDVBFrontendParametersSatellite::FEC_Auto:
                                        parm_u_qpsk_fec_inner = FEC_AUTO;
                                        break;
                        }
+               }
 #if HAVE_DVB_API_VERSION >= 3
                else // DVB_S2
                {
                        switch (feparm.fec)
                        {
-                               case eDVBFrontendParametersSatellite::FEC::f1_2:
+                               case eDVBFrontendParametersSatellite::FEC_1_2:
                                        parm_u_qpsk_fec_inner = FEC_S2_QPSK_1_2;
                                        break;
-                               case eDVBFrontendParametersSatellite::FEC::f2_3:
+                               case eDVBFrontendParametersSatellite::FEC_2_3:
                                        parm_u_qpsk_fec_inner = FEC_S2_QPSK_2_3;
                                        break;
-                               case eDVBFrontendParametersSatellite::FEC::f3_4:
+                               case eDVBFrontendParametersSatellite::FEC_3_4:
                                        parm_u_qpsk_fec_inner = FEC_S2_QPSK_3_4;
                                        break;
-                               case eDVBFrontendParametersSatellite::FEC::f3_5:
+                               case eDVBFrontendParametersSatellite::FEC_3_5:
                                        parm_u_qpsk_fec_inner = FEC_S2_QPSK_3_5;
                                        break;
-                               case eDVBFrontendParametersSatellite::FEC::f4_5:
+                               case eDVBFrontendParametersSatellite::FEC_4_5:
                                        parm_u_qpsk_fec_inner = FEC_S2_QPSK_4_5;
                                        break;
-                               case eDVBFrontendParametersSatellite::FEC::f5_6:
+                               case eDVBFrontendParametersSatellite::FEC_5_6:
                                        parm_u_qpsk_fec_inner = FEC_S2_QPSK_5_6;
                                        break;
-                               case eDVBFrontendParametersSatellite::FEC::f7_8:
+                               case eDVBFrontendParametersSatellite::FEC_7_8:
                                        parm_u_qpsk_fec_inner = FEC_S2_QPSK_7_8;
                                        break;
-                               case eDVBFrontendParametersSatellite::FEC::f8_9:
+                               case eDVBFrontendParametersSatellite::FEC_8_9:
                                        parm_u_qpsk_fec_inner = FEC_S2_QPSK_8_9;
                                        break;
-                               case eDVBFrontendParametersSatellite::FEC::f9_10:
+                               case eDVBFrontendParametersSatellite::FEC_9_10:
                                        parm_u_qpsk_fec_inner = FEC_S2_QPSK_9_10;
                                        break;
                                default:
-                                       eDebug("no valid fec for DVB-S2 set.. abort !!");
+                                       eDebugNoSimulate("no valid fec for DVB-S2 set.. abort !!");
                                        return -EINVAL;
                        }
+#if HAVE_DVB_API_VERSION < 5
                        parm_inversion |= (feparm.rolloff << 2); // Hack.. we use bit 2..3 of inversion param for rolloff
-                       if (feparm.modulation == eDVBFrontendParametersSatellite::Modulation::M8PSK) {
+                       parm_inversion |= (feparm.pilot << 4); // Hack.. we use bit 4..5 of inversion param for pilot
+                       if (feparm.modulation == eDVBFrontendParametersSatellite::Modulation_8PSK) 
+                       {
                                parm_u_qpsk_fec_inner = (fe_code_rate_t)((int)parm_u_qpsk_fec_inner+9);
                                // 8PSK fec driver values are decimal 9 bigger
-                               parm_inversion |= (feparm.pilot << 4); // Hack.. we use bit 4..5 of inversion param for pilot
                        }
+#endif
                }
 #endif
                // FIXME !!! get frequency range from tuner
                if ( parm_frequency < 900000 || parm_frequency > 2200000 )
                {
-                       eDebug("%d mhz out of tuner range.. dont tune", parm_frequency/1000);
+                       eDebugNoSimulate("%d mhz out of tuner range.. dont tune", parm_frequency/1000);
                        return -EINVAL;
                }
-               eDebug("tuning to %d mhz", parm_frequency/1000);
+               eDebugNoSimulate("tuning to %d mhz", parm_frequency/1000);
        }
+       oparm.sat = feparm;
        return res;
 }
 
@@ -1806,75 +2143,76 @@ RESULT eDVBFrontend::prepare_cable(const eDVBFrontendParametersCable &feparm)
        parm_u_qam_symbol_rate = feparm.symbol_rate;
        switch (feparm.modulation)
        {
-       case eDVBFrontendParametersCable::Modulation::QAM16:
+       case eDVBFrontendParametersCable::Modulation_QAM16:
                parm_u_qam_modulation = QAM_16;
                break;
-       case eDVBFrontendParametersCable::Modulation::QAM32:
+       case eDVBFrontendParametersCable::Modulation_QAM32:
                parm_u_qam_modulation = QAM_32;
                break;
-       case eDVBFrontendParametersCable::Modulation::QAM64:
+       case eDVBFrontendParametersCable::Modulation_QAM64:
                parm_u_qam_modulation = QAM_64;
                break;
-       case eDVBFrontendParametersCable::Modulation::QAM128:
+       case eDVBFrontendParametersCable::Modulation_QAM128:
                parm_u_qam_modulation = QAM_128;
                break;
-       case eDVBFrontendParametersCable::Modulation::QAM256:
+       case eDVBFrontendParametersCable::Modulation_QAM256:
                parm_u_qam_modulation = QAM_256;
                break;
        default:
-       case eDVBFrontendParametersCable::Modulation::Auto:
+       case eDVBFrontendParametersCable::Modulation_Auto:
                parm_u_qam_modulation = QAM_AUTO;
                break;
        }
        switch (feparm.inversion)
        {
-       case eDVBFrontendParametersCable::Inversion::On:
+       case eDVBFrontendParametersCable::Inversion_On:
                parm_inversion = INVERSION_ON;
                break;
-       case eDVBFrontendParametersCable::Inversion::Off:
+       case eDVBFrontendParametersCable::Inversion_Off:
                parm_inversion = INVERSION_OFF;
                break;
        default:
-       case eDVBFrontendParametersCable::Inversion::Unknown:
+       case eDVBFrontendParametersCable::Inversion_Unknown:
                parm_inversion = INVERSION_AUTO;
                break;
        }
        switch (feparm.fec_inner)
        {
-       case eDVBFrontendParametersCable::FEC::fNone:
+       case eDVBFrontendParametersCable::FEC_None:
                parm_u_qam_fec_inner = FEC_NONE;
                break;
-       case eDVBFrontendParametersCable::FEC::f1_2:
+       case eDVBFrontendParametersCable::FEC_1_2:
                parm_u_qam_fec_inner = FEC_1_2;
                break;
-       case eDVBFrontendParametersCable::FEC::f2_3:
+       case eDVBFrontendParametersCable::FEC_2_3:
                parm_u_qam_fec_inner = FEC_2_3;
                break;
-       case eDVBFrontendParametersCable::FEC::f3_4:
+       case eDVBFrontendParametersCable::FEC_3_4:
                parm_u_qam_fec_inner = FEC_3_4;
                break;
-       case eDVBFrontendParametersCable::FEC::f5_6:
+       case eDVBFrontendParametersCable::FEC_5_6:
                parm_u_qam_fec_inner = FEC_5_6;
                break;
-       case eDVBFrontendParametersCable::FEC::f7_8:
+       case eDVBFrontendParametersCable::FEC_7_8:
                parm_u_qam_fec_inner = FEC_7_8;
                break;
 #if HAVE_DVB_API_VERSION >= 3
-       case eDVBFrontendParametersCable::FEC::f8_9:
+       case eDVBFrontendParametersCable::FEC_8_9:
                parm_u_qam_fec_inner = FEC_8_9;
                break;
 #endif
        default:
-       case eDVBFrontendParametersCable::FEC::fAuto:
+       case eDVBFrontendParametersCable::FEC_Auto:
                parm_u_qam_fec_inner = FEC_AUTO;
                break;
        }
-       eDebug("tuning to %d khz, sr %d, fec %d, modulation %d, inversion %d",
+       eDebugNoSimulate("tuning to %d khz, sr %d, fec %d, modulation %d, inversion %d",
                parm_frequency/1000,
                parm_u_qam_symbol_rate,
                parm_u_qam_fec_inner,
                parm_u_qam_modulation,
                parm_inversion);
+       oparm.cab = feparm;
        return 0;
 }
 
@@ -1884,157 +2222,158 @@ RESULT eDVBFrontend::prepare_terrestrial(const eDVBFrontendParametersTerrestrial
 
        switch (feparm.bandwidth)
        {
-       case eDVBFrontendParametersTerrestrial::Bandwidth::Bw8MHz:
+       case eDVBFrontendParametersTerrestrial::Bandwidth_8MHz:
                parm_u_ofdm_bandwidth = BANDWIDTH_8_MHZ;
                break;
-       case eDVBFrontendParametersTerrestrial::Bandwidth::Bw7MHz:
+       case eDVBFrontendParametersTerrestrial::Bandwidth_7MHz:
                parm_u_ofdm_bandwidth = BANDWIDTH_7_MHZ;
                break;
-       case eDVBFrontendParametersTerrestrial::Bandwidth::Bw6MHz:
+       case eDVBFrontendParametersTerrestrial::Bandwidth_6MHz:
                parm_u_ofdm_bandwidth = BANDWIDTH_6_MHZ;
                break;
        default:
-       case eDVBFrontendParametersTerrestrial::Bandwidth::BwAuto:
+       case eDVBFrontendParametersTerrestrial::Bandwidth_Auto:
                parm_u_ofdm_bandwidth = BANDWIDTH_AUTO;
                break;
        }
        switch (feparm.code_rate_LP)
        {
-       case eDVBFrontendParametersTerrestrial::FEC::f1_2:
+       case eDVBFrontendParametersTerrestrial::FEC_1_2:
                parm_u_ofdm_code_rate_LP = FEC_1_2;
                break;
-       case eDVBFrontendParametersTerrestrial::FEC::f2_3:
+       case eDVBFrontendParametersTerrestrial::FEC_2_3:
                parm_u_ofdm_code_rate_LP = FEC_2_3;
                break;
-       case eDVBFrontendParametersTerrestrial::FEC::f3_4:
+       case eDVBFrontendParametersTerrestrial::FEC_3_4:
                parm_u_ofdm_code_rate_LP = FEC_3_4;
                break;
-       case eDVBFrontendParametersTerrestrial::FEC::f5_6:
+       case eDVBFrontendParametersTerrestrial::FEC_5_6:
                parm_u_ofdm_code_rate_LP = FEC_5_6;
                break;
-       case eDVBFrontendParametersTerrestrial::FEC::f7_8:
+       case eDVBFrontendParametersTerrestrial::FEC_7_8:
                parm_u_ofdm_code_rate_LP = FEC_7_8;
                break;
        default:
-       case eDVBFrontendParametersTerrestrial::FEC::fAuto:
+       case eDVBFrontendParametersTerrestrial::FEC_Auto:
                parm_u_ofdm_code_rate_LP = FEC_AUTO;
                break;
        }
        switch (feparm.code_rate_HP)
        {
-       case eDVBFrontendParametersTerrestrial::FEC::f1_2:
+       case eDVBFrontendParametersTerrestrial::FEC_1_2:
                parm_u_ofdm_code_rate_HP = FEC_1_2;
                break;
-       case eDVBFrontendParametersTerrestrial::FEC::f2_3:
+       case eDVBFrontendParametersTerrestrial::FEC_2_3:
                parm_u_ofdm_code_rate_HP = FEC_2_3;
                break;
-       case eDVBFrontendParametersTerrestrial::FEC::f3_4:
+       case eDVBFrontendParametersTerrestrial::FEC_3_4:
                parm_u_ofdm_code_rate_HP = FEC_3_4;
                break;
-       case eDVBFrontendParametersTerrestrial::FEC::f5_6:
+       case eDVBFrontendParametersTerrestrial::FEC_5_6:
                parm_u_ofdm_code_rate_HP = FEC_5_6;
                break;
-       case eDVBFrontendParametersTerrestrial::FEC::f7_8:
+       case eDVBFrontendParametersTerrestrial::FEC_7_8:
                parm_u_ofdm_code_rate_HP = FEC_7_8;
                break;
        default:
-       case eDVBFrontendParametersTerrestrial::FEC::fAuto:
+       case eDVBFrontendParametersTerrestrial::FEC_Auto:
                parm_u_ofdm_code_rate_HP = FEC_AUTO;
                break;
        }
        switch (feparm.modulation)
        {
-       case eDVBFrontendParametersTerrestrial::Modulation::QPSK:
+       case eDVBFrontendParametersTerrestrial::Modulation_QPSK:
                parm_u_ofdm_constellation = QPSK;
                break;
-       case eDVBFrontendParametersTerrestrial::Modulation::QAM16:
+       case eDVBFrontendParametersTerrestrial::Modulation_QAM16:
                parm_u_ofdm_constellation = QAM_16;
                break;
-       case eDVBFrontendParametersTerrestrial::Modulation::QAM64:
+       case eDVBFrontendParametersTerrestrial::Modulation_QAM64:
                parm_u_ofdm_constellation = QAM_64;
                break;
        default:
-       case eDVBFrontendParametersTerrestrial::Modulation::Auto:
+       case eDVBFrontendParametersTerrestrial::Modulation_Auto:
                parm_u_ofdm_constellation = QAM_AUTO;
                break;
        }
        switch (feparm.transmission_mode)
        {
-       case eDVBFrontendParametersTerrestrial::TransmissionMode::TM2k:
+       case eDVBFrontendParametersTerrestrial::TransmissionMode_2k:
                parm_u_ofdm_transmission_mode = TRANSMISSION_MODE_2K;
                break;
-       case eDVBFrontendParametersTerrestrial::TransmissionMode::TM8k:
+       case eDVBFrontendParametersTerrestrial::TransmissionMode_8k:
                parm_u_ofdm_transmission_mode = TRANSMISSION_MODE_8K;
                break;
        default:
-       case eDVBFrontendParametersTerrestrial::TransmissionMode::TMAuto:
+       case eDVBFrontendParametersTerrestrial::TransmissionMode_Auto:
                parm_u_ofdm_transmission_mode = TRANSMISSION_MODE_AUTO;
                break;
        }
        switch (feparm.guard_interval)
        {
-               case eDVBFrontendParametersTerrestrial::GuardInterval::GI_1_32:
+               case eDVBFrontendParametersTerrestrial::GuardInterval_1_32:
                        parm_u_ofdm_guard_interval = GUARD_INTERVAL_1_32;
                        break;
-               case eDVBFrontendParametersTerrestrial::GuardInterval::GI_1_16:
+               case eDVBFrontendParametersTerrestrial::GuardInterval_1_16:
                        parm_u_ofdm_guard_interval = GUARD_INTERVAL_1_16;
                        break;
-               case eDVBFrontendParametersTerrestrial::GuardInterval::GI_1_8:
+               case eDVBFrontendParametersTerrestrial::GuardInterval_1_8:
                        parm_u_ofdm_guard_interval = GUARD_INTERVAL_1_8;
                        break;
-               case eDVBFrontendParametersTerrestrial::GuardInterval::GI_1_4:
+               case eDVBFrontendParametersTerrestrial::GuardInterval_1_4:
                        parm_u_ofdm_guard_interval = GUARD_INTERVAL_1_4;
                        break;
                default:
-               case eDVBFrontendParametersTerrestrial::GuardInterval::GI_Auto:
+               case eDVBFrontendParametersTerrestrial::GuardInterval_Auto:
                        parm_u_ofdm_guard_interval = GUARD_INTERVAL_AUTO;
                        break;
        }
        switch (feparm.hierarchy)
        {
-               case eDVBFrontendParametersTerrestrial::Hierarchy::HNone:
+               case eDVBFrontendParametersTerrestrial::Hierarchy_None:
                        parm_u_ofdm_hierarchy_information = HIERARCHY_NONE;
                        break;
-               case eDVBFrontendParametersTerrestrial::Hierarchy::H1:
+               case eDVBFrontendParametersTerrestrial::Hierarchy_1:
                        parm_u_ofdm_hierarchy_information = HIERARCHY_1;
                        break;
-               case eDVBFrontendParametersTerrestrial::Hierarchy::H2:
+               case eDVBFrontendParametersTerrestrial::Hierarchy_2:
                        parm_u_ofdm_hierarchy_information = HIERARCHY_2;
                        break;
-               case eDVBFrontendParametersTerrestrial::Hierarchy::H4:
+               case eDVBFrontendParametersTerrestrial::Hierarchy_4:
                        parm_u_ofdm_hierarchy_information = HIERARCHY_4;
                        break;
                default:
-               case eDVBFrontendParametersTerrestrial::Hierarchy::HAuto:
+               case eDVBFrontendParametersTerrestrial::Hierarchy_Auto:
                        parm_u_ofdm_hierarchy_information = HIERARCHY_AUTO;
                        break;
        }
        switch (feparm.inversion)
        {
-       case eDVBFrontendParametersTerrestrial::Inversion::On:
+       case eDVBFrontendParametersTerrestrial::Inversion_On:
                parm_inversion = INVERSION_ON;
                break;
-       case eDVBFrontendParametersTerrestrial::Inversion::Off:
+       case eDVBFrontendParametersTerrestrial::Inversion_Off:
                parm_inversion = INVERSION_OFF;
                break;
        default:
-       case eDVBFrontendParametersTerrestrial::Inversion::Unknown:
+       case eDVBFrontendParametersTerrestrial::Inversion_Unknown:
                parm_inversion = INVERSION_AUTO;
                break;
        }
+       oparm.ter = feparm;
        return 0;
 }
 
 RESULT eDVBFrontend::tune(const iDVBFrontendParameters &where)
 {
        unsigned int timeout = 5000;
-       eDebug("(%d)tune", m_dvbid);
+       eDebugNoSimulate("(%d)tune", m_dvbid);
 
        m_timeout->stop();
 
        int res=0;
 
-       if (!m_sn)
+       if (!m_sn && !m_simulate)
        {
                eDebug("no frontend device opened... do not try to tune !!!");
                res = -ENODEV;
@@ -2047,7 +2386,9 @@ RESULT eDVBFrontend::tune(const iDVBFrontendParameters &where)
                goto tune_error;
        }
 
-       m_sn->stop();
+       if (!m_simulate)
+               m_sn->stop();
+
        m_sec_sequence.clear();
 
        where.calcLockTimeout(timeout);
@@ -2063,7 +2404,22 @@ RESULT eDVBFrontend::tune(const iDVBFrontendParameters &where)
                        res = -EINVAL;
                        goto tune_error;
                }
-               m_sec->setRotorMoving(false);
+               if (m_rotor_mode != feparm.no_rotor_command_on_tune && !feparm.no_rotor_command_on_tune)
+               {
+                       eDVBFrontend *sec_fe = this;
+                       long tmp = m_data[LINKED_PREV_PTR];
+                       while (tmp != -1)
+                       {
+                               eDVBRegisteredFrontend *linked_fe = (eDVBRegisteredFrontend*)tmp;
+                               sec_fe = linked_fe->m_frontend;
+                               sec_fe->getData(LINKED_NEXT_PTR, tmp);
+                       }
+                       eDebug("(fe%d) reset diseqc after leave rotor mode!", m_dvbid);
+                       sec_fe->m_data[CSW] = sec_fe->m_data[UCSW] = sec_fe->m_data[TONEBURST] = sec_fe->m_data[ROTOR_CMD] = sec_fe->m_data[ROTOR_POS] = -1; // reset diseqc
+               }
+               m_rotor_mode = feparm.no_rotor_command_on_tune;
+               if (!m_simulate)
+                       m_sec->setRotorMoving(m_slotid, false);
                res=prepare_sat(feparm, timeout);
                if (res)
                        goto tune_error;
@@ -2083,7 +2439,7 @@ RESULT eDVBFrontend::tune(const iDVBFrontendParameters &where)
                        goto tune_error;
 
                m_sec_sequence.push_back( eSecCommand(eSecCommand::START_TUNE_TIMEOUT, timeout) );
-               m_sec_sequence.push_back( eSecCommand(eSecCommand::SET_FRONTEND) );
+               m_sec_sequence.push_back( eSecCommand(eSecCommand::SET_FRONTEND, 1) );
                break;
        }
        case feTerrestrial:
@@ -2108,21 +2464,26 @@ RESULT eDVBFrontend::tune(const iDVBFrontendParameters &where)
                        m_sec_sequence.push_back( eSecCommand(eSecCommand::SET_VOLTAGE, iDVBFrontend::voltage13) );
                else
                        m_sec_sequence.push_back( eSecCommand(eSecCommand::SET_VOLTAGE, iDVBFrontend::voltageOff) );
-               m_sec_sequence.push_back( eSecCommand(eSecCommand::SET_FRONTEND) );
+               m_sec_sequence.push_back( eSecCommand(eSecCommand::SET_FRONTEND, 1) );
 
                break;
        }
        }
 
-       m_tuneTimer->start(0,true);
        m_sec_sequence.current() = m_sec_sequence.begin();
 
-       if (m_state != stateTuning)
+       if (!m_simulate)
        {
+               m_tuneTimer->start(0,true);
                m_tuning = 1;
-               m_state = stateTuning;
-               m_stateChanged(this);
+               if (m_state != stateTuning)
+               {
+                       m_state = stateTuning;
+                       m_stateChanged(this);
+               }
        }
+       else
+               tuneLoop();
 
        return res;
 
@@ -2177,6 +2538,8 @@ RESULT eDVBFrontend::setVoltage(int voltage)
        default:
                return -ENODEV;
        }
+       if (m_simulate)
+               return 0;
 #if HAVE_DVB_API_VERSION < 3
        return ::ioctl(m_secfd, SEC_SET_VOLTAGE, vlt);
 #else
@@ -2213,6 +2576,8 @@ RESULT eDVBFrontend::setTone(int t)
        default:
                return -ENODEV;
        }
+       if (m_simulate)
+               return 0;
 #if HAVE_DVB_API_VERSION < 3   
        return ::ioctl(m_secfd, SEC_SET_TONE, tone);
 #else  
@@ -2226,6 +2591,8 @@ RESULT eDVBFrontend::setTone(int t)
 
 RESULT eDVBFrontend::sendDiseqc(const eDVBDiseqcCommand &diseqc)
 {
+       if (m_simulate)
+               return 0;
 #if HAVE_DVB_API_VERSION < 3
        struct secCommand cmd;
        cmd.type = SEC_CMDTYPE_DISEQC_RAW;
@@ -2250,6 +2617,8 @@ RESULT eDVBFrontend::sendDiseqc(const eDVBDiseqcCommand &diseqc)
 #endif
 RESULT eDVBFrontend::sendToneburst(int burst)
 {
+       if (m_simulate)
+               return 0;
 #if HAVE_DVB_API_VERSION < 3
        secMiniCmd cmd = SEC_MINI_NONE;
 #else
@@ -2275,9 +2644,12 @@ RESULT eDVBFrontend::setSEC(iDVBSatelliteEquipmentControl *sec)
        return 0;
 }
 
-RESULT eDVBFrontend::setSecSequence(const eSecCommandList &list)
+RESULT eDVBFrontend::setSecSequence(eSecCommandList &list)
 {
-       m_sec_sequence = list;
+       if (m_data[SATCR] != -1 && m_sec_sequence.current() != m_sec_sequence.end())
+               m_sec_sequence.push_back(list);
+       else
+               m_sec_sequence = list;
        return 0;
 }
 
@@ -2312,10 +2684,10 @@ int eDVBFrontend::isCompatibleWith(ePtr<iDVBFrontendParameters> &feparm)
                eDVBFrontendParametersSatellite sat_parm;
                int ret = feparm->getDVBS(sat_parm);
                ASSERT(!ret);
-               if (sat_parm.system == eDVBFrontendParametersSatellite::System::DVB_S2 && !m_can_handle_dvbs2)
+               if (sat_parm.system == eDVBFrontendParametersSatellite::System_DVB_S2 && !m_can_handle_dvbs2)
                        return 0;
                ret = m_sec->canTune(sat_parm, this, 1 << m_slotid);
-               if (ret > 1 && sat_parm.system == eDVBFrontendParametersSatellite::System::DVB_S && m_can_handle_dvbs2)
+               if (ret > 1 && sat_parm.system == eDVBFrontendParametersSatellite::System_DVB_S && m_can_handle_dvbs2)
                        ret -= 1;
                return ret;
        }
@@ -2328,13 +2700,14 @@ int eDVBFrontend::isCompatibleWith(ePtr<iDVBFrontendParameters> &feparm)
 
 bool eDVBFrontend::setSlotInfo(ePyObject obj)
 {
-       ePyObject Id, Descr, Enabled;
-       if (!PyTuple_Check(obj) || PyTuple_Size(obj) != 3)
+       ePyObject Id, Descr, Enabled, IsDVBS2;
+       if (!PyTuple_Check(obj) || PyTuple_Size(obj) != 4)
                goto arg_error;
        Id = PyTuple_GET_ITEM(obj, 0);
        Descr = PyTuple_GET_ITEM(obj, 1);
        Enabled = PyTuple_GET_ITEM(obj, 2);
-       if (!PyInt_Check(Id) || !PyString_Check(Descr) || !PyBool_Check(Enabled))
+       IsDVBS2 = PyTuple_GET_ITEM(obj, 3);
+       if (!PyInt_Check(Id) || !PyString_Check(Descr) || !PyBool_Check(Enabled) || !PyBool_Check(IsDVBS2))
                goto arg_error;
        strcpy(m_description, PyString_AS_STRING(Descr));
        m_slotid = PyInt_AsLong(Id);
@@ -2344,8 +2717,8 @@ bool eDVBFrontend::setSlotInfo(ePyObject obj)
                !!strstr(m_description, "Alps BSBE2") ||
                !!strstr(m_description, "Alps -S") ||
                !!strstr(m_description, "BCM4501");
-       m_can_handle_dvbs2 = !!strstr(m_description, "Alps BSBE2") || !!strstr(m_description, "BCM4501");
-       eDebug("setSlotInfo for dvb frontend %d to slotid %d, descr %s, need rotorworkaround %s, enabled %s, DVB-S2 %s",
+       m_can_handle_dvbs2 = IsDVBS2 == Py_True;
+       eDebugNoSimulate("setSlotInfo for dvb frontend %d to slotid %d, descr %s, need rotorworkaround %s, enabled %s, DVB-S2 %s",
                m_dvbid, m_slotid, m_description, m_need_rotor_workaround ? "Yes" : "No", m_enabled ? "Yes" : "No", m_can_handle_dvbs2 ? "Yes" : "No" );
        return true;
 arg_error: