/// <summary>
        /// Sends the diseq command.
        /// </summary>
        /// <param name="channel">The channel.</param>
        /// <param name="parameters">The scanparameters.</param>
        public void SendDiseqCommand(ScanParameters parameters, DVBSChannel channel)
        {
            if (m_bIsTeVii == false)
            {
                return;
            }
            Log.Log.Debug("TeVii: SendDiseqc: {0},{1}", parameters.ToString(), channel.ToString());

            //bit 0	(1)	: 0=low band, 1 = hi band
            //bit 1 (2) : 0=vertical, 1 = horizontal
            //bit 3 (4) : 0=satellite position A, 1=satellite position B
            //bit 4 (8) : 0=switch option A, 1=switch option  B
            // LNB    option  position
            // 1        A         A
            // 2        A         B
            // 3        B         A
            // 4        B         B
            int  antennaNr    = BandTypeConverter.GetAntennaNr(channel);
            bool hiBand       = BandTypeConverter.IsHiBand(channel, parameters);
            bool isHorizontal = ((channel.Polarisation == Polarisation.LinearH) ||
                                 (channel.Polarisation == Polarisation.CircularL));
            byte cmd = 0xf0;

            cmd |= (byte)(hiBand ? 1 : 0);
            cmd |= (byte)((isHorizontal) ? 2 : 0);
            cmd |= (byte)((antennaNr - 1) << 2);

            byte[] ucMessage = new byte[4];
            ucMessage[0] = 0xE0; //framing byte
            ucMessage[1] = 0x10; //address byte
            ucMessage[2] = 0x38; //command byte
            ucMessage[3] = cmd;  //data byte (port group 0)
            //byte[] ucMessage = DiSEqC_Helper.ChannelToDiSEqC(parameters, channel);
            SendDiSEqCCommand(ucMessage);
        }
        /// <summary>
        /// Sends the diseq command.
        /// </summary>
        /// <param name="channel">The channel.</param>
        /// <param name="parameters">The channels scanning parameters.</param>
        public void SendDiseqCommand(ScanParameters parameters, DVBSChannel channel)
        {
            if (_isGenPix == false)
            {
                return;
            }
            Log.Log.Debug("SendDiseqc: {0},{1}", parameters.ToString(), channel.ToString());

            //bit 0	(1)	: 0=low band, 1 = hi band
            //bit 1 (2) : 0=vertical, 1 = horizontal
            //bit 3 (4) : 0=satellite position A, 1=satellite position B
            //bit 4 (8) : 0=switch option A, 1=switch option  B
            // LNB    option  position
            // 1        A         A
            // 2        A         B
            // 3        B         A
            // 4        B         B
            int  antennaNr    = BandTypeConverter.GetAntennaNr(channel);
            bool hiBand       = BandTypeConverter.IsHiBand(channel, parameters);
            bool isHorizontal = ((channel.Polarisation == Polarisation.LinearH) ||
                                 (channel.Polarisation == Polarisation.CircularL));
            byte cmd = 0xf0;

            cmd |= (byte)(hiBand ? 1 : 0);
            cmd |= (byte)((isHorizontal) ? 2 : 0);
            cmd |= (byte)((antennaNr - 1) << 2);

            DISEQC_COMMAND DiseqcCommand = new DISEQC_COMMAND();

            DiseqcCommand.ucMessage[0]    = 0xE0; //framing byte
            DiseqcCommand.ucMessage[1]    = 0x10; //address byte
            DiseqcCommand.ucMessage[2]    = 0x38; //command byte
            DiseqcCommand.ucMessage[3]    = cmd;  //data byte (port group 0)
            DiseqcCommand.ucMessage[4]    = 0;    //Need not fill this up
            DiseqcCommand.ucMessage[5]    = 0;    //Need not fill this up
            DiseqcCommand.ucMessageLength = 4;    //Number of Valid bytes in the Command.

            Marshal.StructureToPtr(DiseqcCommand, _ptrDiseqc, false);
            //get the length of the structure command - usually 7 bytes.
            int len = Marshal.SizeOf(DiseqcCommand);

            string txt = "";

            for (int i = 0; i < len; ++i)
            {
                txt += String.Format("0x{0:X} ", Marshal.ReadByte(_ptrDiseqc, i));
            }
            Log.Log.Debug("GenPix: SendDiseqCommand: {0} with length {1}", txt, len);
            //set the DisEqC command to the tuner pin
            int hr = _propertySet.Set(BdaTunerExtentionProperties, (int)BdaTunerExtension.KSPROPERTY_BDA_DISEQC,
                                      _ptrTempInstance, 32, _ptrDiseqc, len);

            if (hr != 0)
            {
                Log.Log.Info("GenPix: SendDiseqCommand returned: 0x{0:X} - {1}{2}", hr, HResult.GetDXErrorString(hr),
                             DsError.GetErrorText(hr));
            }
        }
