Jump to content


Photo

A script to get signal levels for a satellite


  • Please log in to reply
15 replies to this topic

#1 Robinson

  • Senior Member
  • 2,523 posts

+30
Good

Posted 27 January 2014 - 08:34

Hello guys,

I have come across a script that is supposed to zap through transponders of a given satellite (using lamedb entries) in order to record signal levels.

The command could be the following:

/usr/script/zap_to_every_transponder.sh 48 192 3592 (and then receiver will scan 4,8*E-19,2*E-0,8*W)

Then the result is output in a file. Unfortunately this does not quite work as expected on my motorized system.

If anyone is interested in such a script, can you please look into it and see what might be wrong.

Maybe it works well on your systems.

Thank you.

Attached Files


ET9000, OpenPLi 4.0, 13E, 19E

HD51, OpenPLi 6.2, 75E - 30W


Re: A script to get signal levels for a satellite #2 Robinson

  • Senior Member
  • 2,523 posts

+30
Good

Posted 30 January 2014 - 19:13

I guess hardly anyone bothered to download the attachment.

Here is the script:

 

#!/bin/sh
#
# MartiniB #
#
#

[ ! $1 ] && SatPosToDo="*" || SatPosToDo=$1

E2conf=/etc/enigma2/settings
Services=/etc/enigma2/lamedb

