Set Gain from Browser

thanks, everything works now.
and had to manually alter sudoers as before.

now if i use 192.168.1.xxx/ I get this (maybe due to no server ?)

how do I get the graphs ?

Hi @abcd567,

Great work!

I was thinking…yes, run for cover…:grinning:

Would you be so kind to create an image with dump1090, any flavor, no feeders pre-installed, no graphs, no other bells and whistles, just the basic ads-b decoder?

I have followed your detailed instructions to install mutability, it works great, but too much work to re-install after experiments and/or failures.

Configuration in a single TXT file in the root directory, would be nice as well.

Thanks in advance for thinking about it.:wink:

.

If web portal is not installed, then the lighttpd “Placeholder page” at IP-OF-PI (without port number) is normal.

.

.

Use JProchazk’s script. Graphs are included in Web Portal. Keep saying NO to all options offered till option to install Web Portal is offered. Accept it and graphs will be installed.

IP-OF-PI/graphs.php

thanks again :smile:

I have never created an image, and I dont even know how to create an image. I am sorry I cannot help you in this regard.

To make things easy, after burning OS (Raspbian, Armbian, etc), run JProchazka’s script and accept option for dump1090-mutability, and say no to rest, and you get what you are aiming at.

To un install dump1090-mutability:

sudo dpkg --purge dump1090-mutability

sudo rm -rf /usr/share/dump1090-mutability

Good idea…that should do it.

At one point I was thinking if it was possible to stop Piaware, an let dump1090-fa run solo.

Nothing ‘personal’, FA. :smiley: The main station will continue to feed you. This is for testing, and experimentation only.

Thanks.

(1) If you have already installed Piaware + dump1090-fa

sudo systemctl stop piaware

(2) If you have burned microSD card with Raspbian, and have NOT installed anything else, install only dump1090-fa

Note: Most likely wont install on OS Armbian/OrangePi/Odroid. Only on RPi/Raspbian.

wget http://flightaware.com/adsb/piaware/files/packages/pool/piaware/p/piaware-support/piaware-repository_3.5.3_all.deb sudo dpkg -i piaware-repository_3.5.3_all.deb

sudo dpkg -i piaware-repository_3.5.3_all.deb

sudo apt-get update

sudo apt-get install dump1090-fa

sudo reboot

For 1), This would have to be done after every reboot, I think, but I have not tried it.

For 2), I did think about it, but the sudo dpkg line gave me the impression that it would still install everything.

Need to try.

Thanks.

Yes, after every reboot, as at boot piaware and dump1090-fa are re-started.

Alternatively, purge piaware (method untested)

sudo dpkg --purge piaware  

Thought about that as well, but wondered if it would delete needed dependencies.

As you can see, I’m being more theoretical than practical.:smiley:

Off-topic: For those in the market for RPis, Arrow Electronics has a good deal on right now.

https://www.arrow.com/en/popular-raspberry-pi-products

Experimenting is fun. My approach is: try anything you want. Succeeded, good. Broken the install, my friends Win32diskimager/etcher are alwas there to help :slight_smile:

Indeed!

I need another Pi and SD card, maybe a Zero W this time around.

I think it is easy and you can do it. It is a one time effort, and good if you need repeated fresh installs.

  1. Write OS (Raspbian, Armbian etc) to your microSD card

  2. If you want dump1090-mutability, install it by JProchazka’s script. If you Want dump1090-fa do NOT use JP’s script, as it will force install Piaware also. Instead use package install by method in item (2) of my post above.

  3. Once you have tested above install, and are satisfied, make a backup copy of image and save on your Windows/Mac computer as shown in the web page linked below. When your install breaks, simply burn microSD card from the saved image, and it will have OS + dump1090 pre-installed.

  4. Please see this web page and youtube video:
    https://thepi.io/how-to-back-up-your-raspberry-pi/amp/
    https://www.youtube.com/watch?v=VOT4f2Wd340

1 Like

Thanks @abcd567.

Need to buy SD cards.

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: Assign strong password to user www-data, and add it to sudoer’s group

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

.
REBOOT to enable permissions for www-data

sudo reboot

.

STEP-3: Create new directory and files

(a) Create new directory

sudo mkdir /var/www/html/setgain   

(b) Move inside the new directory

cd /var/www/html/setgain/   

(c ) 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   