Example #3
0
        /// <summary>
        /// Sends the diseq command.
        /// </summary>
        /// <param name="parameters">Scan parameters</param>
        /// <param name="channel">The channel.</param>
        public void SendDiseqCommand(ScanParameters parameters, DVBSChannel channel)
        {
            byte  disEqcPort = (byte)BandTypeConverter.GetAntennaNr(channel);
            Int32 LNBLOFLowBand;
            Int32 LNBLOFHighBand;
            Int32 LNBLOFHiLoSW;

            BandTypeConverter.GetDefaultLnbSetup(parameters, channel.BandType, out LNBLOFLowBand, out LNBLOFHighBand,
                                                 out LNBLOFHiLoSW);
            byte turnon22Khz = BandTypeConverter.IsHiBand(channel, parameters) ? (byte)2 : (byte)1;

            SetLnbData(true, LNBLOFLowBand, LNBLOFHighBand, LNBLOFHiLoSW, turnon22Khz, disEqcPort);
            SendDiseqcCommandTest(parameters, channel);
        }
Example #4
0
        ///<summary>
        /// Send DiseqC Command test
        ///</summary>
        ///<param name="parameters">Scan parameters</param>
        ///<param name="channel">Channel</param>
        public void SendDiseqcCommandTest(ScanParameters parameters, DVBSChannel channel)
        {
            int  antennaNr    = BandTypeConverter.GetAntennaNr(channel);
            bool hiBand       = BandTypeConverter.IsHiBand(channel, parameters);
            bool isHorizontal = ((channel.Polarisation == Polarisation.LinearH) ||
                                 (channel.Polarisation == Polarisation.CircularL));
            byte cmd = 0xf0;

            cmd |= (byte)(hiBand ? 1 : 0);
            cmd |= (byte)((isHorizontal) ? 2 : 0);
            cmd |= (byte)((antennaNr - 1) << 2);
            byte[] diseqc = new byte[4];
            diseqc[0] = 0xe0;
            diseqc[1] = 0x10;
            diseqc[2] = 0x38;
            diseqc[3] = cmd;
            SendDiSEqCCommand(diseqc);
        }