foo="$0"
crntNamePath=${foo%.*}
crntNameTXT=$crntNamePath".txt"
crntNameExt=${foo##*/}
crntNameShort=${crntNameExt%.*}
fileCmd=/tmp/"$crntNameShort".CMD
#fileLog=/tmp/"$crntNameShort".Log
fileTuneFailed=$crntNamePath".TuneFailed"
fileTuneOK=$crntNamePath".TuneOK_"`date +%y%m%d`

[ -e /etc/enigma2/settings ] && [ -e /etc/enigma2/lamedb ] || exit

[ ! -e $fileTuneFailed ] && echo -e "#\n# Tune Failed list:\n#\n"SatPos"\t"Frequency"\t"Symbolrate"\t"Transponder-ID"\t\t"Date-Time>$fileTuneFailed
[ ! -e $fileTuneOK ] && echo -e "#\n# Tune OK list:\n#\n"SatPos"\t"Frequency"\t"Symbolrate"\t"Transponder-ID"\t\t"Signal-Info"\t"SNR"\t"ACG"\t"BER>$fileTuneOK

FreePort=80
DOCMD1="wget -O $fileCmd -q http://localhost:$FreePort/web"
DOCMD2=$DOCMD1/remotecontrol?command=

# Wakeup form Standby
$DOCMD1/powerstate?newstate=4

PreviousOkServiceRef=1:0:1:1897:D:55:300000:0:0:0:
$DOCMD1/zap?sRef=$PreviousOkServiceRef
sleep 2

ZapToService () {
	$DOCMD1/zap?sRef=$ServiceRef
	Symbolrate=`echo $line| sed -e s#:#\ #g| awk {'print $3'}`
	Symbolrate=$((Symbolrate / 1000))
	if [ "$Symbolrate" -ge "20000" ]; then
		sleep 3
	elif [ "$Symbolrate" -ge "10000" ]; then
		sleep 4
	elif [ "$Symbolrate" -ge "9000" ]; then
		sleep 6
	elif [ "$Symbolrate" -ge "8000" ]; then
		sleep 8
	elif [ "$Symbolrate" -ge "7000" ]; then
		sleep 10
	elif [ "$Symbolrate" -ge "6000" ]; then
		sleep 12
	elif [ "$Symbolrate" -ge "5000" ]; then
		sleep 14
	elif [ "$Symbolrate" -ge "4000" ]; then
		sleep 16
	elif [ "$Symbolrate" -ge "3000" ]; then
		sleep 18
	else
		sleep 20
	fi
	TryCounter="1"
	SignalInfo="" SignalInfoSNR="-" SignalInfoACG="-" SignalInfoBER="-"
	while [ ! "$SignalInfo" ]; do
		$DOCMD1/signal
		sleep 1
		sed -e ':a;N;$!ba;s/\n/\ /g' -e s#[[:space:]]##g $fileCmd>$fileCmd.singleline
		SignalInfo=`grep "<e2snrdb>" $fileCmd.singleline| sed -e 's/.*<e2snrdb>//' -e 's/<.*//' -e 's/.*\/.*//' -e 's/dB/\ dB/'`
		if [ ! "$SignalInfo" ]; then
			TryCounter=$((TryCounter + 1))
			if [ "$TryCounter" -ge "3" ]; then
				SignalInfo="0"
			else
				# Wakeup form Standby
				$DOCMD1/powerstate?newstate=4
				sleep 2
			fi
		else
			SignalInfoSNR=`grep "<e2snr>" $fileCmd.singleline| sed -e 's/.*<e2snr>//' -e 's/<.*//'`
			SignalInfoACG=`grep "<e2acg>" $fileCmd.singleline| sed -e 's/.*<e2acg>//' -e 's/<.*//'`
			SignalInfoBER=`grep "<e2ber>" $fileCmd.singleline| sed -e 's/.*<e2ber>//' -e 's/<.*//'`
		fi
	done
	SignalInfo2=${SignalInfo%.*}
	Freq=`echo $line| sed -e s#:#\ #g| awk {'print $2'}`
	case "$line" in
		s\ *)	Pol=" "`echo $line| sed -e s#:#\ #g| awk {'print $4'}| sed -e s#0#H# -e s#1#V#`
			Freq=`echo $((Freq / 1000))| sed -e s#[0-9][0-9]#\&\.#`$Pol;;
		*)	Pol=""
			Freq=$((Freq / 1000));;
	esac
	[ "$SignalInfo2" -ge "0" -a "$SignalInfo2" -le "9" ] && SignalInfo=" "$SignalInfo
	#echo -e "$SignalInfo\t"$satPosE2"\t"$Freq"\t"$Symbolrate"\t"$TransponderID
	echo -e "$SignalInfo\t"$satPosE2"\t"$Freq"\t"$Symbolrate"\t"$TransponderID"\t"$SignalInfoSNR"\t"$SignalInfoACG"\t"$SignalInfoBER
	if [ "$SignalInfo2" -le "4" ] || [ "$SignalInfo2" -gt "25" ]; then
		echo -e $satPosE2"\t"$Freq"\t"$Symbolrate"\t\t"$TransponderID"\t"`date +%y.%m.%d.\ %H:%M:%S`>>$fileTuneFailed
		$DOCMD1/zap?sRef=$PreviousOkServiceRef
		sleep 2
	else
		echo -e $satPosE2"\t"$Freq"\t"$Symbolrate"\t\t"$TransponderID"\t"$SignalInfo"\t"$SignalInfoSNR"\t"$SignalInfoACG"\t"$SignalInfoBER>>$fileTuneOK
		PreviousOkServiceRef=$ServiceRef
	fi
	$DOCMD2"174"
	$DOCMD2"174"
#exit
}

while read line; do
  case "$line" in
	end)
		break;;
	\/)
#exit
		TransponderID="" Pol="";;
	t\ *|c\ *)
	;;
	s\ *)
	   if [ "$TransponderID" ]; then
		satPos=`echo $line| sed -e s#:#\ #g| awk {'print $6'}`
		[ "$satPos" -lt 0 ] && satPosE2=$((3600 + satPos)) || satPosE2="$satPos"
		if [ ! "$satPosE2" = "$satPosLastCheck" ]; then
			if grep -qs ".sat.$satPosE2." "$E2conf"; then
				case "$satPosE2" in
					#*)
					#192)
					#3592)
					$SatPosToDo|$2|$3|$4|$5|$6|$7|$8|$9)
						satPosInst=1;;
					*)
						satPosInst="skip";;
				esac
			else
				satPosInst=0
			fi
			satPosLastCheck="$satPosE2"
			echo -e satPosE2: "$satPosE2\t\t\t" satPosInst: "$satPosInst"
		fi
		if [ "$satPosInst" = "1" ]; then