(d) Open newly created file in nano editor

sudo nano setgain.sh   

(e) 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 '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.
.

(f) 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   

(g) Open newly created file in nano editor

sudo nano findgain.sh   

(h) 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 '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.
.

(i) Inside directory /var/www/html/setgain, create new php file

sudo nano index.php

(j) Copy-paste following code in it

<?php
echo <<<HTML
 <form id="myform" name="myform" action="{$_SERVER['PHP_SELF']}" method="post" />
    ENTER GAIN VALUE: <input type="text" id="gain" name="gain" value="-10" />
    <input type="submit" name="submit" value="Click to Set Gain" />
 </form>
HTML;

echo "Your gain was = ";
system("/var/www/html/setgain/findgain.sh");
?>
<BR>
<?php
function setgain(){
$_SERVER['PHP_SELF'];
$gain="{$_POST['gain']}";
echo "You changed gain to = $gain";
system("/var/www/html/setgain/setgain.sh $gain  >> /tmp/gain.log 2>&1");
}

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

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

.

STEP-4: Load the gain setting file in browser of Win/Mac computer, and set gain.

IP-OF-PI/setgain/

STEP-5: Check if the gain change has actually taken place

(a) Check gain changed or not, and what is its current value

sudo systemctl status dump1090-fa -l  

grep -oP "(?<=--gain )[^ ]+" /etc/default/dump1090-fa  
  

.
(b) Check for error messages

cat /tmp/gain.log  

.

2 Likes

@evangelyul
There was a bug in the code for setgain.php file, which caused gain to set to null when page IP/setgain/index.php was loaded. If after page load you check gain (sudo piaware-config -show rtlsdr-gain OR cat /etc/default/dump1090-mutability OR cat /etc/default/dump1090-fa, as the case may be) you will see following:

GAIN=
instead of
GAIN=xx

OR

--gain
instead of
--gain xx

I have now removed that bug, and posted updated code. Please replace the code in file setgain.php by the updated one.

thank you very much abcd567
works well now :smile:

made couple of modifications

-in step 2 after adding user www-data, I run following as suggested by member xlr99
as I had problems with permissions.

-in index.php replaced cuurent with current and
changed name of a.txt to errgain.txt
also since findgain.sh returns a string, moified line
Your gain was to Your gain string was.

-replaced /etc/sudoers to original, removing manual entry
www-data ALL=(ALL:ALL) ALL.

tried on pi running jessie with dump1090-mutability build with your
instructions and on a VM pi running stretch with dump1090-mutability Joe’s setup.

setgain-1

1 Like

I NEVER faced this problem with any of the different types of installs. I dont know why you face it. May be using root instead of pi OR changing hostname from raspberrypi to something else caused this issue for you??

.

.
Thanks for pointing out the typo.

I have earlier found that variable $cuurentgain is not required, as it is not used anywhere.

Even without assigning this variable to output of the command system("blah blah blah");, the command echoes its output to the gain setting’s page index.php.

Actually I wanted to remove this variable, but forgot. Good that your comment reminded me. I will now make change as follows:

Existing Line in index.php:
$cuurentgain = system("/var/www/html/setgain/findgain.sh");

Modified line in index.php:
system("/var/www/html/setgain/findgain.sh");

.

.
Thanks for suggestion. The file name a.txt does not show what it is and needed to be changed.

The name errgain.txt you used is better than a.txt, but is still incomplete because both the stdout AND stderr are recorded in this file (>> /tmp/a.txt 2>&1"). I will now change it to a still better name gain.log which is more meaningful.

I thought of placing this file in /var/log directory, but keeping it in /tmp` directory has advantage of getting the file automatically emptied at reboot.

Successfully Embeded “Set Gain” in SkyView Map

dump1090-fa on Stretch x86 (running in Oracle VM on Windows Desktop).
Working well. Initially on loading the SkyView page, the text field displays current gain setting. To change gain, change gain value in text field and click “Set Gain” Button. When gain change has taken effect, the text field changes and displays newly set gain.

I have to test it on RPi
Will do this weekend.

.

2 Likes

great ! next try to replace text box to to a drop-down list (thus restricting user to proper values)
it ll be nice if gains could be added dynamically, say, from rtl_test -t output or something, or
standard preset values.
jolly good progress abcd567 :smiley: