Read / Set Gain from SkyView and Gmap


#1

(1) Gain Reading/Setting added in dump1090-fa’s SkyView Map

.

(1) Gain Reading/Setting added in dump1090-mutability’s gmap

.

Click the link which matches your install:

1. Piaware SD Card image

2. Raspbian Jessie/Stretch image with dump1090-fa package install

3. Raspbian Jessie/Stretch image with dump1090-mutability v1.15~dev install

.
.

REFERENCE:
The requirement to have gain setting embedded in SkyView / gmap was originated by user @evangelyul.

To achieve this objective, the author @abcd567 developed the method presented in this thread. User @evangelyul has actively participated during the development stage.

Please see following thread for development details:
https://discussions.flightaware.com/t/set-gain-from-browser/36278


Do I Need A Filter?
#2

Piaware%20SD%20Card%20Image

STEP-1: Install necessary php packages and enable module

sudo apt-get update
sudo apt-get install php5-cgi
sudo lighty-enable-mod fastcgi-php
sudo /etc/init.d/lighttpd force-reload

.

STEP-2: Set up existing user www-data

2.1 - Assign strong password to existing user www-data, and add it to sudoer’s group

sudo passwd www-data
sudo adduser www-data sudo
groups www-data

.
2.2 - REBOOT for sudo permission of user www-data to be implemented.

sudo reboot

STEP-3: Create new directory and files

3.1 - Create new directory

sudo mkdir /var/www/html/setgain

3.2 - Move inside the new directory

cd /var/www/html/setgain/

3.3 - Inside directory /var/www/html/setgain, create a new blank file setgain.sh, make it executable

sudo touch setgain.sh
sudo chmod +x setgain.sh

3.4 - Open newly created file in nano editor

sudo nano setgain.sh

3.5 - Add code to the new file
(In code below, replace xxxxxxxxx by the actual password you have set for user www-data)

#!/bin/bash
echo 'xxxxxxxxxxx' | sudo -S piaware-config rtlsdr-gain "$1"

echo 'xxxxxxxxxxx' | sudo -S systemctl restart dump1090-fa

Save (Ctrl+o) and Close (Ctrl+x) the file.
.

3.6 - Inside directory /var/www/html/setgain, create a new blank file findgain.sh, make it executable

sudo touch findgain.sh
sudo chmod +x findgain.sh

3.7 - Open newly created file in nano editor

sudo nano findgain.sh

3.8 - Add code to the new file
(In code below, replace xxxxxxxxx by the actual password you have set for user www-data)

#!/bin/bash
echo 'xxxxxxxxxxx' | sudo -S piaware-config -show rtlsdr-gain

Save (Ctrl+o) and Close (Ctrl+x) the file.
.

STEP-4

4.1 - Create a new file gain.php in folder /usr/share/dump1090-fa/html

cd /usr/share/dump1090-fa/html/
sudo nano gain.php   

4.2 - Copy-paste following code in newly created blank file gain.php

NOTE: Some of code lines are very long. Scroll Right to see these in full
.

<html>
 <form id="myform" action="gain.php" method="post" />
  <input type="text" name="gain" id="gain" maxlength="5" size="4" value="<?php system('/var/www/html/setgain/findgain.sh');?>" />
  <input type="submit" value="Set Gain" style="color:#ffffff;background-color:#00A0E2;border-color:#00B0F0;" />
 </form>
</html>

<?php
function setgain(){
$gain="{$_POST['gain']}";
system("/var/www/html/setgain/setgain.sh $gain  >> /tmp/gain.log 2>&1");
header("Refresh:0");
}

if ("{$_POST['gain']}"){
setgain();
}
?>


Save (Ctrl+o) and Close (Ctrl+x)

STEP-5