# type 1 = digital television service
# type 4 = nvod reference service (NYI)
# type 17 = MPEG-2 HD digital television service
# type 22 = advanced codec SD digital television
# type 24 = advanced codec SD NVOD reference service (NYI)
# type 25 = advanced codec HD digital television
# type 27 = advanced codec HD NVOD reference service (NYI)
# type 2 = digital radio sound service
# type 10 = advanced codec digital radio sound service

			TransponderServices=`grep "^....:$TransponderID:.*:0" "$Services"`
			if [ "$TransponderServices" ]; then
				ServiceID=""
				for ServiceType in 1 25 17 22 24 27 4 25 130 133 2 *; do
					for Service in $TransponderServices; do
						case "$Service" in
							*:*:*:*:$ServiceType:0) ServiceID=`echo $Service| sed -e s#:.*##` break;;
						esac
					done
					if [ "$ServiceID" ]; then
						ServiceRef=1:0:1:"$ServiceID"`echo $TransponderID| sed -e s#........##`:`echo $TransponderID| sed -e s#:.*##`:0:0:0
						ZapToService
						break
					fi
				done
			fi
		fi
	   fi
	;;
	[0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f]:[0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f]:[0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f])
		TransponderID="$line"
		if grep -qs "[[:space:]]$TransponderID[[:space:]]" "$fileTuneFailed" ||
		grep -qs "[[:space:]]$TransponderID[[:space:]]" "$fileTuneOK"; then
			TransponderID=""
		fi
	;;
  esac
done < "$Services"

 

Any ideas on how to improve this script?


ET9000, OpenPLi 4.0, 13E, 19E

HD51, OpenPLi 6.2, 75E - 30W


Re: A script to get signal levels for a satellite #3 Huevos

  • PLi® Contributor
  • 3,276 posts

+131
Excellent

Posted 31 January 2014 - 22:12

How do you want to improve it? Wouldn't you rather an E2 plugin?

 

By the way I wrote something last night in PHP that does the same thing but across the network interrogating the box via OpenWebIF. Result here:

http://satellites-xml.org/28E-SNR.php


Edited by Huevos, 31 January 2014 - 22:16.


Re: A script to get signal levels for a satellite #4 Robinson

  • Senior Member
  • 2,523 posts

+30
Good

Posted 31 January 2014 - 23:00

Well, this script somehow does not work for me very well on a motorized system.

Maybe someone else would be willing to try it?

I just want to scan 1 whole satellite, let's say 13E or 28E.

How do I do that without touching my lamedb?

/usr/bin/zap_to_every_transponder.sh 130 does not exactly do the job for me.

 

How do you want to improve it? Wouldn't you rather an E2 plugin?

 

By the way I wrote something last night in PHP that does the same thing but across the network interrogating the box via OpenWebIF. Result here:

http://satellites-xml.org/28E-SNR.php

Can you share your php script?


Edited by Robinson, 31 January 2014 - 23:01.

ET9000, OpenPLi 4.0, 13E, 19E

HD51, OpenPLi 6.2, 75E - 30W


Re: A script to get signal levels for a satellite #5 Huevos

  • PLi® Contributor
  • 3,276 posts

+131
Excellent

Posted 31 January 2014 - 23:23

Well, this script somehow does not work for me very well on a motorized system.

Maybe someone else would be willing to try it?

I just want to scan 1 whole satellite, let's say 13E or 28E.

How do I do that without touching my lamedb?

/usr/bin/zap_to_every_transponder.sh 130 does not exactly do the job for me.

 

Can you share your php script?

What I mean is what is the purpose of the scan? Just to get signal level?

 

Yes you can have a copy of the PHP script if you like. But I think easiest option would an E2 plugin so you can control it from the GUI. And write output to an xml file.

 

Also doing it with an E2 plugin would be easier because you don't need the service refs, and you could select whichever tuner you want to use.

 

Here's how I did it in PHP. First I did a complete scan of 28E. Then I saved userbouquet.LastScanned.tv. I wrote a bit of code that reads that along with lamedb and grabs one service ref off each transponder. Once you've got the service refs it's easy. Just zap the box via OpenWebIF and read the SNR. Then I'm writing the result to MySQL (instead of file). Another file runs it every 10 minutes (could be done with a cron job). And then finally there is another script to display the result from MySQL.



Re: A script to get signal levels for a satellite #6 Robinson

  • Senior Member
  • 2,523 posts

