Did this work before?
I’m not familiar with php. I’ll check your old php version.
when you do an echo 15> newgain on the shell does it work?
Did this work before?
I’m not familiar with php. I’ll check your old php version.
when you do an echo 15> newgain on the shell does it work?
You can include an
echo "Set gain to:"$line
in the script to check if it’s being read ok.
.
.
sudo apt update
sudo apt install php5-cgi
sudo lighty-enable-mod fastcgi-php
sudo /etc/init.d/lighttpd force-reload
sudo apt update
sudo apt install php7.0-cgi
sudo lighty-enable-mod fastcgi-php
sudo /etc/init.d/lighttpd force-reload
.
2.1 - Create new directory
sudo mkdir /usr/local/sbin/gain
2.2 - Create a new blank script file setgain.sh inside this new directory
sudo touch /usr/local/sbin/gain/setgain.sh
2.3 Add entry in cron to run script setgain.sh at boot
sudo crontab -e
#Scroll down and ADD following line at the end
@reboot /bin/bash /usr/local/sbin/gain/setgain.sh
Save (Ctrl+o) and Close (Ctrl+x)
.
2.4 - Open file setgain.sh to edit
sudo nano /usr/local/sbin/gain/setgain.sh
.
2.5 - Copy-paste following code in file setgain.sh
#!/bin/bash
# redirect all output and errors of this script to a log file
exec &>/usr/local/sbin/gain/log
# file that anyone can write to in order to set a new gain
fifo=/usr/local/sbin/gain/newgain
# remove $fifo so we are sure we can create our named pipe
rm -f $fifo
# create the named pipe with write access for everyone
mkfifo -m 666 $fifo
# read current gain and store in file currentgain
# script in gain.php will read gain value stored in currentgain and
# will display it on map as "Current Gain"
piaware-config -show rtlsdr-gain > /usr/local/sbin/gain/currentgain
while sleep 1
do
if ! [[ -r $fifo ]] || ! [[ -p $fifo ]]
# exit the loop/script if $fifo is not readable or not a named pipe
then break
fi
# read one line from the named pipe, remove all characters but numbers, dot, minus and newline and store it in $line
read line < <(tr -cd '.\-0123456789\n' < $fifo)
#set new gain
piaware-config rtlsdr-gain "$line"
#restart dump1090-fa to implement new gain value
systemctl restart dump1090-fa
# read updated gain and store in file currentgain
piaware-config -show rtlsdr-gain > /usr/local/sbin/gain/currentgain
# script in gain.php will read the updated gain and display it on map
done
Save (Ctrl+o) and Close (Ctrl+x) the file.
.
gain.php
containing gain button, drop-down list of gains & current gain display. This file will be embeded in SkyView Map in Step - 43.1 - Create a new file gain.php
in folder /usr/share/dump1090-fa/html
sudo nano /usr/share/dump1090-fa/html/gain.php
3.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" />
<div><font color=#ff0000 face="'Helvetica Neue', Helvetica, Arial, sans-serif">Current Gain: <?php system('cat /usr/local/sbin/gain/currentgain');?> </font></div>
<select name="gain" id="gain">
<option value=-10>-10</option>
<option value=49.6>49.6</option>
<option value=48.0>48.0</option>
<option value=44.5>44.5</option>
<option value=43.9>43.9</option>
<option value=43.4>43.4</option>
<option value=42.1>42.1</option>
<option value=40.2>40.2</option>
<option value=38.6>38.6</option>
<option value=37.2>37.2</option>
<option value=36.4>36.4</option>
<option value=33.8>33.8</option>
<option value=32.8>32.8</option>
<option value=29.7>29.7</option>
<option value=28.0>28.0</option>
<option value=25.4>25.4</option>
<option value=22.9>22.9</option>
<option value=20.7>20.7</option>
<option value=19.7>19.7</option>
<option value=16.6>16.6</option>
</select>
<input type="submit" value="Set Gain" style="color:#ffffff;background-color:#00A0E2;border-color:#00B0F0;" />
</form>
</html>
<?php
function setgain(){
$gain="{$_POST['gain']}";
system("echo $gain > /usr/local/sbin/gain/newgain");
sleep(5);
header("Refresh:0");
}
if ("{$_POST['gain']}"){
setgain();
}
?>
Save (Ctrl+o) and Close (Ctrl+x)
.
index.html
and add code to embed newly created file gain.php (the file gain.php contains “Set Gain” button & drop-down menu)..
4.1 - 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.html.orig
#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.html.orig ol style.css
flags.js index.html planeObject.js test
flags-tiny jquery registrations.js upintheair.json
.
4.2 - Open the file `index.html for editing
sudo nano /usr/share/dump1090-fa/html/index.html
4.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>
.
4.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.1 - Reboot Pi for cron to run the script setgain.sh at startup.
5.2 - After Pi has rebooted, go to page IP-of-PI/dump1090-fa/ and check gain setting add-on appears as shown in screenshot below.
The value show in Red at browser load or re-load is your current gain value.
If you want to change it, click open drop-down menu, select the desired gain and click “Set Gain” button. After about 5 seconds, the Current Gain (red) will be updated.
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
.
You can also check current gain by following command
sudo piaware-config -show rtlsdr-gain
.
.
CLICK ON IMAGE TO SEE LARGER SIZE
setgain.sh
script is written by @wiedehopf. This original script is for Piaware SD card image. Necessary modifications in this script were made by @abcd567 to adopt it for dump1090-fa package install..
.
sudo apt update
sudo apt install php5-cgi
sudo lighty-enable-mod fastcgi-php
sudo /etc/init.d/lighttpd force-reload
sudo apt update
sudo apt install php7.0-cgi
sudo lighty-enable-mod fastcgi-php
sudo /etc/init.d/lighttpd force-reload
.
2.1 - Create new directory
sudo mkdir /usr/local/sbin/gain
2.2 - Create a new blank script file setgain.sh inside this new directory
sudo touch /usr/local/sbin/gain/setgain.sh
2.3 Add entry in cron to run script setgain.sh at boot
sudo crontab -e
#Scroll down and ADD following line at the end
@reboot /bin/bash /usr/local/sbin/gain/setgain.sh
Save (Ctrl+o) and Close (Ctrl+x)
.
2.4 - Open file setgain.sh to edit
sudo nano /usr/local/sbin/gain/setgain.sh
.
2.5 - Copy-paste following code in file setgain.sh
#!/bin/bash
# redirect all output and errors of this script to a log file
exec &>/usr/local/sbin/gain/log
# file that anyone can write to in order to set a new gain
fifo=/usr/local/sbin/gain/newgain
# remove $fifo so we are sure we can create our named pipe
rm -f $fifo
# create the named pipe with write access for everyone
mkfifo -m 666 $fifo
# read current gain and store in file currentgain
# script in gain.php will read gain value stored in currentgain and
# will display it on map as "Current Gain"
awk '{for(i=1;i<=NF;i++) if ($i=="--gain") print $(i+1)}' /etc/default/dump1090-fa > /usr/local/sbin/gain/currentgain
while sleep 1
do
if ! [[ -r $fifo ]] || ! [[ -p $fifo ]]
# exit the loop/script if $fifo is not readable or not a named pipe
then break
fi
# read one line from the named pipe, remove all characters but numbers, dot, minus and newline and store it in $line
read line < <(tr -cd '.\-0123456789\n' < $fifo)
#set new gain
sed -i '/RECEIVER_OPTIONS=.*/c\RECEIVER_OPTIONS="--device-index 0 --gain '$line' --ppm 0 --net-bo-port 30005"' /etc/default/dump1090-fa
#restart dump1090-fa to implement new gain value
systemctl restart dump1090-fa
# read updated gain and store in file currentgain
awk '{for(i=1;i<=NF;i++) if ($i=="--gain") print $(i+1)}' /etc/default/dump1090-fa > /usr/local/sbin/gain/currentgain
# script in gain.php will read the updated gain and display it on map
done
Save (Ctrl+o) and Close (Ctrl+x) the file.
.
gain.php
containing gain button, drop-down list of gains & current gain display. This file will be embeded in SkyView Map in Step - 4.
3.1 - Create a new file gain.php
in folder /usr/share/dump1090-fa/html
sudo nano /usr/share/dump1090-fa/html/gain.php
3.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" />
<div><font color=#ff0000 face="'Helvetica Neue', Helvetica, Arial, sans-serif">Current Gain: <?php system('cat /usr/local/sbin/gain/currentgain');?> </font></div>
<select name="gain" id="gain">
<option value=-10>-10</option>
<option value=49.6>49.6</option>
<option value=48.0>48.0</option>
<option value=44.5>44.5</option>
<option value=43.9>43.9</option>
<option value=43.4>43.4</option>
<option value=42.1>42.1</option>
<option value=40.2>40.2</option>
<option value=38.6>38.6</option>
<option value=37.2>37.2</option>
<option value=36.4>36.4</option>
<option value=33.8>33.8</option>
<option value=32.8>32.8</option>
<option value=29.7>29.7</option>
<option value=28.0>28.0</option>
<option value=25.4>25.4</option>
<option value=22.9>22.9</option>
<option value=20.7>20.7</option>
<option value=19.7>19.7</option>
<option value=16.6>16.6</option>
</select>
<input type="submit" value="Set Gain" style="color:#ffffff;background-color:#00A0E2;border-color:#00B0F0;" />
</form>
</html>
<?php
function setgain(){
$gain="{$_POST['gain']}";
system("echo $gain > /usr/local/sbin/gain/newgain");
sleep(5);
header("Refresh:0");
}
if ("{$_POST['gain']}"){
setgain();
}
?>
Save (Ctrl+o) and Close (Ctrl+x)
.
index.html
and add code to embed newly created file gain.php (the file gain.php contains “Set Gain” button & drop-down menu)..
4.1 - 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.html.orig
#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.html.orig ol style.css
flags.js index.html planeObject.js test
flags-tiny jquery registrations.js upintheair.json
.
4.2 - Open the file `index.html for editing
sudo nano /usr/share/dump1090-fa/html/index.html
4.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>
.
4.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.1 - Reboot Pi for cron to run the script setgain.sh at startup.
5.2 - After Pi has rebooted, go to page IP-of-PI/dump1090-fa/ and check gain setting add-on appears as shown in screenshot below.
The value show in Red at browser load or re-load is your current gain value.
If you want to change it, click open drop-down menu, select the desired gain and click “Set Gain” button. After about 5 seconds, the Current Gain (red) will be updated.
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
.
You can also check current gain by following command
cat /etc/default/dump1090-fa
.
.
CLICK ON IMAGE TO SEE LARGER SIZE
setgain.sh
script is written by @wiedehopf. This original script is for Piaware SD card image. Necessary modifications in this script were made by @abcd567 to adopt it for dump1090-mutability package install..
.
sudo apt update
sudo apt install php5-cgi
sudo lighty-enable-mod fastcgi-php
sudo /etc/init.d/lighttpd force-reload
sudo apt update
sudo apt install php7.0-cgi
sudo lighty-enable-mod fastcgi-php
sudo /etc/init.d/lighttpd force-reload
.
2.1 - Create new directory
sudo mkdir /usr/local/sbin/gain
2.2 - Create a new blank script file setgain.sh inside this new directory
sudo touch /usr/local/sbin/gain/setgain.sh
2.3 Add entry in cron to run script setgain.sh at boot
sudo crontab -e
#Scroll down and ADD following line at the end
@reboot /bin/bash /usr/local/sbin/gain/setgain.sh
Save (Ctrl+o) and Close (Ctrl+x)
.
2.4 - Open file setgain.sh to edit
sudo nano /usr/local/sbin/gain/setgain.sh
.
2.5 - Copy-paste following code in file setgain.sh
#!/bin/bash
# redirect all output and errors of this script to a log file
exec &>/usr/local/sbin/gain/log
# file that anyone can write to in order to set a new gain
fifo=/usr/local/sbin/gain/newgain
# remove $fifo so we are sure we can create our named pipe
rm -f $fifo
# create the named pipe with write access for everyone
mkfifo -m 666 $fifo
# read current gain and store in file currentgain
# script in gain.php will read gain value stored in currentgain and
# will display it on map as "Current Gain"
sed -n 's/\GAIN=//p' /etc/default/dump1090-mutability > /usr/local/sbin/gain/currentgain
while sleep 1
do
if ! [[ -r $fifo ]] || ! [[ -p $fifo ]]
# exit the loop/script if $fifo is not readable or not a named pipe
then break
fi
# read one line from the named pipe, remove all characters but numbers, dot, minus and newline and store it in $line
read line < <(tr -cd '.\-0123456789\n' < $fifo)
#set new gain
sed -i '/GAIN=.*/c\GAIN='$line /etc/default/dump1090-mutability
#restart dump1090-mutability to implement new gain value
systemctl restart dump1090-mutability
# read updated gain and store in file currentgain
sed -n 's/\GAIN=//p' /etc/default/dump1090-mutability > /usr/local/sbin/gain/currentgain
# script in gain.php will read the updated gain and display it on map
done
Save (Ctrl+o) and Close (Ctrl+x) the file.
.
gain.php
containing gain button, drop-down list of gains & current gain display. This file will be embedded in dump1090 Map in Step - 4.
3.1 - Create a new file gain.php
in folder /usr/share/dump1090-mutability/html
sudo nano /usr/share/dump1090-mutability/html/gain.php
3.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" />
<div><font color=#ff0000 face="'Helvetica Neue', Helvetica, Arial, sans-serif">Current Gain: <?php system('cat /usr/local/sbin/gain/currentgain');?> </font></div>
<select name="gain" id="gain">
<option value=-10>-10</option>
<option value=49.6>49.6</option>
<option value=48.0>48.0</option>
<option value=44.5>44.5</option>
<option value=43.9>43.9</option>
<option value=43.4>43.4</option>
<option value=42.1>42.1</option>
<option value=40.2>40.2</option>
<option value=38.6>38.6</option>
<option value=37.2>37.2</option>
<option value=36.4>36.4</option>
<option value=33.8>33.8</option>
<option value=32.8>32.8</option>
<option value=29.7>29.7</option>
<option value=28.0>28.0</option>
<option value=25.4>25.4</option>
<option value=22.9>22.9</option>
<option value=20.7>20.7</option>
<option value=19.7>19.7</option>
<option value=16.6>16.6</option>
</select>
<input type="submit" value="Set Gain" style="color:#ffffff;background-color:#00A0E2;border-color:#00B0F0;" />
</form>
</html>
<?php
function setgain(){
$gain="{$_POST['gain']}";
system("echo $gain > /usr/local/sbin/gain/newgain");
sleep(5);
header("Refresh:0");
}
if ("{$_POST['gain']}"){
setgain();
}
?>
Save (Ctrl+o) and Close (Ctrl+x)
.
gmap.html
and add code to embed newly created file gain.php (the file gain.php contains “Set Gain” button & drop-down menu)..
4.1 - 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.html.orig
#Check to ensure back-up copy has been created by giving ls command
ls
#The output should contain both gmap.html and gmap.html.orig
config.js formatter.js markers.js style.css
coolclock gain.php ol3 test
db gmap.html.orig planeObject.js upintheair.json
dbloader.js gmap.html registrations.js
flags.js jquery script.js
flags-tiny layers.js spinny.gif
.
4.2 - Open the file gmap.html
for editing
cd /usr/share/dump1090-mutability/html/
sudo nano gmap.html
.
4.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.1 - Reboot Pi for cron to run the script setgain.sh at startup.
5.2 - After Pi has rebooted, go to page IP-of-PI/dump1090-fa/ and check gain setting add-on appears as shown in screenshot below.
The value show in Red at browser load or re-load is your current gain value.
If you want to change it, click open drop-down menu, select the desired gain and click “Set Gain” button. After about 5 seconds, the Current Gain (red) will be updated.
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-mutability -l
.
You can also check current gain by following command
cat /etc/default/dump1090-mutability
.
.
CLICK ON IMAGE TO SEE LARGER SIZE
Great work as always!
Does it have @obj ‘seal of approval’ to be added to the FA image?
He already said he doesn’t want to open this can of worms. And that’s a valid point.
If he were to implement it, the shell script would not be necessary and the piaware service would just do the part that requires root.
What i can imagine is implementing the feature on the stations stats page where currently you already get a log from piaware. Also that would only work for the sd-card images as the gain is set via piaware.
I know! My half jokingly question was based on the expectation that the initial concerns were addressed, were they not?
Again, I’m not sure what is involved and the consequences, but this would be fine, even better perhaps.
Anyways, don’t worry, be happy.
@Dxista Ah i’m sorry i missed your red cheeks
@abcd567
Do you need to do anything to get the php part to work? Regarding user stuff?
I guess you should not which is great
Changing permissions on the currentgain file is not needed i just checked it works just fine in /usr/local/sbin as well. Also i’m not sure why you duplicated reading the gain but it’s not really important i guess. It was being done first thing in the loop so before any gain was changed. And after the gain is changed the loop goes around and reads the gain again.
If you don’t want the additional 1 second wait (sleep 1) you can change it to:
while true
and put the sleep 1 above read line and below reading the gain.
Only advantage would be that reading the gain is only at one point in the script.
(And if you were to edit the code you only have to modify one place and can’t forget the other, but for the end-user that is a non-issue. I just like to keep things tidy if possible )
Changing back www-data to the former state should be:
sudo deluser www-data sudo # remove user www-data from sudo group
sudo passwd -d www-data # removes the password for user www-data disabling remote login
For PHP no user permissions needed. Installing package php7.0-cgi
and then enabling module fastcgi-php
enables php.
Ok, I will test it by commenting it out, and if ok, I will edit the “How-to”.
After boot, “Current Gain” showed either blank or an old value. I added the first one to read gain at boot and save it in “currentgain”, before web page loads, so that when web page is loaded, “Current Gain” value is not blank or outdated. Second time it is read only when the gain is changed by drop-down. Anyway I will try again to see if I can manage with only one gain reading.
Thanks for the tip. I have already done that.
That’s strange. After boot it should have just entered the loop, read the gain and saved it to the file.
Not sure what is different having it outside the loop
Anyway it’s just to keep it nice and compact, great work putting it all together!
By the way what editor do you get on a standard image when using sudo crontab -e
?
(Might mention ctrl-o and ctrl-x if it’s nano)
there are many choices given first time command crontab -e
is given. I selected nano.
that is why I mention Save (Ctrl+o) and Close (Ctrl+x)
Yeah the ctrl-o and ctrl-x are mentioned for the other editor uses in your how-to but not for the crontab case or i may be blind
That’s why i though you might want to add it.
Also mentioning they should chose nano can’t hurt to keep the how-to consistent.
If someone likes vim and follows the how-to he will ignore the how-to anyway.
.
Following lines deleted
# make sure it's readable for everyone
chmod 644 /var/html/setgain/currentgain
.
.
crontab -e
: Ctrl+o and Ctrl+x added
Is it needed to put the execution bit on the setgain.sh ?
I did it to be sure.
I have still the problem when changing the gain in this way the process ppup1090 give 100% cpu in transaction “TOP”
can you manually restart dump1090-fa, to verify that is what’s causing the problem?
sudo systemctl restart dump1090-fa
But i’m pretty sure that’s the problem because ppup1090 can’t “see” anything else but dump1090 restarting.
How do you start ppup1090? Is it a service? In that case you can just restart it after dump1090 i guess. (which could be put in the script after the dump1090 restart)
edit: Execution bit on setgain.sh is not needed as you execute /bin/bash and that reads/interpretes the setgain.sh bashscript. If you were to execute it directly it would be a different story.
edit2: I don’t know of a better solution than just restarting ppup1090 as i’m not familiar with the code and even then finding the bug that causes the high cpu usage might not be that easy to find
Hi,
indeed “sudo systemctl restart dump1090-fa” puts ppup1090 to 100%
It was installed accroding to : How-to Feed Plane Plotter Site directly from Raspberry Pi
edit : do I have to recompile it (ppup1090) ? I have the impression when I did the “gain-test” with the python script I had no such problem (I say clearly : impression )
Have you checked the log file?
Just recompiling without changing the code is unlikely to change anything
As you don’t change gain too often i would just suggest the following:
sudo nano /usr/local/sbin/gain/setgain.sh
And change it by adding the last line in this snippet:
#restart dump1090-mutability to implement new gain value
systemctl restart dump1090-mutability
pkill ppup1090
Now this will just end the ppup1090 process and the script that starts ppup1090 will restart it after waiting 30 seconds.
This is not a very elegant solution but as i said i don’t expect you to change gain all the time
I just now compiled ppup1090
on Stretch image as per the method I have posted in thread How-to Feed Plane Plotter Site directly from Raspberry Pi
It’s normal CPU usage shown on top
is less than 2%, but when I restarted dump1090-mutability, top
started showing CPU usage 100%. The Performance Graphs show a jump in overall CPU usage from 15% to 35%.
After seeing this, I commented out line /home/pi/ppup/ppup-maint.sh &
in file /etc/rc.local
and rebooted Pi. The ppup1090
is no more running now.
EDIT:
The restart of dump1090-mutability was done manually by command sudo systemctl restart dump1090-mutability
, and after observing its effect in top
, command sudo pkill ppup1090
was issued. When ppup1090
restarted automatically after few seconds, the CPU usage returned to normal 2%
I also tested this by selecting a different gain value from drop-down list, then clicking “Set Gain” button. Result were same as with manual restart.
@abcd567
@wiedehopf
Thanks for the suggestions, I have the same observation as abcd567 and indeed wiedehopf, it’s not my intention to change the gain a lot.