Example #5
0
        /// <summary>
        /// Sends the diseq command.
        /// </summary>
        /// <param name="channel">The channel.</param>
        /// <param name="parameters">The scanparameters.</param>
        public bool SendDiseqCommand(ScanParameters parameters, DVBSChannel channel)
        {
            bool succeeded = true;

            if (_isHauppauge == false)
            {
                return(true);
            }
            int antennaNr = BandTypeConverter.GetAntennaNr(channel);

            if (antennaNr == 0)
            {
                return(true);
            }
            //clear the message params before writing in order to avoid corruption of the diseqc message.
            for (int i = 0; i < 188; ++i)
            {
                Marshal.WriteByte(_ptrDiseqc, i, 0x00);
            }
            bool hiBand = BandTypeConverter.IsHiBand(channel, parameters);
            //bit 0	(1)	: 0=low band, 1 = hi band
            //bit 1 (2) : 0=vertical, 1 = horizontal
            //bit 3 (4) : 0=satellite position A, 1=satellite position B
            //bit 4 (8) : 0=switch option A, 1=switch option  B
            // LNB    option  position
            // 1        A         A
            // 2        A         B
            // 3        B         A
            // 4        B         B
            bool isHorizontal = ((channel.Polarisation == Polarisation.LinearH) ||
                                 (channel.Polarisation == Polarisation.CircularL));
            byte cmd = 0xf0;

            cmd |= (byte)(hiBand ? 1 : 0);
            cmd |= (byte)((isHorizontal) ? 2 : 0);
            cmd |= (byte)((antennaNr - 1) << 2);

            const int len    = 188;        //hauppauge diseqc message length
            ulong     diseqc = 0xE0103800; //currently committed switches only. i.e. ports 1-4

            diseqc += cmd;

            Marshal.WriteByte(_ptrDiseqc, 0, (byte)((diseqc >> 24) & 0xff)); //framing byte
            Marshal.WriteByte(_ptrDiseqc, 1, (byte)((diseqc >> 16) & 0xff)); //address byte
            Marshal.WriteByte(_ptrDiseqc, 2, (byte)((diseqc >> 8) & 0xff));  //command byte
            Marshal.WriteByte(_ptrDiseqc, 3, (byte)(diseqc & 0xff));         //data byte (port group 0)
            Marshal.WriteInt32(_ptrDiseqc, 160, 4);                          //send_message_length
            Marshal.WriteInt32(_ptrDiseqc, 164, 0);                          //receive_message_length
            Marshal.WriteInt32(_ptrDiseqc, 168, 3);                          //amplitude_attenuation
            if (antennaNr == 1)                                              //for simple diseqc switches (i.e. 22KHz tone burst)
            {
                Marshal.WriteByte(_ptrDiseqc, 172, (int)BurstModulationType.TONE_BURST_UNMODULATED);
            }
            else
            {
                Marshal.WriteByte(_ptrDiseqc, 172, (int)BurstModulationType.TONE_BURST_MODULATED);
                //default to tone_burst_modulated
            }
            Marshal.WriteByte(_ptrDiseqc, 176, (int)DisEqcVersion.DISEQC_VER_1X); //default
            Marshal.WriteByte(_ptrDiseqc, 180, (int)RxMode.RXMODE_NOREPLY);       //default
            Marshal.WriteByte(_ptrDiseqc, 184, 1);                                //last_message TRUE */

            string txt = "";

            for (int i = 0; i < 4; ++i)
            {
                txt += String.Format("0x{0:X} ", Marshal.ReadByte(_ptrDiseqc, i));
            }
            for (int i = 160; i < 188; i = (i + 4))
            {
                txt += String.Format("0x{0:X} ", Marshal.ReadInt32(_ptrDiseqc, i));
            }
            Log.Log.Debug("Hauppauge: SendDiseq: {0}", txt);
            int hr = _propertySet.Set(BdaTunerExtentionProperties, (int)BdaTunerExtension.KSPROPERTY_BDA_DISEQC, _ptrDiseqc,
                                      len, _ptrDiseqc, len);

            if (hr != 0)
            {
                succeeded = false;
                Log.Log.Info("Hauppauge: SendDiseq returned: 0x{0:X} - {1}", hr, DsError.GetErrorText(hr));
            }
            return(succeeded);
        }
        /// <summary>
        /// Sends the diseq command.
        /// </summary>
        /// <param name="channel">The channel.</param>
        /// <param name="parameters">The channels scanning parameters.</param>
        public void SendDiseqCommand(ScanParameters parameters, DVBSChannel channel)
        {
            if (_isProfRed == false)
            {
                return;
            }
            if (_previousChannel != null)
            {
                if (_previousChannel.Frequency == channel.Frequency &&
                    _previousChannel.DisEqc == channel.DisEqc &&
                    _previousChannel.Polarisation == channel.Polarisation &&
                    _previousChannel.Pilot == channel.Pilot &&
                    _previousChannel.Rolloff == channel.Rolloff &&
                    _previousChannel.InnerFecRate == channel.InnerFecRate)
                {
                    _previousChannel = channel;
                    Log.Log.WriteFile("ProfRed: already tuned to diseqc:{0}, frequency:{1}, polarisation:{2}",
                                      channel.DisEqc, channel.Frequency, channel.Polarisation);
                    return;
                }
                if (_previousChannel.DisEqc == DisEqcType.None && channel.DisEqc == DisEqcType.None)
                {
                    _previousChannel = channel;
                    Log.Log.WriteFile("ProfRed: already no diseqc used",
                                      channel.DisEqc, channel.Frequency, channel.Polarisation);
                    return;
                }
            }
            if (_previousChannel == null && channel.DisEqc == DisEqcType.None)
            {
                _previousChannel = channel;
                Log.Log.WriteFile("ProfRed: diseqc isn't used - skip it",
                                  channel.DisEqc, channel.Frequency, channel.Polarisation);
                return;
            }
            _previousChannel = channel;
            int antennaNr = BandTypeConverter.GetAntennaNr(channel);

            //hack - bypass diseqc settings for single LNB implementations
            if (antennaNr == 0)
            {
                return;
            }
            //end of hack

            //clear the message params before writing in order to avoid corruption of the diseqc message.
            for (int i = 0; i < 188; ++i)
            {
                Marshal.WriteByte(_ptrDiseqc, i, 0x00);
            }

            bool hiBand = BandTypeConverter.IsHiBand(channel, parameters);


            //bit 0	(1)	: 0=low band, 1 = hi band
            //bit 1 (2) : 0=vertical, 1 = horizontal
            //bit 3 (4) : 0=satellite position A, 1=satellite position B
            //bit 4 (8) : 0=switch option A, 1=switch option  B
            // LNB    option  position
            // 1        A         A
            // 2        A         B
            // 3        B         A
            // 4        B         B

            bool isHorizontal = ((channel.Polarisation == Polarisation.LinearH) ||
                                 (channel.Polarisation == Polarisation.CircularL));
            byte cmd = 0xf0;

            cmd |= (byte)(hiBand ? 1 : 0);
            cmd |= (byte)((isHorizontal) ? 2 : 0);
            cmd |= (byte)((antennaNr - 1) << 2);

            const int len    = 188;
            ulong     diseqc = 0xE0103800; //currently committed switches only. i.e. ports 1-4

            diseqc += cmd;
            Marshal.WriteByte(_ptrDiseqc, 0, (byte)((diseqc >> 24) & 0xff)); //framing byte
            Marshal.WriteByte(_ptrDiseqc, 1, (byte)((diseqc >> 16) & 0xff)); //address byte
            Marshal.WriteByte(_ptrDiseqc, 2, (byte)((diseqc >> 8) & 0xff));  //command byte
            Marshal.WriteByte(_ptrDiseqc, 3, (byte)(diseqc & 0xff));         //data byte (port group 0)
            Marshal.WriteByte(_ptrDiseqc, 151, 4);                           //send_message_length
            Marshal.WriteByte(_ptrDiseqc, 161, 0);                           //receive_message_length

            if (antennaNr == 1)                                              //for simple diseqc switches (i.e. 22KHz tone burst)
            {
                Marshal.WriteByte(_ptrDiseqc, 164, 2);                       // TONE_BURST_UNMODULATED
            }
            else
            {
                Marshal.WriteByte(_ptrDiseqc, 164, 1); // TONE_BURST_MODULATED
            }
            Marshal.WriteByte(_ptrDiseqc, 172, 3);     //default for Diseqc
            Marshal.WriteByte(_ptrDiseqc, 168, 2);     //RxMode.RXMODE_NOREPLY);//default
            Marshal.WriteByte(_ptrDiseqc, 180, 1);     //last_message TRUE */
            string txt = "";

            for (int i = 0; i < 4; ++i)
            {
                txt += String.Format("0x{0:X} ", Marshal.ReadByte(_ptrDiseqc, i));
            }
            txt += String.Format("0x{0:X} ", Marshal.ReadByte(_ptrDiseqc, 151)); //send_message_length
            for (int i = 164; i < 188; i += 4)
            {
                txt += String.Format("0x{0:X} ", Marshal.ReadInt32(_ptrDiseqc, i));
            }
            Log.Log.WriteFile("ProfRed: SendDiseq: {0}", txt);

            int retval; //out value
            int hr = _propertySet.Get(_bdaTunerExtentionProperties, (int)BdaTunerExtension.KSPROPERTY_BDA_DISEQC, _ptrDiseqc,
                                      len, _ptrDiseqc, len, out retval);

            Log.Log.Info("ProfRed: setdiseqc returned:{0:X}", hr);
        }