+30
Good

Posted 31 January 2014 - 23:41

What I mean is what is the purpose of the scan? Just to get signal level?

Yeah, just to check how the level changes during the day or over a certain period of time or after snowfall or during rain etc.

 

But I think easiest option would an E2 plugin so you can control it from the GUI. And write output to an xml file.

Yes, but that requires somebody's effort and I'm not sure if there is someone who wants to make it.

 

 


ET9000, OpenPLi 4.0, 13E, 19E

HD51, OpenPLi 6.2, 75E - 30W


Re: A script to get signal levels for a satellite #7 Huevos

  • PLi® Contributor
  • 3,276 posts

+131
Excellent

Posted 1 February 2014 - 00:15

Ok, here's the very basics in PHP. Change the box IP right at top. It will give you output something like this.

 

10714 = 13.14 dB
10729 = 12.52 dB
10744 = 13.19 dB
10758 = 12.93 dB
10773 = 12.69 dB
10788 = 13.75 dB
10803 = 12.94 dB
10817 = 13.99 dB
10832 = 13.92 dB
10847 = 12.98 dB
10862 = 13.59 dB
10876 = 13.23 dB
10891 = 12.72 dB
10906 = 13.21 dB
10921 = 13.00 dB
10935 = 12.73 dB
10964 = 12.23 dB
10994 = 11.99 dB
11023 = 11.85 dB
11053 = 12.16 dB
11067 = 11.89 dB
11097 = 11.93 dB
11126 = 12.33 dB
11222 = 10.04 dB
11224 = 10.92 dB
11260 = 10.00 dB
11261 = 10.71 dB
11307 = 11.06 dB
11343 = 8.87 dB
11344 = 10.39 dB
11390 = 10.23 dB
11426 = 9.51 dB
11719 = 13.33 dB
11758 = 6.97 dB
11778 = 7.28 dB
11797 = 13.98 dB
11817 = 14.76 dB
11836 = 0.00 dB
11856 = 0.00 dB
11875 = 0.00 dB
11895 = 14.38 dB
11914 = 8.32 dB
11934 = 7.16 dB
11992 = 8.53 dB
12012 = 7.46 dB
12031 = 14.94 dB
12051 = 14.14 dB
12070 = 14.28 dB
12090 = 13.92 dB
12109 = 14.64 dB
12148 = 14.29 dB
12168 = 13.41 dB
12187 = 14.01 dB
12207 = 13.91 dB
12226 = 14.44 dB
12246 = 13.68 dB
12265 = 14.27 dB
12285 = 14.74 dB
12304 = 14.06 dB
12324 = 14.30 dB
12343 = 14.70 dB
12363 = 13.77 dB
12382 = 8.72 dB
12460 = 9.59 dB
12480 = 9.31 dB
12515 = 14.69 dB
12520 = 14.38 dB
12545 = 14.58 dB
12551 = 14.47 dB
12574 = 12.10 dB
12580 = 12.66 dB
12604 = 13.72 dB
12610 = 14.01 dB
12633 = 14.20 dB
12640 = 14.05 dB
12663 = 13.21 dB
12669 = 12.33 dB

Attached Files

  • Attached File  SNR.php   5.4KB   74 downloads


Re: A script to get signal levels for a satellite #8 Robinson

  • Senior Member
  • 2,523 posts

+30
Good

Posted 1 February 2014 - 17:08

Thanks Huevos.

Now, how do I run this script? What software do I need on my computer?


ET9000, OpenPLi 4.0, 13E, 19E

HD51, OpenPLi 6.2, 75E - 30W


Re: A script to get signal levels for a satellite #9 Huevos

  • PLi® Contributor
  • 3,276 posts

+131
Excellent

Posted 1 February 2014 - 18:03

You need a webserver (apache) and PHP. If it's a Windows PC the links are below (non ssl version):

http://ftp.cixug.es/...binaries/win32/

http://windows.php.n...32-VC11-x86.zip

Install Apache first (as a service) then PHP.

Then just put the script in /htdocs in your Apache directory.

Then open a web browser on same PC and type http://localhost/scriptname.php



Re: A script to get signal levels for a satellite #10 Huevos

  • PLi® Contributor
  • 3,276 posts