5.1 - Next step is to edit file index.html in folder `/usr/share/dump1090-fa/html.
BEFORE EDITING, make its backup copy. This will enable you to revert in case something goes wrong.

cd /usr/share/dump1090-fa/html/
sudo cp index.html index.bak.html

#Check to ensure back-up copy has been created by giving ls command

ls

#The output should contain both index.html and index.bak.html
config.js    formatter.js    layers.js         script.js
db           images          markers.js        spinny.gif
dbloader.js  index.bak.html  ol                style.css
flags.js     index.html      planeObject.js    test
flags-tiny   jquery          registrations.js  upintheair.json

.

5.2 - Open the file `index.html for editing

cd /usr/share/dump1090-fa/html/  
sudo nano index.html  

5.3 - Press Ctrl+w then type buttonContainer then press Enter key.
The cursor will jump to line containg word buttonContainer, as shown below

			<div class="logoContainer">
				<a href="http://flightaware.com/" target="_blank"><img src="images/fa_logo_color.png" alt="FlightAware" class="flightawareLogo" srcset="images/fa_logo_color.png 1x, images/fa_logo_color@2x.png 2x, images/fa_logo_color@3x.png 3x"></a>
				<img src="images/pa-sv-logo.png" alt="PiAware SkyView" class="adsbLogo piAwareLogo" srcset="images/pa-sv-logo.png 1x, images/pa-sv-logo@2x.png 2x, images/pa-sv-logo@3x.png 3x">
				<img src="images/ff-sv-logo.png" alt="FlightFeeder SkyView" class="adsbLogo flightfeederLogo" srcset="images/ff-sv-logo.png 1x, images/ff-sv-logo@2x.png 2x, images/ff-sv-logo@3x.png 3x" style="display: none;">
			</div>

			<div class="buttonContainer">
				<div class="dateTime" id="clock_div"></div>
				<div class="button buttonHeader" onclick="resetMap();"><span class="buttonText">Reset Map</span></div>

.

5.4 - Just above line <div class="buttonContainer">, insert following 3 lines

<div id="GAIN" style="text-align:center;width:175px;height:65px;">   
<iframe src=gain.php style="border:0;width:175px;height:65px;"></iframe>   
</div> <!----- GAIN --->   

.
After insertion of 3 lines, the code will be like shown below:

			<div class="logoContainer">
				<a href="http://flightaware.com/" target="_blank"><img src="images/fa_logo_color.png" alt="FlightAware" class="flightawareLogo" srcset="images/fa_logo_color.png 1x, images/fa_logo_color@2x.png 2x, images/fa_logo_color@3x.png 3x"></a>
				<img src="images/pa-sv-logo.png" alt="PiAware SkyView" class="adsbLogo piAwareLogo" srcset="images/pa-sv-logo.png 1x, images/pa-sv-logo@2x.png 2x, images/pa-sv-logo@3x.png 3x">
				<img src="images/ff-sv-logo.png" alt="FlightFeeder SkyView" class="adsbLogo flightfeederLogo" srcset="images/ff-sv-logo.png 1x, images/ff-sv-logo@2x.png 2x, images/ff-sv-logo@3x.png 3x" style="display: none;">
			</div>

<div id="GAIN" style="text-align:center;width:175px;height:65px;">   
<iframe src=gain.php style="border:0;width:175px;height:65px;"></iframe>   
</div> <!----- GAIN --->   

			<div class="buttonContainer">
				<div class="dateTime" id="clock_div"></div>
				<div class="button buttonHeader" onclick="resetMap();"><span class="buttonText">Reset Map</span></div>

.

5.5 - Go to page IP-of-PI/dump1090-fa/ and check gain setting add-on appears as shown in screenshot below.

The value show at browser load or re-load is your current gain value.

If you want to change it, replace the value displaced by value desired and click “Set Gain” button. The value in gain box will briefly show your previous setting, then show your current (changed) setting.

Check the gain value by following command. The last line of output of this command will show the actual value of gain used.

sudo systemctl status dump1090-fa -l    

.


#3

Jessie%20and%20Stretch%20FA

For Raspbian Jessie/Stretch + dump1090-fa package install

Only Step-1 is different for Jessie and Stretch, rest is same.

STEP-1 (JESSIE): Install necessary php packages and enable module

