You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
535 lines
11 KiB
535 lines
11 KiB
#!/bin/bash
|
|
|
|
echo "CubeSatSim v1.3b configuration tool"
|
|
echo
|
|
|
|
if [ "$2" = "-n" ]; then
|
|
norestart=1
|
|
else
|
|
norestart=0
|
|
fi
|
|
|
|
if [ "$1" = "" ]; then
|
|
value=`cat /home/pi/CubeSatSim/.mode`
|
|
echo "$value" > /dev/null
|
|
set -- $value
|
|
|
|
if [ "$1" = "a" ]; then
|
|
echo "APRS mode is set"
|
|
elif [ "$1" = "m" ]; then
|
|
echo "CW mode is set"
|
|
elif [ "$1" = "f" ]; then
|
|
echo "FSK mode is set"
|
|
elif [ "$1" = "b" ]; then
|
|
echo "BPSK mode is set"
|
|
elif [ "$1" = "s" ]; then
|
|
echo "SSTV mode is set"
|
|
else
|
|
echo
|
|
fi
|
|
echo
|
|
value=`cat /home/pi/CubeSatSim/sim.cfg`
|
|
echo "$value" > /dev/null
|
|
set -- $value
|
|
|
|
if [ "$5" = "y" ] || [ "$5" = "yes" ] ; then
|
|
# sim="yes"
|
|
echo "Simulated Telemetry is ON"
|
|
else
|
|
# sim="no"
|
|
echo "Simulated Telemetry is OFF"
|
|
fi
|
|
|
|
echo
|
|
echo "Current command count is:"
|
|
cat /home/pi/CubeSatSim/command_count.txt
|
|
echo
|
|
echo
|
|
echo "Current beacon transmit mode is:"
|
|
cat /home/pi/CubeSatSim/command_tx
|
|
echo
|
|
|
|
echo "Squelch level is:"
|
|
echo $6
|
|
echo
|
|
echo -e "Current sim.cfg configuration file:"
|
|
echo
|
|
|
|
echo $1 $2 $3 $4 $5 $6 $7 $8
|
|
echo
|
|
|
|
echo "To change, include an OPTION"
|
|
echo "To see options, type config -h"
|
|
# echo
|
|
# set -- "-h"
|
|
fi
|
|
|
|
|
|
if [ "$1" = "-i" ]; then
|
|
echo "Restarting CubeSatSim"
|
|
sudo systemctl restart cubesatsim
|
|
exit
|
|
elif [ "$1" = "-a" ]; then
|
|
echo "changing CubeSatSim to AFSK mode"
|
|
sudo echo "a" > /home/pi/CubeSatSim/.mode
|
|
sudo sed -i ':a;N;$!ba;s/\nforce_turbo=1//g' /boot/config.txt
|
|
echo "rebooting"
|
|
sudo reboot now
|
|
# sudo systemctl restart cubesatsim
|
|
exit
|
|
elif [ "$1" = "-m" ]; then
|
|
echo "changing CubeSatSim to CW mode"
|
|
sudo echo "m" > /home/pi/CubeSatSim/.mode
|
|
sudo sed -i ':a;N;$!ba;s/\nforce_turbo=1//g' /boot/config.txt
|
|
echo "rebooting"
|
|
sudo reboot now
|
|
# sudo systemctl restart cubesatsim
|
|
exit
|
|
elif [ "$1" = "-f" ]; then
|
|
echo "changing CubeSatSim to FSK mode"
|
|
sudo echo "f" > /home/pi/CubeSatSim/.mode
|
|
if ! grep -q force_turbo=1 /boot/config.txt ; then sudo sh -c 'echo "force_turbo=1" >> /boot/config.txt'; fi
|
|
echo "rebooting"
|
|
sudo reboot now
|
|
# sudo systemctl restart cubesatsim
|
|
exit
|
|
elif [ "$1" = "-b" ]; then
|
|
echo "changing CubeSatSim to BPSK mode"
|
|
sudo echo "b" > /home/pi/CubeSatSim/.mode
|
|
if ! grep -q force_turbo=1 /boot/config.txt ; then sudo sh -c 'echo "force_turbo=1" >> /boot/config.txt'; fi
|
|
echo "rebooting"
|
|
sudo reboot now
|
|
# sudo systemctl restart cubesatsim
|
|
exit
|
|
elif [ "$1" = "-s" ]; then
|
|
echo "changing CubeSatSim to SSTV mode"
|
|
sudo echo "s" > /home/pi/CubeSatSim/.mode
|
|
sudo sed -i ':a;N;$!ba;s/\nforce_turbo=1//g' /boot/config.txt
|
|
echo "rebooting"
|
|
sudo reboot now
|
|
# sudo systemctl restart cubesatsim
|
|
exit
|
|
elif [ "$1" = "-h" ]; then
|
|
echo "config OPTION"
|
|
echo
|
|
echo "Changes CubeSatSim mode, resets, or modifies configuration file"
|
|
echo
|
|
echo " -h This help info"
|
|
echo " -a Change to AFSK/APRS mode"
|
|
echo " -m Change to CW mode"
|
|
echo " -f Change to FSK/DUV mode"
|
|
echo " -b Change to BPSK mode"
|
|
echo " -s Change to SSTV mode"
|
|
echo " -i Restarts CubeSatsim software"
|
|
echo " -c Change the CALLSIGN in the configuration file sim.cfg"
|
|
echo " -t Change the Simulated Telemetry setting in sim.cfg"
|
|
echo " -r Change the Resets Count in the configuration file sim.cfg"
|
|
echo " -l Change the Latitude and Longitude in the configuration file sim.cfg"
|
|
echo " -S Scan both I2C buses on the Raspberry Pi"
|
|
echo " -C Clear logs"
|
|
echo " -T Change command state"
|
|
echo " -R Change the Commands Count in the file command_count.txt"
|
|
echo " -q Change the Squelch setting for command receiver"
|
|
echo " -F Change the rx and tx frequency"
|
|
echo
|
|
exit
|
|
|
|
elif [ "$1" = "-t" ]; then
|
|
|
|
echo
|
|
echo "Editing the Simulated Telemetry setting in"
|
|
echo "the configuration file for CubeSatSim"
|
|
echo
|
|
|
|
value=`cat /home/pi/CubeSatSim/sim.cfg`
|
|
echo "$value" > /dev/null
|
|
set -- $value
|
|
|
|
if [ "$5" = "yes" ] || [ "$5" = "y" ]; then
|
|
echo "Simualted Telemetry is ON"
|
|
else
|
|
echo "Simualted Telemetry is OFF"
|
|
fi
|
|
|
|
echo
|
|
|
|
# echo $1 $2 $3 $4 $5 $6 $7 $8
|
|
|
|
echo "Do you want Simulated Telemetry ON (y/n) "
|
|
read sim
|
|
echo
|
|
|
|
if [ "$sim" = "y" ] || [ "$sim" = "yes" ] ; then
|
|
sim="yes"
|
|
echo "Simulated Telemetry is ON"
|
|
else
|
|
sim="no"
|
|
echo "Simulated Telemetry is OFF"
|
|
fi
|
|
|
|
echo
|
|
echo -e "\nCubeSatSim configuraation sim.cfg file updated to: \n"
|
|
echo
|
|
echo $1 $2 $3 $4 $sim $6 $7 $8
|
|
echo $1 $2 $3 $4 $sim $6 $7 $8 > /home/pi/CubeSatSim/sim.cfg
|
|
echo
|
|
echo "Restarting CubeSatSim with new configuraation file"
|
|
echo
|
|
|
|
sudo systemctl restart cubesatsim
|
|
|
|
elif [ "$1" = "-c" ]; then
|
|
|
|
echo
|
|
echo "Editing the CALLSIGN in the"
|
|
echo "configuration file for CubeSatSim"
|
|
echo
|
|
echo "Return keeps current value."
|
|
# echo -e "Current sim.cfg configuration file:"
|
|
# echo
|
|
|
|
value=`cat /home/pi/CubeSatSim/sim.cfg`
|
|
echo "$value" > /dev/null
|
|
set -- $value
|
|
|
|
echo "Current value of CALLSIGN is"
|
|
echo $1
|
|
echo
|
|
|
|
# echo $1 $2 $3 $4 $5 $6 $7 $8
|
|
|
|
echo "Enter callsign in all capitals: "
|
|
read callsign
|
|
|
|
if [ -z $callsign ] ; then
|
|
|
|
callsign="$1"
|
|
echo "Keeping value of" $callsign
|
|
norestart=1
|
|
else
|
|
|
|
echo -e "\nCubeSatSim configuraation sim.cfg file updated to: \n"
|
|
|
|
echo $callsign $2 $3 $4 $5 $6 $7 $8
|
|
echo $callsign $2 $3 $4 $5 $6 $7 $8 > /home/pi/CubeSatSim/sim.cfg
|
|
fi
|
|
|
|
if [ "$norestart" = "1" ]; then
|
|
echo
|
|
else
|
|
echo
|
|
echo "Restarting CubeSatSim with new configuraation file"
|
|
echo
|
|
sudo systemctl restart cubesatsim
|
|
fi
|
|
|
|
elif [ "$1" = "-r" ]; then
|
|
|
|
echo
|
|
echo "Editing the Reset Count in the"
|
|
echo "configuration file for CubeSatSim"
|
|
echo
|
|
echo "Return keeps current value."
|
|
# echo -e "Current sim.cfg configuration file:"
|
|
# echo
|
|
|
|
value=`cat /home/pi/CubeSatSim/sim.cfg`
|
|
echo "$value" > /dev/null
|
|
set -- $value
|
|
|
|
echo
|
|
echo "Current value of Reset Count is"
|
|
echo $2
|
|
echo
|
|
|
|
# echo $1 $2 $3 $4 $5 $6 $7 $8
|
|
|
|
echo -e "Enter Reset Count (integer): "
|
|
|
|
read resets
|
|
|
|
if [ -z $resets ] ; then
|
|
resets="$2"
|
|
echo "Keeping value of" $resets
|
|
fi
|
|
|
|
if ! [[ $resets =~ ^[0-9]+$ ]] ; then
|
|
echo "Error: not an integer!"
|
|
resets="$2"
|
|
echo "Keeping value of" $resets
|
|
norestart=1
|
|
else
|
|
|
|
echo -e "\nCubeSatSim configuraation sim.cfg file updated to: \n"
|
|
|
|
echo $1 $resets $3 $4 $5 $6 $7 $8
|
|
echo $1 $resets $3 $4 $5 $6 $7 $8 > /home/pi/CubeSatSim/sim.cfg
|
|
fi
|
|
|
|
if [ "$norestart" = "1" ]; then
|
|
echo
|
|
else
|
|
echo
|
|
echo "Restarting CubeSatSim with new configuraation file"
|
|
echo
|
|
sudo systemctl restart cubesatsim
|
|
fi
|
|
|
|
elif [ "$1" = "-l" ]; then
|
|
|
|
echo
|
|
echo "Editing latitude and longitude in the"
|
|
echo "configuration file for CubeSatSim"
|
|
echo "(Only used for APRS telemetry)"
|
|
echo
|
|
echo "Return keeps current value."
|
|
# echo -e "Current sim.cfg configuration file:"
|
|
# echo
|
|
|
|
value=`cat /home/pi/CubeSatSim/sim.cfg`
|
|
echo "$value" > /dev/null
|
|
set -- $value
|
|
|
|
echo
|
|
echo "Current value of latitude is"
|
|
echo $3
|
|
echo
|
|
|
|
# echo $1 $2 $3 $4 $5 $6 $7 $8
|
|
|
|
echo -e "Enter latitude (decimal degrees, positive is north): "
|
|
|
|
read lat
|
|
|
|
if [ -z $lat ] ; then
|
|
|
|
lat="$3"
|
|
echo "Keeping value of" $lat
|
|
fi
|
|
|
|
if ! [[ $lat =~ ^[+-]?[0-9]+([.][0-9]+)?$ ]] ; then
|
|
|
|
echo "Error: not a number!"
|
|
lat="$3"
|
|
echo "Keeping value of" $lat
|
|
fi
|
|
|
|
echo
|
|
echo "Current value of longitude is"
|
|
echo $4
|
|
echo
|
|
|
|
echo -e "Enter longitude (decimal degrees, positive is east): "
|
|
|
|
read long
|
|
|
|
if [ -z $long ] ; then
|
|
|
|
long="$4"
|
|
echo "Keeping value of" $long
|
|
fi
|
|
|
|
if ! [[ $long =~ ^[+-]?[0-9]+([.][0-9]+)?$ ]] ; then
|
|
|
|
echo "Error: not a number!"
|
|
long="$4"
|
|
echo "Keeping value of" $long
|
|
fi
|
|
|
|
echo -e "\nCubeSatSim configuraation sim.cfg file updated to: \n"
|
|
echo $1 $2 $lat $long $5 $6 $7 $8
|
|
echo $1 $2 $lat $long $5 $6 $7 $8 > /home/pi/CubeSatSim/sim.cfg
|
|
|
|
if [ "$norestart" = "1" ]; then
|
|
echo
|
|
else
|
|
echo
|
|
echo "Restarting CubeSatSim with new configuraation file"
|
|
echo
|
|
sudo systemctl restart cubesatsim
|
|
fi
|
|
|
|
elif [ "$1" = "-S" ]; then
|
|
|
|
echo
|
|
echo "Scan both I2C buses on the Raspberry Pi"
|
|
echo
|
|
|
|
echo "I2C Bus 1"
|
|
echo
|
|
i2cdetect -y 1
|
|
echo
|
|
echo "I2C Bus 1"
|
|
echo
|
|
i2cdetect -y 3
|
|
echo
|
|
|
|
elif [ "$1" = "-C" ]; then
|
|
|
|
echo
|
|
echo "Clear logs"
|
|
echo
|
|
|
|
sudo systemctl stop cubesatsim
|
|
sudo systemctl stop rpitx
|
|
|
|
sudo journalctl --vacuum-time=1s
|
|
|
|
sudo systemctl reboot now
|
|
|
|
echo "rebooting"
|
|
|
|
elif [ "$1" = "-T" ]; then
|
|
|
|
echo
|
|
echo "Change command state"
|
|
echo
|
|
|
|
echo "Current command state is:"
|
|
cat /home/pi/CubeSatSim/command_tx
|
|
echo
|
|
|
|
echo "Do you want to set beacon transmit to ON (y/n) "
|
|
read reset
|
|
echo
|
|
|
|
if [ "$reset" = "y" ] || [ "$reset" = "yes" ] ; then
|
|
sudo sed -i 's/False/True/g' /home/pi/CubeSatSim/command_tx
|
|
echo "Command state set to True to enable beacon"
|
|
echo "rebooting"
|
|
sudo reboot now
|
|
else
|
|
sudo sed -i 's/True/False/g' /home/pi/CubeSatSim/command_tx
|
|
echo "Command state set to False to disable beacon"
|
|
echo "rebooting"
|
|
sudo reboot now
|
|
fi
|
|
|
|
elif [ "$1" = "-R" ]; then
|
|
|
|
echo
|
|
echo "Reset the Commands Count in the file command_count.txt"
|
|
echo
|
|
|
|
echo "Current commands count is:"
|
|
cat /home/pi/CubeSatSim/commands_count.txt
|
|
echo
|
|
|
|
echo "Do you want to reset the commands count to zero (y/n) "
|
|
read reset
|
|
echo
|
|
|
|
if [ "$reset" = "y" ] || [ "$reset" = "yes" ] ; then
|
|
sudo rm /home/pi/CubeSatSim/command_count.txt
|
|
echo "Commands count reset to 0"
|
|
echo "0\n" > /home/pi/CubeSatSim/command_count.txt
|
|
else
|
|
echo "Commands count not reset"
|
|
fi
|
|
elif [ "$1" = "-q" ]; then
|
|
|
|
echo
|
|
echo "Editing the Squelch setting in"
|
|
echo "the configuration file for CubeSatSim"
|
|
echo
|
|
|
|
value=`cat /home/pi/CubeSatSim/sim.cfg`
|
|
echo "$value" > /dev/null
|
|
set -- $value
|
|
|
|
echo
|
|
echo "Current value of squelch is"
|
|
echo $6
|
|
echo
|
|
|
|
# echo $1 $2 $3 $4 $5 $6 $7 $8
|
|
|
|
echo -e "Enter squelch (integer 0 - 8): "
|
|
|
|
read sq
|
|
|
|
if [ -z $sq ] ; then
|
|
|
|
sq="$6"
|
|
echo "Keeping value of" $lat
|
|
fi
|
|
|
|
if ! [[ $sq =~ ^[+-]?[0-9]+([.][0-9]+)?$ ]] ; then
|
|
|
|
echo "Error: not a number!"
|
|
sq="$6"
|
|
echo "Keeping value of" $sq
|
|
fi
|
|
|
|
echo
|
|
echo -e "\nCubeSatSim configuraation sim.cfg file updated to: \n"
|
|
echo
|
|
echo $1 $2 $3 $4 $5 $sq $7 $8
|
|
echo $1 $2 $3 $4 $4 $sq $7 $8 > /home/pi/CubeSatSim/sim.cfg
|
|
echo
|
|
echo "Restarting CubeSatSim with new configuraation file"
|
|
echo
|
|
|
|
sudo systemctl restart cubesatsim
|
|
|
|
elif [ "$1" = "-F" ]; then
|
|
|
|
echo
|
|
echo "Editing the tx and rx frequency in the"
|
|
echo "configuration file for CubeSatSim"
|
|
echo
|
|
echo "Return keeps current value."
|
|
# echo -e "Current sim.cfg configuration file:"
|
|
# echo
|
|
|
|
value=`cat /home/pi/CubeSatSim/sim.cfg`
|
|
echo "$value" > /dev/null
|
|
set -- $value
|
|
|
|
echo "Current value of tx is"
|
|
echo $7
|
|
echo
|
|
echo "Current value of rx is"
|
|
echo $8
|
|
echo
|
|
|
|
# echo $1 $2 $3 $4 $5 $6 $7 $8
|
|
|
|
echo "Enter tx frequency as 4XX.XXXX: "
|
|
read tx
|
|
|
|
if [ -z $tx ] ; then
|
|
|
|
tx="$7"
|
|
echo "Keeping value of" $tx
|
|
fi
|
|
|
|
echo "Enter rx frequency as 4XX.XXXX: "
|
|
read rx
|
|
|
|
if [ -z $rx ] ; then
|
|
|
|
rx="$8"
|
|
echo "Keeping value of" $rx
|
|
fi
|
|
# else
|
|
|
|
echo -e "\nCubeSatSim configuraation sim.cfg file updated to: \n"
|
|
|
|
echo $callsign $2 $3 $4 $5 $6 $7 $8
|
|
echo $callsign $2 $3 $4 $5 $6 $tx $rx > /home/pi/CubeSatSim/sim.cfg
|
|
# fi
|
|
|
|
# if [ "$norestart" = "1" ]; then
|
|
# echo
|
|
# else
|
|
echo
|
|
echo "Restarting CubeSatSim with new configuraation file"
|
|
echo
|
|
sudo systemctl restart cubesatsim
|
|
# fi
|
|
|
|
fi
|
|
|
|
# sudo systemctl restart cubesatsim
|