+131
Excellent

Posted 3 February 2014 - 02:16

And once you've got some data you can draw some graphs with it (also done with PHP).

 

Attached File  daily-trend.png   146.28KB   23 downloads



Re: A script to get signal levels for a satellite #11 Oliver.M.

  • Member
  • 12 posts

0
Neutral

Posted 16 June 2020 - 17:57

Hi, Sorry to re-open a 6 year old thread -

 

I'm looking to do something very similar but as a plug in.

Is there a command I can run on my receiver to get the signal levels?

 

I noticed this echo command in Robinsons code:

echo -e "$SignalInfo\t"$satPosE2"\t"$Freq"\t"$Symbolrate"\t"$TransponderID"\t"$SignalInfoSNR"\t"$SignalInfoACG"\t"$SignalInfoBER

Is this dependent on anything else in the code Robinson has written or could this be run on its own to return information such as the Signal to Noise ratio?

 

I would like to build this into a plugin to automatically monitor the SNR over time into a CSV file.



Re: A script to get signal levels for a satellite #12 athoik

  • PLi® Core member
  • 8,395 posts

+321
Excellent

Posted 16 June 2020 - 21:33

You can read values directly from dvb...

 

import sys
import time
import fcntl
import ctypes

_IOC_NRBITS = 8
_IOC_TYPEBITS = 8
_IOC_SIZEBITS = 14
_IOC_DIRBITS = 2

_IOC_NRSHIFT = 0
_IOC_TYPESHIFT = _IOC_NRSHIFT + _IOC_NRBITS
_IOC_SIZESHIFT = _IOC_TYPESHIFT + _IOC_TYPEBITS
_IOC_DIRSHIFT = _IOC_SIZESHIFT + _IOC_SIZEBITS

_IOC_NONE = 0
_IOC_WRITE = 1
_IOC_READ  = 2

def _IOC(dir_, type_, nr, size):
    return (
        ctypes.c_int32(dir_ << _IOC_DIRSHIFT).value |
        ctypes.c_int32(ord(type_) << _IOC_TYPESHIFT).value |
        ctypes.c_int32(nr << _IOC_NRSHIFT).value |
        ctypes.c_int32(size << _IOC_SIZESHIFT).value)

def _IOC_TYPECHECK(t):
    return ctypes.sizeof(t)

def _IO(type_, nr):
    return _IOC(_IOC_NONE, type_, nr, 0)

def _IOW(type_, nr, size):
    return _IOC(_IOC_WRITE, type_, nr, _IOC_TYPECHECK(size))

def _IOR(type_, nr, size):
    return _IOC(_IOC_READ, type_, nr, _IOC_TYPECHECK(size))

def _IOWR(type_, nr, size):
    return _IOC(_IOC_READ | _IOC_WRITE, type_, nr, _IOC_TYPECHECK(size))

enum = ctypes.c_uint
fe_status_t = enum
FE_HAS_SIGNAL = 0x01
FE_HAS_CARRIER = 0x02
FE_HAS_VITERBI = 0x04
FE_HAS_SYNC = 0x08
FE_HAS_LOCK = 0x10
FE_TIMEDOUT = 0x20
FE_REINIT = 0x40

FE_READ_STATUS = _IOR('o', 69, fe_status_t)
FE_READ_BER = _IOR('o', 70, ctypes.c_uint32)
FE_READ_SIGNAL_STRENGTH = _IOR('o', 71, ctypes.c_uint16)
FE_READ_SNR = _IOR('o', 72, ctypes.c_uint16)
FE_READ_UNCORRECTED_BLOCKS = _IOR('o', 73, ctypes.c_uint32)

class Frontend(object):
    def __init__(self, fd):
        self._fd = fd

    def _ioctlGet(self, query, c_type):
        result = c_type()
        try:
                fcntl.ioctl(self._fd, query, result)
        except:
                print "exception using %s" % query
        return result

    def getStatus(self):
        return self._ioctlGet(FE_READ_STATUS, fe_status_t).value

    def getBitErrorRate(self):
        return self._ioctlGet(FE_READ_BER, ctypes.c_uint32).value

    def getSignalNoiseRatio(self):
        return self._ioctlGet(FE_READ_SNR, ctypes.c_uint16).value

    def getSignalStrength(self):
        return self._ioctlGet(FE_READ_SIGNAL_STRENGTH, ctypes.c_uint16).value

    def getUncorrectedBlockCount(self):
        return self._ioctlGet(FE_READ_UNCORRECTED_BLOCKS, ctypes.c_uint32).value