sudo apt-get update   
sudo apt-get install php5-cgi   
sudo lighty-enable-mod fastcgi-php   
sudo /etc/init.d/lighttpd force-reload   

STEP-1 (STRETCH): Install necessary php packages and enable module

sudo apt-get update   
sudo apt-get install php7.0-cgi   
sudo lighty-enable-mod fastcgi-php   
sudo /etc/init.d/lighttpd force-reload   

.

STEP-2: Set up existing user www-data

2.1 - Assign strong password to existing user www-data, and add it to sudoer’s group

sudo passwd www-data   
sudo adduser www-data sudo   
groups www-data   

.
2.2 - REBOOT to enable permissions for www-data

sudo reboot

.

STEP-3: Create new directory and files

3.1 - Create new directory

sudo mkdir /var/www/html/setgain   

.
3.2 - Move inside the new directory

cd /var/www/html/setgain/   

.
3.3 - Inside directory /var/www/html/setgain, create a new blank file setgain.sh, make it executable

sudo touch setgain.sh   
sudo chmod +x setgain.sh   

.
3.4 - Open newly created file in nano editor

sudo nano setgain.sh   

.
3.5 - Add code to the new file
(In code below, replace xxxxxxxxx by the actual password you have set for user www-data)

NOTE: Some of code lines are very long. Scroll Right to see these in full
.

#!/bin/bash
echo 'xxxxxxxxxx' | sudo -S sed -i '/RECEIVER_OPTIONS=.*/c\RECEIVER_OPTIONS="--device-index 0 --gain '$1' --ppm 0 --net-bo-port 30005"' /etc/default/dump1090-fa   

echo 'xxxxxxxxxx' | sudo -S systemctl restart dump1090-fa   

Save (Ctrl+o) and Close (Ctrl+x) the file.

.
3.6 - Inside directory /var/www/html/setgain, create a new blank file findgain.sh, make it executable

sudo touch findgain.sh   
sudo chmod +x findgain.sh   

.
3.7 - Open newly created file in nano editor

sudo nano findgain.sh   

.
3.8 - Add code to the new file
(In code below, replace xxxxxxxxx by the actual password you have set for user www-data)

NOTE: Some of code lines are very long. Scroll Right to see these in full
.

#!/bin/bash   
echo 'xxxxxxxxxx' | sudo -S awk '{for(i=1;i<=NF;i++) if ($i=="--gain") print $(i+1)}' /etc/default/dump1090-fa  

Save (Ctrl+o) and Close (Ctrl+x) the file.

.

STEP-4

4.1 - Create a new file gain.php in folder /usr/share/dump1090-fa/html

cd /usr/share/dump1090-fa/html/
sudo nano gain.php   

4.2 - Copy-paste following code in newly created blank file gain.php

NOTE: Some of code lines are very long. Scroll Right to see these in full
.

<html>
 <form id="myform" action="gain.php" method="post" />
  <input type="text" name="gain" id="gain" maxlength="5" size="4" value="<?php system('/var/www/html/setgain/findgain.sh');?>" />
  <input type="submit" value="Set Gain" style="color:#ffffff;background-color:#00A0E2;border-color:#00B0F0;" />
 </form>
</html>

<?php
function setgain(){
$gain="{$_POST['gain']}";
system("/var/www/html/setgain/setgain.sh $gain  >> /tmp/gain.log 2>&1");
header("Refresh:0");
}

if ("{$_POST['gain']}"){
setgain();
}
?>


.
Save (Ctrl+o) and Close (Ctrl+x)
.

STEP-5

5.1 - Next step is to edit file index.html in folder /usr/share/dump1090-fa/html.
BEFORE EDITING, make its backup copy. This will enable you to revert in case something goes wrong.

cd /usr/share/dump1090-fa/html/
sudo cp index.html index.bak.html

#Check to ensure back-up copy has been created by giving ls command

ls

#The output should contain both index.html and index.bak.html
config.js    formatter.js    layers.js         script.js
db           images          markers.js        spinny.gif
dbloader.js  index.bak.html  ol                style.css
flags.js     index.html      planeObject.js    test
flags-tiny   jquery          registrations.js  upintheair.json

.

5.2 - Open the file index.html for editing

cd /usr/share/dump1090-fa/html/  
sudo nano index.html  

5.3 - Press Ctrl+w then type buttonContainer then press Enter key.
The cursor will jump to line containg word buttonContainer, as shown below

			<div class="logoContainer">
				<a href="http://flightaware.com/" target="_blank"><img src="images/fa_logo_color.png" alt="FlightAware" class="flightawareLogo" srcset="images/fa_logo_color.png 1x, images/fa_logo_color@2x.png 2x, images/fa_logo_color@3x.png 3x"></a>
				<img src="images/pa-sv-logo.png" alt="PiAware SkyView" class="adsbLogo piAwareLogo" srcset="images/pa-sv-logo.png 1x, images/pa-sv-logo@2x.png 2x, images/pa-sv-logo@3x.png 3x">
				<img src="images/ff-sv-logo.png" alt="FlightFeeder SkyView" class="adsbLogo flightfeederLogo" srcset="images/ff-sv-logo.png 1x, images/ff-sv-logo@2x.png 2x, images/ff-sv-logo@3x.png 3x" style="display: none;">
			</div>

			<div class="buttonContainer">
				<div class="dateTime" id="clock_div"></div>
				<div class="button buttonHeader" onclick="resetMap();"><span class="buttonText">Reset Map</span></div>

.

5.4 - Just above line <div class="buttonContainer">, insert following 3 lines

<div id="GAIN" style="text-align:center;width:175px;height:65px;">   
<iframe src=gain.php style="border:0;width:175px;height:65px;"></iframe>   
</div> <!----- GAIN --->   

.
After insertion of 3 lines, the code will be like shown below:

			<div class="logoContainer">
				<a href="http://flightaware.com/" target="_blank"><img src="images/fa_logo_color.png" alt="FlightAware" class="flightawareLogo" srcset="images/fa_logo_color.png 1x, images/fa_logo_color@2x.png 2x, images/fa_logo_color@3x.png 3x"></a>
				<img src="images/pa-sv-logo.png" alt="PiAware SkyView" class="adsbLogo piAwareLogo" srcset="images/pa-sv-logo.png 1x, images/pa-sv-logo@2x.png 2x, images/pa-sv-logo@3x.png 3x">
				<img src="images/ff-sv-logo.png" alt="FlightFeeder SkyView" class="adsbLogo flightfeederLogo" srcset="images/ff-sv-logo.png 1x, images/ff-sv-logo@2x.png 2x, images/ff-sv-logo@3x.png 3x" style="display: none;">
			</div>

<div id="GAIN" style="text-align:center;width:175px;height:65px;">   
<iframe src=gain.php style="border:0;width:175px;height:65px;"></iframe>   
</div> <!----- GAIN --->   

			<div class="buttonContainer">
				<div class="dateTime" id="clock_div"></div>
				<div class="button buttonHeader" onclick="resetMap();"><span class="buttonText">Reset Map</span></div>

.
Save (Ctrl+o) and Close (Ctrl+x)
.

5.5 - Go to page IP-of-PI/dump1090-fa/ and check gain setting add-on appears as shown in screenshot below.

The value show at browser load or re-load is your current gain value.

If you want to change it, replace the value displaced by value desired and click “Set Gain” button. The value in gain box will briefly show your previous setting, then show your current (changed) setting.

Check the gain value by following command. The last line of output of this command will show the actual value of gain used.

sudo systemctl status dump1090-fa -l    

.


#4

Jessie%20and%20Stretch%20Mutab

For Raspbian Jessie/Stretch + dump1090-mutability v1.15~dev install

Only Step-1 is different for Jessie and Stretch, rest is same.

STEP-1 (JESSIE): Install necessary php packages and enable module

sudo apt-get update   
sudo apt-get install php5-cgi   
sudo lighty-enable-mod fastcgi-php   
sudo /etc/init.d/lighttpd force-reload   

.

STEP-1 (STRETCH): Install necessary php packages and enable module

sudo apt-get update   
sudo apt-get install php7.0-cgi   
sudo lighty-enable-mod fastcgi-php   
sudo /etc/init.d/lighttpd force-reload   

STEP-2: Set up existing user www-data

2.1 - Assign strong password to existing user www-data, and add it to sudoer’s group

sudo passwd www-data   
sudo adduser www-data sudo   
groups www-data   
  

2.2 - REBOOT for sudo permission of user www-data to be implemented.

sudo reboot

.

STEP-3: Create new directory and files

3.1 - Create new directory

sudo mkdir /var/www/html/setgain   

.
3.2 - Move inside the new directory

cd /var/www/html/setgain/   

.
3.3 - Inside directory /var/www/html/setgain, create a new blank file setgain.sh, make it executable

sudo touch setgain.sh   
sudo chmod +x setgain.sh   

.
3.4 - Open newly created file in nano editor

sudo nano setgain.sh   

.
3.5 - Add code to the new file
(In code below, replace xxxxxxxxx by the actual password you have set for user www-data)

NOTE: Some of code lines are very long. Scroll Right to see these in full
.

#!/bin/bash   
echo 'xxxxxxxxxx' | sudo -S sed -i '/GAIN=.*/c\GAIN='$1 /etc/default/dump1090-mutability  

echo 'xxxxxxxxxx' | sudo -S systemctl restart dump1090-mutability  

Save (Ctrl+o) and Close (Ctrl+x) the file.

.
3.6 - Inside directory /var/www/html/setgain, create a new blank file findgain.sh, make it executable

sudo touch findgain.sh   
sudo chmod +x findgain.sh   

.
3.7 - Open newly created file in nano editor

sudo nano findgain.sh   

.
3.8 - Add code to the new file
(In code below, replace xxxxxxxxx by the actual password you have set for user www-data)

NOTE: Some of code lines are very long. Scroll Right to see these in full
.

#!/bin/bash
echo 'xxxxxxxxxx' | sudo -S sed -n 's/\GAIN=//p' /etc/default/dump1090-mutability  

Save (Ctrl+o) and Close (Ctrl+x) the file.

.

STEP-4

4.1 - Create a new file gain.php in folder /usr/share/dump1090-mutability/html

cd /usr/share/dump1090-mutability/html/
sudo nano gain.php   

.
4.2 - Copy-paste following code in newly created blank file gain.php

NOTE: Some of code lines are very long. Scroll Right to see these in full
.

<html>
 <form id="myform" action="gain.php" method="post" />
  <input type="text" name="gain" id="gain" maxlength="5" size="4" value="<?php system('/var/www/html/setgain/findgain.sh');?>" />
  <input type="submit" value="Set Gain" style="color:#ffffff;background-color:#00A0E2;border-color:#00B0F0;" />
 </form>
</html>

<?php
function setgain(){
$gain="{$_POST['gain']}";
system("/var/www/html/setgain/setgain.sh $gain  >> /tmp/gain.log 2>&1");
header("Refresh:0");
}

if ("{$_POST['gain']}"){
setgain();
}
?>


Save (Ctrl+o) and Close (Ctrl+x)

STEP-5