dev = "/dev/dvb/adapter0/frontend1"
fe = Frontend(open(dev, 'r'))

sys.stdout.write("EPOCH;BER;STATUS;SNR;SIGNAL\n")
for x in range(10):
        sys.stdout.write("%d;%d;%d;%d;%d\n" % (time.time(), fe.getBitErrorRate(), fe.getStatus(), fe.getSignalNoiseRatio(), fe.getSignalStrength()))
        time.sleep(1)

 

python dvbcsv.py
EPOCH;BER;STATUS;SNR;SIGNAL
1592339481;0;31;29520;100
1592339482;0;31;29520;100
1592339483;0;31;29520;100
1592339484;0;31;29520;100
1592339485;0;31;29520;100
1592339486;0;31;29520;100
1592339487;0;31;29520;100
1592339488;0;31;29360;100
1592339489;0;31;29360;100
1592339490;0;31;29520;100

 

Above code uses parts of: https://pypi.org/project/linuxdvb/

 

So only DVB API v3. In case you need DVB API v5 you need to create the required ioctl's.


Wavefield T90: 0.8W - 1.9E - 4.8E - 13E - 16E - 19.2E - 23.5E - 26E - 33E - 39E - 42E - 45E on EMP Centauri DiseqC 16/1
Unamed: 13E Quattro - 9E Quattro on IKUSI MS-0916

Re: A script to get signal levels for a satellite #13 Huevos

  • PLi® Contributor
  • 3,276 posts

+131
Excellent

Posted 16 June 2020 - 23:28

This is really cool.



Re: A script to get signal levels for a satellite #14 Oliver.M.

  • Member
  • 12 posts

0
Neutral

Posted 17 June 2020 - 08:36

athoik - this is great, thank you for providing this!!

 

Over the past few days I have been looking at the eDVBResourceManager enigma module and frontend.cpp code and haven't been getting anywhere. This has just solved all of my problems.

 

Thank you.



Re: A script to get signal levels for a satellite #15 Huevos

  • PLi® Contributor
  • 3,276 posts

+131
Excellent

Posted 17 June 2020 - 12:38

athoik - this is great, thank you for providing this!!

 

Over the past few days I have been looking at the eDVBResourceManager enigma module and frontend.cpp code and haven't been getting anywhere. This has just solved all of my problems.

 

Thank you.

 

 

athoik - this is great, thank you for providing this!!

 

Over the past few days I have been looking at the eDVBResourceManager enigma module and frontend.cpp code and haven't been getting anywhere. This has just solved all of my problems.

 

Thank you.

You still need to borrow some code from frontend.cpp to convert the SNR into human readable values. And maybe some code to control the tuner (either internally via enigma) or externally (send commands to OpenWebIF). The beauty of this code though is ti works from outside enigma.



Re: A script to get signal levels for a satellite #16 insiderain

  • New Member
  • 2 posts

0
Neutral

Posted 3 March 2021 - 10:27

Hi, 

I tried to run the script from athoik (post#12, sorry for not replying as quote but somehow I missed the link while writing) on my zgemma H2 box and I get logs like these below:
 
 EPOCH;BER;STATUS;SNR;SIGNAL

exception using -2147193018
exception using -2147193019
exception using -2147324088
exception using -2147324089
1614762772;0;0;0;0
exception using -2147193018
exception using -2147193019
exception using -2147324088
exception using -2147324089
1614762773;0;0;0;0
exception using -2147193018
exception using -2147193019
exception using -2147324088
exception using -2147324089
 

 It looks like all ioclt calls fail with exception. I changed your code to dump the exception message which is "Operation not permitted".

 

 Am I doing something wrong? I tested it with both frontend0 and frontend1 but I get the same results.


Edited by insiderain, 3 March 2021 - 10:30.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users