5.1 - Next step is to edit file gmap.html in folder `/usr/share/dump1090-mutability/html.
BEFORE EDITING, make its backup copy. This will enable you to revert in case something goes wrong.

cd /usr/share/dump1090-mutability/html/
sudo cp gmap.html gmap.bak.html

#Check to ensure back-up copy has been created by giving ls command

ls

#The output should contain both gmap.html and gmap.bak.html

config.js    formatter.js   markers.js        style.css
coolclock    gain.php       ol3               test
db           gmap.bak.html  planeObject.js    upintheair.json
dbloader.js  gmap.html      registrations.js
flags.js     jquery         script.js
flags-tiny   layers.js      spinny.gif

.
5.2 - Open the file gmap.html for editing

cd /usr/share/dump1090-mutability/html/  
sudo nano gmap.html  

.
5.3 - Press Ctrl+w then type sudo_buttons then press Enter key.
The cursor will jump to line <div id="sudo_buttons">, as shown below

                                </div> <!-- timestamps -->

                                <div id="sudo_buttons">
                                        <table style="width: 100%">
                                                <tr>
                                                        <td style="width: 150px; text-align: center;" class="pointer">
                                                                [ <span onclick="resetMap();">Reset Map</span> ]
                                                        </td>
                                                </tr>
                                        </table>

                                </div> <!-- sudo_buttons -->

.
5.4 - Just above line <div id="sudo_buttons">, insert following 3 lines

<div id="GAIN" style="text-align:center;width:175px;height:65px;">   
<iframe src=gain.php style="border:0;width:175px;height:65px;"></iframe>   
</div> <!----- GAIN --->   

.

After insertion of 3 lines, the code will be like shown below:

                                </div> <!-- timestamps -->

<div id="GAIN" style="text-align:center;width:175px;height:65px;">   
<iframe src=gain.php style="border:0;width:175px;height:65px;"></iframe>   
</div> <!----- GAIN --->   


                                <div id="sudo_buttons">
                                        <table style="width: 100%">
                                                <tr>
                                                        <td style="width: 150px; text-align: center;" class="pointer">
                                                                [ <span onclick="resetMap();">Reset Map</span> ]
                                                        </td>
                                                </tr>
                                        </table>

                                </div> <!-- sudo_buttons -->

Save (Ctrl+o) and Close (Ctrl+x)
.

5.5 - Go to page IP-of-PI/dump1090/ and check gain setting add-on appears as shown in screenshot below.

The value shown at browser load or re-load is your current gain value.

If you want to change it, replace the value displayed by value desired and click “Set Gain” button. The value in gain box will briefly show your previous setting, then show your current (changed) setting.

Check the gain value by following command.

sudo systemctl status dump1090-mutability -l    

.
Following line of output of this command will show the actual value of gain used.

NOTE: Some of code lines are very long. Scroll Right to see these in full
.

CGroup: /system.slice/dump1090-mutability.service
           └─6531 /usr/bin/dump1090-mutability --net --gain 36 --ppm 0 --fix --lat xx.xx --lon yy.yy --max-range 300 --net-ri-port 30001


#5

Feedback requested.
Did gain setting in the map works ok for you?
Did you face any problems adding or using gain setting in the map?


#6

Installed on both my 1.15-dev map and on 3.5.3 map
both working and changing gain no problems


#7

@suffolk3000

Thanks for the feed-back.


#8

Hello
added in dump1090-fa’s SkyView Map
no problem
thanks


#9

@LFBDBORDEAUX
Thanks for the feedback.


#10

@abcd567 tried this this morning with an existing Raspian Jessie/Stretch package install- seems to work fine- thank you and @evangelyul for this work and great idea !

Notes on install:
I think in the Raspian Jessie/Stretch Dump1090-fa package install instructions at the end of step 5.4 the “Save (Ctrl+o) and Close (Ctrl+x) the file” step is missing, probably just trimmed off in edit.

There was one other place I cannot recall where directory navigation in the step left me in one place and the next step required a directory change that wasn’t outlined ( depending on how verbose you want to make the instructions, etc)


#11

.
Thanks for pointingt out.
Fixed now by adding “Save (Ctrl+o) and Close (Ctrl+x) the file” at the end of Step 5.4.

.

Tried, but could not find missing directory location. Was it in Raspbian Jessie/Stretch and dump1090-fa ?


#12

Yes - Sorry for not being more clear- It wasnt so much missing as I seemed to be unable to move directly to cd /usr/share/dump1090-fa/html/ at the start of Step 4 from where I was at end of Step 3.8 … but may have just been a finger-check on my part. Probably disregard.