Merge pull request #418 from alanbjohnston/master-b-gpio-l

GPIO camera and install improvements
master-b
Alan Johnston 1 month ago committed by GitHub
commit ffa0fcdc2d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -1,27 +1,64 @@
#!/bin/bash #!/bin/bash
echo -e "\ninstallation script for CubeSatSim v2.2\n" FLAG=0
checkout=0
BULLSEYE=0
UPDATE=0
if [[ $(grep '11.' /etc/debian_version) ]]; then FILE=/home/pi/CubeSatSim/cubesatsim # code has already been compiled
echo "Installing on Debian 11 (Bullseye)" if [ -f "$FILE" ]; then
UPDATE=1
echo -e "\nUpdate script for CubeSatSim v2.2\n"
if [ -z "$1" ] ; then
checkout=0
else
checkout=1
branch="$1"
echo -n "changing to branch "
echo $branch
FLAG=1
fi
if [ "$2" = "n" ] ; then
noreboot=1
else
noreboot=0
fi
else
echo -e "\nInstallation script for CubeSatSim v2.2\n"
touch /home/pi/CubeSatSim/command_control_direwolf
echo "creating $FILE"
echo "AMSAT 0 0 0 no 3 434.9 435 no 0 0 no 60" > /home/pi/CubeSatSim/sim.cfg
/home/pi/CubeSatSim/config -c -n
/home/pi/CubeSatSim/config -l -n
fi
if [[ $(grep '11.' /etc/debian_version) ]]; then
BULLSEYE=1
echo "Debian 11 (Bullseye) detected"
sudo cp /boot/config.txt /boot/config.txt.0 sudo cp /boot/config.txt /boot/config.txt.0
sudo cp /boot/cmdline.txt /boot/cmdline.txt.0 sudo cp /boot/cmdline.txt /boot/cmdline.txt.0
sudo raspi-config nonint do_i2c 0 sudo raspi-config nonint do_i2c 0
sudo raspi-config nonint do_camera 0 sudo raspi-config nonint do_camera 0
sudo raspi-config nonint do_legacy 0 sudo raspi-config nonint do_legacy 0
#if [ "$1" = "u" ]; then
#fi
## sudo sed -i 's/console=serial0,115200 //g' /boot/cmdline.txt
sudo sed -i 's/console=serial0,115200 //g' /boot/cmdline.txt sudo sed -i 's/console=serial0,115200 //g' /boot/cmdline.txt
sudo sed -i 's/console=tty1 r/console=tty1 maxcpus=1 r/g' /boot/cmdline.txt # single core if Pi Zero 2 sudo sed -i 's/console=tty1 r/console=tty1 maxcpus=1 r/g' /boot/cmdline.txt # single core if Pi Zero 2
@ -86,7 +123,7 @@ echo -e "\ninstallation script for CubeSatSim v2.2\n"
sudo sh -c 'echo "\ndtoverlay=pwm,pin=18,func=2" >> /boot/config.txt' sudo sh -c 'echo "\ndtoverlay=pwm,pin=18,func=2" >> /boot/config.txt'
fi fi
if [[ $(grep 'disable_splash=1 ' /boot/config.txt) ]]; then if [[ $(grep 'disable_splash=1' /boot/config.txt) ]]; then
echo "disable_splash=1 already in /boot/config.txt" echo "disable_splash=1 already in /boot/config.txt"
else else
echo "adding disable_splash=1 to /boot/config.txt" echo "adding disable_splash=1 to /boot/config.txt"
@ -106,25 +143,19 @@ echo -e "\ninstallation script for CubeSatSim v2.2\n"
fi fi
if [[ $(grep 'bookworm' /etc/os-release) ]]; then if [[ $(grep 'bookworm' /etc/os-release) ]]; then
echo "Bookworm detected, installation continuing."
echo "Debian 12 (Bookworm) detected"
sudo cp /boot/firmware/config.txt /boot/firmware/config.txt.0 sudo cp /boot/firmware/config.txt /boot/firmware/config.txt.0
sudo cp /boot/firmware/cmdline.txt /boot/firmware/cmdline.txt.0 sudo cp /boot/firmware/cmdline.txt /boot/firmware/cmdline.txt.0
sudo raspi-config nonint do_i2c 0 sudo raspi-config nonint do_i2c 0
sudo raspi-config nonint do_camera 0 sudo raspi-config nonint do_camera 0
sudo raspi-config nonint do_legacy 0 sudo raspi-config nonint do_legacy 0
#if [ "$1" = "u" ]; then
#fi
## sudo sed -i 's/console=serial0,115200 //g' /boot/firmware/cmdline.txt
sudo sed -i 's/console=serial0,115200 //g' /boot/firmware/cmdline.txt sudo sed -i 's/console=serial0,115200 //g' /boot/firmware/cmdline.txt
sudo sed -i 's/console=tty1 r/console=tty1 maxcpus=1 r/g' /boot/firmware/cmdline.txt # single core if Pi Zero 2 sudo sed -i 's/console=tty1 r/console=tty1 maxcpus=1 r/g' /boot/firmware/cmdline.txt # single core if Pi Zero 2
@ -189,7 +220,7 @@ if [[ $(grep 'bookworm' /etc/os-release) ]]; then
sudo sh -c 'echo "\ndtoverlay=pwm,pin=18,func=2" >> /boot/firmware/config.txt' sudo sh -c 'echo "\ndtoverlay=pwm,pin=18,func=2" >> /boot/firmware/config.txt'
fi fi
if [[ $(grep 'disable_splash=1 ' /boot/firmware/config.txt) ]]; then if [[ $(grep 'disable_splash=1' /boot/firmware/config.txt) ]]; then
echo "disable_splash=1 already in /boot/firmware/config.txt" echo "disable_splash=1 already in /boot/firmware/config.txt"
else else
echo "adding disable_splash=1 to /boot/firmware/config.txt" echo "adding disable_splash=1 to /boot/firmware/config.txt"
@ -214,8 +245,10 @@ if [[ $(grep 'bookworm' /etc/os-release) ]]; then
sudo sh -c 'echo "\n" >> /boot/firmware/config.txt' sudo sh -c 'echo "\n" >> /boot/firmware/config.txt'
else elif [[ $(grep 'trixie' /etc/os-release) ]]; then
echo "Your Pi OS version is not Bookworm."
echo "Trixie detected, installation continuing."
echo "Your Pi OS version is not Bookworm or Bullseye."
echo "The software installation will likely not work." echo "The software installation will likely not work."
echo "See the README.md for how to install using Bookworm." echo "See the README.md for how to install using Bookworm."
echo echo
@ -232,9 +265,41 @@ fi
FILE=/home/pi/CubeSatSim/sim.cfg FILE=/home/pi/CubeSatSim/sim.cfg
if [ -f "$FILE" ]; then if [ -f "$FILE" ]; then
echo "$FILE exists." echo "$FILE exists."
changed=0
value=`cat /home/pi/CubeSatSim/sim.cfg`
# echo "$value"
echo "$value" > /dev/null
set -- $value
if [ -z "$1" ] ; then n1="AMSAT" ; changed=1 ; else n1=$1 ; fi # callsign
if [ -z "$2" ] ; then n2="0" ; changed=1 ; else n2=$2 ; fi # reset count
if [ -z "$3" ] ; then n3="0" ; changed=1 ; else n3=$3 ; fi # lat
if [ -z "$4" ] ; then n4="0" ; changed=1 ; else n4=$4 ; fi # lon
if [ -z "$5" ] ; then n5="no" ; changed=1 ; else n5=$5 ; fi # sim mode
if [ -z "$6" ] ; then n6="3" ; changed=1 ; else n6=$6 ; fi # squelch
if [ -z "$7" ] ; then n7="434.9000" ; changed=1 ; else n7=$7 ; fi # transmit frequency
if [ -z "$8" ] ; then n8="435.0000" ; changed=1 ; else n8=$8 ; fi # receive frequency
if [ -z "$9" ] ; then n9="no" ; changed=1 ; else n9=$9 ; fi # hab mode
if [ -z "${10}" ] ; then m1="0" ; changed=1 ; else m1=${10} ; fi # rx pl code
if [ -z "${11}" ] ; then m2="0" ; changed=1 ; else m2=${11} ; fi # tx pl code
if [ -z "${12}" ] ; then m3="no" ; changed=1 ; else m3=${12} ; fi # random fail
if [ -z "${13}" ] ; then m4="60" ; changed=1 ; else m4=${13} ; fi # random fail period
if [ $changed -eq 1 ]; then
echo -e "Current sim.cfg configuration file:"
echo
echo $1 $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${11} ${12} ${13}
echo -e "\nCubeSatSim configuration sim.cfg file updated to: \n"
echo
echo $n1 $n2 $n3 $n4 $n5 $n6 $n7 $n8 $n9 $m1 $m2 $m3 $m4
echo $n1 $n2 $n3 $n4 $n5 $n6 $n7 $n8 $n9 $m1 $m2 $m3 $m4> /home/pi/CubeSatSim/sim.cfg
echo
fi
else else
echo "creating $FILE" echo "creating $FILE"
echo "AMSAT 1 0.0 0.0" > /home/pi/CubeSatSim/sim.cfg echo "AMSAT 0 0 0 no 3 434.9 435 no 0 0 no 60" > /home/pi/CubeSatSim/sim.cfg
fi fi
if [[ $(grep 'cubesatsim' /etc/motd) ]]; then if [[ $(grep 'cubesatsim' /etc/motd) ]]; then
@ -259,64 +324,84 @@ else
echo "creating $FILE" echo "creating $FILE"
echo "0\n" > /home/pi/CubeSatSim/command_count.txt echo "0\n" > /home/pi/CubeSatSim/command_count.txt
fi fi
touch /home/pi/CubeSatSim/command_control_direwolf
sudo apt-get update && sudo apt-get dist-upgrade -y sudo apt-get update && sudo apt-get dist-upgrade -y
sudo apt-get remove pulseaudio -y # if [ $BULLSEYE -eq 1 ]; then
# sudo apt purge -y python3-pip
sudo apt-get install -y gcc g++ make cmake libasound2-dev libudev-dev libavahi-client-dev libgpiod-dev raspi-config # sudo apt install -y python3-pip
# fi
# removed wiringpi and python-picamera python3-picamera
sudo apt-get install -y git libasound2-dev i2c-tools build-essential libgd-dev libmagic-dev minicom
cd
git clone https://github.com/alanbjohnston/direwolf.git if [ ! -d "/home/pi/venv" ]; then
cd direwolf cd
sudo apt install -y python3-venv
sudo python3 -m venv venv
source /home/pi/venv/bin/activate
curl https://bootstrap.pypa.io/get-pip.py | sudo /home/pi/venv/bin/python3
sudo /home/pi/venv/bin/pip3 install adafruit_extended_bus
sudo /home/pi/venv/bin/pip3 install adafruit-circuitpython-ina219
make -j fi
sudo make install sudo apt-get remove pulseaudio -y
make install-rpi sudo apt-get install -y gcc g++ make cmake libasound2-dev libudev-dev libavahi-client-dev libgpiod-dev raspi-config
sudo apt-get install -y gpsd gpsd-clients libgps-dev python3-gps # removed wiringpi and python-picamera python3-picamera
sudo apt-get install -y git libasound2-dev i2c-tools build-essential libgd-dev libmagic-dev minicom
sudo systemctl disable gpsd if [ ! -d "/home/pi/direwolf" ]; then
sudo systemctl disable gpsd.socket
cd /tmp cd
git clone https://github.com/alanbjohnston/direwolf.git
cd direwolf
make -j
sudo make install
make install-rpi
fi
# wget https://project-downloads.drogon.net/wiringpi-latest.deb sudo apt-get install -y gpsd gpsd-clients libgps-dev python3-gps
sudo systemctl disable gpsd
sudo systemctl disable gpsd.socket
# sudo dpkg -i wiringpi-latest.deb if [ ! -d "/home/pi/WiringPi" ]; then
cd
git clone https://github.com/alanbjohnston/WiringPi
cd WiringPi
./build debian
sudo dpkg -i debian-template/wiringpi-2.61-1.deb
fi
cd cd
git clone https://github.com/alanbjohnston/WiringPi if [ ! $BULLSEYE -eq 1 ]; then
cd WiringPi sudo apt install -y libtiff6
./build debian fi
sudo dpkg -i debian-template/wiringpi-2.61-1.deb
cd
#changed to python3-smbus sudo apt install -y python3-pip python3-smbus libjpeg-dev zlib1g-dev libfreetype6-dev libopenjp2-7 python3-pil python3-serial libusb-1.0-0 libusb-1.0-0-dev
sudo apt install -y libtiff6 if [ $BULLSEYE -eq 1 ] || [ $UPDATE -eq 0 ] ; then
sudo apt install -y python3-pip python3-smbus libjpeg-dev zlib1g-dev libfreetype6-dev libopenjp2-7 python3-pil python3-serial libusb-1.0-0 libusb-1.0-0-dev sudo pip3 install --upgrade setuptools
sudo pip3 install adafruit-blinka RPI.GPIO adafruit-extended-bus adafruit-circuitpython-ina219
sudo pip3 install --upgrade setuptools fi
sudo pip3 install adafruit-blinka RPI.GPIO adafruit-extended-bus adafruit-circuitpython-ina219 cd /home/pi/CubeSatSim
cd ~/CubeSatSim git pull --no-rebase > .updated
git pull --no-rebase if [ $checkout -eq 1 ]; then
git checkout $branch
git pull --no-rebase > .updated
FLAG=1
echo "Running update script again"
/home/pi/CubeSatSim/install
fi
make debug make debug
@ -328,156 +413,267 @@ else
echo "b" > .mode echo "b" > .mode
fi fi
cd if [ ! -d "/home/pi/pi-power-button" ]; then
git clone https://github.com/alanbjohnston/pi-power-button.git
cd pi-power-button cd
git clone https://github.com/alanbjohnston/pi-power-button.git
git checkout master cd pi-power-button
git checkout master
./script/install
sudo apt-get install -y libraspberrypi-dev
./script/install fi
sudo apt-get install -y libraspberrypi-dev
cd
echo "Installing SSDV for FUNcube mode" cd /home/pi/pi-power-button
git clone https://github.com/alanbjohnston/ssdv.git # install ssdv for FUNcube images
cd ssdv
make
cd
echo "Installing fctelem binary v0.2 for FUNcube mode" git pull --no-rebase > .updated_p
mkdir /home/pi/fctelem git checkout master
mkdir /home/pi/fctelem/public_html grep 'changed' /home/pi/pi-power-button/.updated_p
cd fctelem if [[ $(grep 'changed' /home/pi/pi-power-button/.updated_p) ]]; then
wget https://github.com/alanbjohnston/go/releases/download/v0.2/fctelem.zip
unzip -u fctelem.zip
cd echo "updating pi-power-button."
echo "Installing fcdctl to set FUNcubeDongle Pro gain" script/install
# sudo rm /var/lib/dpkg/info/python3-pip.list FLAG=1
# sudo apt install python3-pip --reinstall fi
# sudo apt-get install -y python3-smbus libusb-1.0
cd
git clone https://github.com/csete/fcdctl.git
cd fcdctl
make fcdpp
cd cd
git clone https://github.com/alanbjohnston/PiSSTVpp.git if [ ! -d "/home/pi/PiSSTVpp" ]; then
cd PiSSTVpp
make pisstvpp
echo "Copying SSTV image 1"
cp /home/pi/CubeSatSim/sstv/sstv_image_1_320_x_256.jpg /home/pi/CubeSatSim/sstv_image_1_320_x_256.jpg
echo "Copying SSTV image 2" sudo apt-get update -y
cp /home/pi/CubeSatSim/sstv/sstv_image_2_320_x_256.jpg /home/pi/CubeSatSim/sstv_image_2_320_x_256.jpg sudo apt-get install -y python-picamera python3-picamera build-essential libgd-dev libmagic-dev
cd
git clone https://github.com/alanbjohnston/PiSSTVpp.git
cd PiSSTVpp
make pisstvpp
cd fi
git clone https://github.com/alanbjohnston/rpitx.git
cd rpitx
./install.sh if [ ! -d "/home/pi/rpitx" ]; then
cd cd
git clone https://github.com/alanbjohnston/rpitx.git
cd rpitx
./install.sh
cd
else
sudo cp ~/CubeSatSim/systemd/cubesatsim.service /etc/systemd/system/cubesatsim.service if [[ $(grep 'SYNCWITHPWM' /home/pi/rpitx/src/librpitx/src/fskburst.h) ]]; then
echo "rpitx library already updated"
else
echo "updating rpitx"
cd /home/pi/rpitx
git pull
./update.sh
cd
fi
fi
sudo systemctl enable cubesatsim FILE=/etc/systemd/system/cubesatsim.service
if [ -f "$FILE" ]; then
if [[ $(diff /home/pi/CubeSatSim/systemd/cubesatsim.service /etc/systemd/system/cubesatsim.service) ]]; then
echo "changed cubesatsim.service."
sudo cp /home/pi/CubeSatSim/systemd/cubesatsim.service /etc/systemd/system/cubesatsim.service
FLAG=1
else
echo "no changes to cubesatsim.service."
fi
else
echo "creating cubesatsim.service."
sudo cp /home/pi/CubeSatSim/systemd/cubesatsim.service /etc/systemd/system/cubesatsim.service
sudo systemctl enable command
sudo cp ~/CubeSatSim/systemd/transmit.service /etc/systemd/system/transmit.service FLAG=1
fi
# sudo systemctl enable transmit FILE=/etc/systemd/system/rpitx.service
if [ -f "$FILE" ]; then
sudo systemctl disable rpitx
sudo rm /etc/systemd/system/rpitx.service
fi
sudo cp ~/CubeSatSim/systemd/command.service /etc/systemd/system/command.service FILE=/etc/systemd/system/transmit.service
if [ -f "$FILE" ]; then
if [[ $(diff /home/pi/CubeSatSim/systemd/transmit.service /etc/systemd/system/transmit.service) ]]; then
echo "changed transmit.service."
sudo cp /home/pi/CubeSatSim/systemd/transmit.service /etc/systemd/system/transmit.service
FLAG=1
else
echo "no change to transmit.service."
fi
else
echo "creating transmit.service."
sudo cp /home/pi/CubeSatSim/systemd/transmit.service /etc/systemd/system/transmit.service
FLAG=1
fi
sudo systemctl enable command FILE=/etc/systemd/system/command.service
if [ -f "$FILE" ]; then
if [[ $(diff /home/pi/CubeSatSim/systemd/command.service /etc/systemd/system/command.service) ]]; then
echo "changed command.service."
sudo cp /home/pi/CubeSatSim/systemd/command.service /etc/systemd/system/command.service
FLAG=1
else
echo "no change to command.service."
fi
else
echo "creating command.service."
sudo cp /home/pi/CubeSatSim/systemd/command.service /etc/systemd/system/command.service
sudo systemctl enable command
FLAG=1
fi
sudo cp /home/pi/CubeSatSim/asound.conf /etc/asound.conf FILE=/etc/asound.conf
if [ -f "$FILE" ]; then
if [[ $(diff /home/pi/CubeSatSim/asound.conf /etc/asound.conf) ]]; then
echo "changed /etc/asound.conf."
sudo cp /home/pi/CubeSatSim/asound.conf /etc/asound.conf
FLAG=1
else
echo "no change to /etc/asound.conf."
fi
else
echo "creating /etc/asound.conf."
sudo cp /home/pi/CubeSatSim/asound.conf /etc/asound.conf
FLAG=1
fi
FILE=/home/pi/CubeSatSim/sstv_image_1_320_x_256.jpg
if [ ! -f "$FILE" ]; then
echo "Copying SSTV image 1."
cp /home/pi/CubeSatSim/sstv/sstv_image_1_320_x_256.jpg /home/pi/CubeSatSim/sstv_image_1_320_x_256.jpg
fi
FILE=/home/pi/CubeSatSim/sstv_image_2_320_x_256.jpg
if [ ! -f "$FILE" ]; then
echo "Copying SSTV image 2."
cp /home/pi/CubeSatSim/sstv/sstv_image_2_320_x_256.jpg /home/pi/CubeSatSim/sstv_image_2_320_x_256.jpg
fi
sudo sed -i 's/DEVICES=""/DEVICES="\/dev\/serial0"/g' /etc/default/gpsd sudo sed -i 's/DEVICES=""/DEVICES="\/dev\/serial0"/g' /etc/default/gpsd
sudo sed -i 's/GPSD_OPTIONS=""/GPSD_OPTIONS="-s 9600"/g' /etc/default/gpsd sudo sed -i 's/GPSD_OPTIONS=""/GPSD_OPTIONS="-s 9600"/g' /etc/default/gpsd
changed=0 if [ ! -d "/home/pi/fctelem" ]; then
value=`cat /home/pi/CubeSatSim/sim.cfg` echo "Installing fctelem binary v0.2 for FUNcube mode"
echo "$value" > /dev/null cd
set -- $value mkdir /home/pi/fctelem
mkdir /home/pi/fctelem/public_html
if [ -z "$1" ] ; then n1="AMSAT" ; changed=1 ; else n1=$1 ; fi # callsign cd fctelem
if [ -z "$2" ] ; then n2="0" ; changed=1 ; else n2=$2 ; fi # reset count wget https://github.com/alanbjohnston/go/releases/download/v0.2/fctelem.zip
if [ -z "$3" ] ; then n3="0" ; changed=1 ; else n3=$3 ; fi # lat unzip -u fctelem.zip
if [ -z "$4" ] ; then n4="0" ; changed=1 ; else n4=$4 ; fi # lon FLAG=1
if [ -z "$5" ] ; then n5="no" ; changed=1 ; else n5=$5 ; fi # sim mode elif [ ! -f "/home/pi/fctelem/v0.2" ]; then
if [ -z "$6" ] ; then n6="3" ; changed=1 ; else n6=$6 ; fi # squelch echo "Updating fctelem binary to version v0.2 for FUNcube mode"
if [ -z "$7" ] ; then n7="434.9000" ; changed=1 ; else n7=$7 ; fi # transmit frequency cd
if [ -z "$8" ] ; then n8="435.0000" ; changed=1 ; else n8=$8 ; fi # receive frequency cd /home/pi/fctelem
if [ -z "$9" ] ; then n9="no" ; changed=1 ; else n9=$9 ; fi # hab mode sudo mv fctelem fctelem.bk
if [ -z "${10}" ] ; then n10="0" ; changed=1 ; else n10=${10} ; fi # rx pl code sudo mv fcdecode.conf fcdecode.conf.bk
if [ -z "${11}" ] ; then n11="0" ; changed=1 ; else n11=${11} ; fi # tx pl code sudo mv fctelem.zip fctelem.zip.1
wget https://github.com/alanbjohnston/go/releases/download/v0.2/fctelem.zip
if [ $changed -eq 1 ]; then unzip -u fctelem.zip
echo -e "Current sim.cfg configuration file:" FLAG=1
echo
echo $1 $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${11}
echo -e "\nCubeSatSim configuration sim.cfg file updated to: \n"
echo
echo $n1 $n2 $n3 $n4 $n5 $n6 $n7 $n8 $n9 $n10 $n11
echo $n1 $n2 $n3 $n4 $n5 $n6 $n7 $n8 $n9 $n10 $n11 > /home/pi/CubeSatSim/sim.cfg
echo
fi fi
echo "Installing MPU6050-C-CPP-Library-for-Raspberry-Pi" if [ ! -f "/home/pi/MPU6050-C-CPP-Library-for-Raspberry-Pi/mpu6050" ]; then
sudo apt-get install -y libi2c-dev echo "Installing MPU6050-C-CPP-Library-for-Raspberry-Pi"
cd sudo apt-get install -y libi2c-dev
git clone https://github.com/alanbjohnston/MPU6050-C-CPP-Library-for-Raspberry-Pi.git cd
cd MPU6050-C-CPP-Library-for-Raspberry-Pi git clone https://github.com/alanbjohnston/MPU6050-C-CPP-Library-for-Raspberry-Pi.git
sudo make install cd MPU6050-C-CPP-Library-for-Raspberry-Pi
make payload sudo make install
make payload
fi
echo "Installing raspberry-pi-bme280" cd /home/pi/MPU6050-C-CPP-Library-for-Raspberry-Pi
sudo apt-get install -y libi2c-dev git checkout master
cd git pull --no-rebase > .updated_p
git clone https://github.com/alanbjohnston/raspberry-pi-bme280.git
cd raspberry-pi-bme280
git checkout payload
make
cd if [[ $(grep 'changed' /home/pi/MPU6050-C-CPP-Library-for-Raspberry-Pi/.updated_p) ]]; then
sudo apt install python3-venv echo "updating MPU6050-C-CPP-Library-for-Raspberry-Pi"
sudo python3 -m venv venv sudo make install
source /home/pi/venv/bin/activate make payload
else
echo "nothing to do for MPU6050-C-CPP-Library-for-Raspberry-Pi."
fi
if [ ! -f "/home/pi/raspberry-pi-bme280/bme280" ]; then
echo "Installing raspberry-pi-bme280"
sudo apt-get install -y libi2c-dev
cd
git clone https://github.com/alanbjohnston/raspberry-pi-bme280.git
cd raspberry-pi-bme280
git checkout payload
make
fi
curl https://bootstrap.pypa.io/get-pip.py | sudo /home/pi/venv/bin/python3 cd /home/pi/raspberry-pi-bme280
git checkout payload
git pull --no-rebase > .updated_p
sudo /home/pi/venv/bin/pip3 install adafruit_extended_bus if [[ $(grep 'changed' /home/pi/raspberry-pi-bme280/.updated_p) ]]; then
sudo /home/pi/venv/bin/pip3 install adafruit-circuitpython-ina219
cd echo "updating raspberry-pi-bme280"
make
else
echo "nothing to do for raspberry-pi-bme280."
fi
if [ ! -f "/home/pi/fcdctl/fcdctl" ]; then
echo "Installing fcdctl to set FUNcubeDongle Pro gain"
sudo rm /var/lib/dpkg/info/python3-pip.list
sudo apt install python3-pip --reinstall
sudo apt-get install -y python3-smbus libusb-1.0
cd
git clone https://github.com/csete/fcdctl.git
cd fcdctl
make fcdpp
fi
CubeSatSim/config -c -n if [ ! -f "/home/pi/ssdv/ssdv" ]; then
cd
echo "Installing SSDV for FUNcube mode"
git clone https://github.com/alanbjohnston/ssdv.git # install ssdv for FUNcube images
cd ssdv
make
fi
CubeSatSim/config -l -n cd
echo "Would you like to reboot to complete the installation (y/n)?" #echo "Would you like to reboot to complete the installation (y/n)?"
read -r ANS #read -r ANS
if [ "$ANS" = "y" ]; then #if [ "$ANS" = "y" ]; then
sudo reboot now # sudo reboot now
else #else
echo "The CubeSatSim software will start next time you reboot" # echo "The CubeSatSim software will start next time you reboot"
#fi
if [ "$noreboot" = "0" ] ; then
if [ $FLAG -eq 1 ]; then
echo "systemctl daemon-reload and reboot"
sudo systemctl daemon-reload
sudo reboot -h now
# sudo cubesatsim
else
grep 'changed' /home/pi/CubeSatSim/.updated
if [[ $(grep 'changed' /home/pi/CubeSatSim/.updated) ]]; then
echo "reboot due to code changes " | wall
sudo reboot -h now
# sudo cubesatsim
else
echo "nothing to do."
fi
fi
else
if [ $FLAG -eq 1 ]; then
echo "reboot needed for changes to take effect" | wall
fi
fi fi

@ -1,7 +1,7 @@
#!/usr/bin/env python #!/usr/bin/env python
import RPi.GPIO as GPIO #import RPi.GPIO as GPIO
from RPi.GPIO import output #from RPi.GPIO import output
#import subprocess #import subprocess
import time import time
from time import sleep from time import sleep
@ -14,6 +14,43 @@ import serial
import random import random
import subprocess import subprocess
def output(pin, value):
command = "gpio -g write " + str(pin) + " " + str(value)
system(command)
print(command)
def input(pin):
# command = "gpio -g read " + str(pin)
query = ["gpio", "-g", "read", str(pin)] # Read GPIO pin
try:
result = subprocess.run(query, capture_output=True, text=True, check=True)
print(f"Command run was: {query}")
print("Sucess!")
print(f"Output of the command (stdout): {result.stdout}")
return int(result.stdout)
except subprocess.CalledProcessError as e:
print(f"Command failed with return code: {e.returncode}")
print(f"Command run was: {e.cmd}")
print(f"Output of the command (stdout): {e.stdout}")
print(f"Error output of the command (stderr): {e.stderr}")
return -1
def setup(pin, config):
if config == "in" or config == "out" or config == "up" or config == "down":
command = "gpio -g mode " + str(pin) + " " + config
system(command)
print(command)
else:
print(f"Unknown GPIO setup configuration: {config}")
def blink(times):
powerPin = 16
for i in range(times):
system("gpio -g write " + str(powerPin) + " 0") # blink two times
sleep(0.1)
system("gpio -g write " + str(powerPin) + " 1")
sleep(0.1)
def sim_failure_check(): def sim_failure_check():
try: try:
global card global card
@ -46,7 +83,6 @@ def sim_failure_check():
except: except:
print("No failure mode") print("No failure mode")
card = "Headphones" card = "Headphones"
# card = "Device"
if sim_config: if sim_config:
sim_mode = True sim_mode = True
@ -65,9 +101,9 @@ def battery_saver_check():
def blink(times): def blink(times):
powerPin = 16 powerPin = 16
for i in range(times): for i in range(times):
system("gpio -g write " + str(powerPin) + " 0") # blink two times output(powerPin, 0) # blink
sleep(0.1) sleep(0.1)
system("gpio -g write " + str(powerPin) + " 1") output(powerPin, 1)
sleep(0.1) sleep(0.1)
def increment_mode(): def increment_mode():
@ -114,13 +150,13 @@ def increment_mode():
file.close() file.close()
print(".mode file written") print(".mode file written")
GPIO.setwarnings(False) # GPIO.setwarnings(False)
system("gpio -g write " + str(txLed) + " 0") output(txLed, 0)
system("gpio -g write " + str(powerPin) + " 0") output(powerPin, 0)
print("sudo reboot -h now") print("sudo reboot -h now")
GPIO.setwarnings(False) # GPIO.setwarnings(False)
system("gpio -g mode " + str(powerPin) + " out") setup(powerPin, "out")
system("gpio -g write " + str(powerPin) + " 0"); output(powerPin, 0);
# system("reboot -h now") # system("reboot -h now")
# release = True; # release = True;
@ -181,7 +217,7 @@ def camera_photo():
return True return True
else: else:
return False return False
print("CubeSatSim v2.2 transmit.py starting...") print("CubeSatSim v2.2 transmit.py starting...")
pd = 21 pd = 21
@ -193,70 +229,52 @@ powerPin = 16
command_tx = True command_tx = True
try: # GPIO.setmode(GPIO.BCM)
system("gpio -g write " + str(powerPin) + " 1") # GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM) setup(13, "up")
GPIO.setwarnings(False) setup(12, "up")
GPIO.setup(13, GPIO.IN, pull_up_down=GPIO.PUD_UP) setup(27, "up")
GPIO.setup(12, GPIO.IN, pull_up_down=GPIO.PUD_UP) setup(txc_pin, "up")
GPIO.setup(txc_pin, GPIO.IN, pull_up_down=GPIO.PUD_UP) setup(green, "out")
GPIO.setup(green, GPIO.OUT) output(powerPin, 1)
GPIO.setup(27, GPIO.IN)
except:
print("gpio setup problem")
system("gpio -g mode 27 IN")
try:
GPIO.setup(27, GPIO.IN, pull_up_down=GPIO.PUD_UP)
except:
print("Can't set txLed")
transmit = False transmit = False
txLed = 27 txLed = 27
# txLed = 17 if input(12) == False:
txLedOn = 1
txLedOff = 0
if GPIO.input(12) == False:
print("LPF present") print("LPF present")
transmit = True transmit = True
else: else:
print("No LPF") print("No LPF")
# system("gpio -g mode " + str(txLed) + " out") # GPIO.setup(txLed, GPIO.OUT)
# system("gpio -g write " + str(txLed) + " 0") # output(txLed, 0)
GPIO.setmode(GPIO.BCM) # Repeat to make LED work on Pi 4 # GPIO.setmode(GPIO.BCM) # Repeat to make LED work on Pi 4
GPIO.setwarnings(False) # GPIO.setwarnings(False)
try: setup(txLed, "out")
system("gpio -g mode " + str(txLed) + " out")
except:
print("Can't set txLed")
GPIO.setup(pd, GPIO.OUT) setup(pd, "out")
#output(pd, 1) #output(pd, 1)
output(pd, 0) output(pd, 0)
GPIO.setup(ptt, GPIO.OUT) setup(ptt, "out")
output (ptt, 1) output (ptt, 1)
txc = False txc = False
if GPIO.input(txc_pin) == False: if input(txc_pin) == False:
print("TXC is present") print("TXC is present")
txc = True; txc = True;
else: else:
print("TXC not present") print("TXC not present")
# txc = False # forcing it off # txc = False # forcing it off
output(txLed, 1)
try: sleep(1)
system("gpio -g write " + str(txLed) + " 1") output(txLed, 0)
sleep(1)
system("gpio -g write " + str(txLed) + " 0")
except:
print("Can't set txLed")
battery_saver_check() battery_saver_check()
# print(txLedOn) # print(1)
print(txLed) print(txLed)
# GPIO.setup(27, GPIO.OUT) # GPIO.setup(27, GPIO.OUT)
# GPIO.output(27, 0) # GPIO.output(27, 0)
@ -440,10 +458,10 @@ if __name__ == "__main__":
try: try:
f = open("/home/pi/CubeSatSim/command_control", "r") f = open("/home/pi/CubeSatSim/command_control", "r")
f.close() f.close()
GPIO.setmode(GPIO.BCM) # GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False) # GPIO.setwarnings(False)
GPIO.setup(squelch, GPIO.IN, pull_up_down=GPIO.PUD_UP) ## pull up in case pin is not connected setup(squelch, "up") ## pull up in case pin is not connected
if GPIO.input(squelch) == False: if input(squelch) == False:
print("squelch not set correctly, no command input!") print("squelch not set correctly, no command input!")
else: else:
if (mode != 'n') and (mode != 'x'): if (mode != 'n') and (mode != 'x'):
@ -458,16 +476,10 @@ if __name__ == "__main__":
print(callsign) print(callsign)
GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi 4 # GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi 4
try: # print(txLed)
print(txLed) # print(1)
print(txLedOn) # setup(txLed, "out")
system("gpio -g mode " + str(txLed) + " out")
except:
print("Can't set txLed")
# card = "Headphones" # default using pcm audio output of Pi Zero
card = "Device" # using USB sound card for audio output
query = ["grep", "VERSION_CODENAME=bullseye", "/etc/os-release"] query = ["grep", "VERSION_CODENAME=bullseye", "/etc/os-release"]
try: try:
@ -486,6 +498,9 @@ if __name__ == "__main__":
else: else:
os_status = "bullseye" os_status = "bullseye"
print (os_status) print (os_status)
card = "Headphones" # default using pcm audio output of Pi Zero
# card = "Device" # using USB sound card for audio output
query = ["sudo", "systemctl", "is-active", "gpsd.socket"] query = ["sudo", "systemctl", "is-active", "gpsd.socket"]
try: try:
@ -532,12 +547,9 @@ if __name__ == "__main__":
print("Don't transmit CW ID since APRS HAB mode is active") print("Don't transmit CW ID since APRS HAB mode is active")
else: else:
if (((mode == 'a') or (mode == 'b') or (mode == 'f') or (mode == 's') or (mode == 'j')) and (command_tx == True) and (skip == False)) or ((mode == 'e') and (command_tx == True)): # battery_saver_mode if (((mode == 'a') or (mode == 'b') or (mode == 'f') or (mode == 's') or (mode == 'j')) and (command_tx == True) and (skip == False)) or ((mode == 'e') and (command_tx == True)): # battery_saver_mode
GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4 # GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4
try: # setup(txLed, "out")
system("gpio -g mode " + str(txLed) + " out") output(txLed, 1)
system("gpio -g write " + str(txLed) + " 1")
except:
print("Can't set txLed")
print("Transmit CW ID") print("Transmit CW ID")
status = "" status = ""
if not no_command: if not no_command:
@ -548,10 +560,7 @@ if __name__ == "__main__":
system("echo 'hi hi de " + callsign + status + "' > id.txt && gen_packets -M 20 /home/pi/CubeSatSim/id.txt -o /home/pi/CubeSatSim/morse.wav -r 48000 > /dev/null 2>&1 && cat /home/pi/CubeSatSim/morse.wav | csdr convert_i16_f | csdr gain_ff 7000 | csdr convert_f_samplerf 20833 | sudo /home/pi/rpitx/rpitx -i- -m RF -f " + tx + "e3") system("echo 'hi hi de " + callsign + status + "' > id.txt && gen_packets -M 20 /home/pi/CubeSatSim/id.txt -o /home/pi/CubeSatSim/morse.wav -r 48000 > /dev/null 2>&1 && cat /home/pi/CubeSatSim/morse.wav | csdr convert_i16_f | csdr gain_ff 7000 | csdr convert_f_samplerf 20833 | sudo /home/pi/rpitx/rpitx -i- -m RF -f " + tx + "e3")
else: else:
system("echo 'hi hi de " + callsign + status + "' > id.txt && gen_packets -M 20 /home/pi/CubeSatSim/id.txt -o /home/pi/CubeSatSim/morse.wav -r 48000 > /dev/null 2>&1 && cat /home/pi/CubeSatSim/morse.wav | csdr convert_i16_f | csdr gain_ff 7000 | csdr convert_f_samplerf 20833 | sudo /home/pi/rpitx/rpitx -i- -m RF -f " + tx + "e3 > /dev/null 2>&1") system("echo 'hi hi de " + callsign + status + "' > id.txt && gen_packets -M 20 /home/pi/CubeSatSim/id.txt -o /home/pi/CubeSatSim/morse.wav -r 48000 > /dev/null 2>&1 && cat /home/pi/CubeSatSim/morse.wav | csdr convert_i16_f | csdr gain_ff 7000 | csdr convert_f_samplerf 20833 | sudo /home/pi/rpitx/rpitx -i- -m RF -f " + tx + "e3 > /dev/null 2>&1")
try: output(txLed, 0)
system("gpio -g write " + str(txLed) + " 0")
except:
print("Can't set txLed")
sleep(1) sleep(1)
else: else:
@ -570,7 +579,7 @@ if __name__ == "__main__":
if (mode == 'a'): if (mode == 'a'):
print("AFSK") print("AFSK")
else: else:
# system("gpio -g write " + str(powerPin) + " 0") # GPIO.output(powerPin, 0)
print("Transmit APRS Commands") print("Transmit APRS Commands")
system("sudo systemctl stop command") system("sudo systemctl stop command")
# while True: # while True:
@ -587,12 +596,9 @@ if __name__ == "__main__":
system("gen_packets -o /home/pi/CubeSatSim/telem.wav /home/pi/CubeSatSim/t.txt -r 48000 > /dev/null 2>&1") system("gen_packets -o /home/pi/CubeSatSim/telem.wav /home/pi/CubeSatSim/t.txt -r 48000 > /dev/null 2>&1")
system("cat /home/pi/CubeSatSim/t.txt") system("cat /home/pi/CubeSatSim/t.txt")
if (command_tx == True): if (command_tx == True):
GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4 # GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4
try: # setup(txLed, "out")
system("gpio -g mode " + str(txLed) + " out") output(txLed, 1)
system("gpio -g write " + str(txLed) + " 1")
except:
print("Can't set txLed")
# output(pd, 1) # output(pd, 1)
# output (ptt, 0) # output (ptt, 0)
# sleep(.1) # sleep(.1)
@ -618,10 +624,7 @@ if __name__ == "__main__":
sleep(0.1) sleep(0.1)
# output (ptt, 1) # output (ptt, 1)
# output(pd, 0) # output(pd, 0)
try: output(txLed, 0)
system("gpio -g write " + str(txLed) + " 0")
except:
print("Can't set txLed")
system("sudo rm /home/pi/CubeSatSim/ready") system("sudo rm /home/pi/CubeSatSim/ready")
f.close() f.close()
@ -651,12 +654,9 @@ if __name__ == "__main__":
system(command) system(command)
## chan = chan + 1 ## chan = chan + 1
if (command_tx == True): if (command_tx == True):
GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4 # GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4
system("gpio -g mode " + str(txLed) + " out") # setup(txLed, "out")
try: output(txLed, 1)
system("gpio -g write " + str(txLed) + " 1")
except:
print("Can't set txLed")
if (txc): if (txc):
sim_failure_check() sim_failure_check()
@ -672,10 +672,7 @@ if __name__ == "__main__":
system("cat /home/pi/CubeSatSim/morse.wav | csdr convert_i16_f | csdr gain_ff 7000 | csdr convert_f_samplerf 20833 | sudo /home/pi/rpitx/rpitx -i- -m RF -f " + tx + "e3") system("cat /home/pi/CubeSatSim/morse.wav | csdr convert_i16_f | csdr gain_ff 7000 | csdr convert_f_samplerf 20833 | sudo /home/pi/rpitx/rpitx -i- -m RF -f " + tx + "e3")
else: else:
system("cat /home/pi/CubeSatSim/morse.wav | csdr convert_i16_f | csdr gain_ff 7000 | csdr convert_f_samplerf 20833 | sudo /home/pi/rpitx/rpitx -i- -m RF -f " + tx + "e3 > /dev/null 2>&1") system("cat /home/pi/CubeSatSim/morse.wav | csdr convert_i16_f | csdr gain_ff 7000 | csdr convert_f_samplerf 20833 | sudo /home/pi/rpitx/rpitx -i- -m RF -f " + tx + "e3 > /dev/null 2>&1")
try: output(txLed, 0)
system("gpio -g write " + str(txLed) + " 0")
except:
print("Can't set txLed")
# command_control_check() # command_control_check()
sleep(2) sleep(2)
@ -688,21 +685,28 @@ if __name__ == "__main__":
print("SSTV") print("SSTV")
# command_control_check() # command_control_check()
output (ptt, 1) output (ptt, 1)
output(pd, 1) output(pd, 1)
try:
print("Testing for camera") # from picamera import PiCamera
if camera_photo(): # from pysstv.sstv import SSTV
# camera = PiCamera()
print("Testing for camera")
if os_status == "bookworm":
system("rpicam-still -o /home/pi/CubeSatSim/camera_out.jpg --width 320 --height 256") # > /dev/null 2>&1")
else:
system("raspistill -o /home/pi/CubeSatSim/camera_out.jpg -w 320 -h 256")
f = open("/home/pi/CubeSatSim/camera_out.jpg")
f.close()
print("Camera present")
camera_present = 1 camera_present = 1
print("camera present") # camera.close()
else: except:
camera_present = 0
print("No camera available") print("No camera available")
print(" -> if camera plugged in, is software enabled?") print(" -> if camera plugged in, is software enabled?")
camera_present = 0
try:
system("gpio -g write " + str(txLed) + " 0") # while 1:
except: output(txLed, 0)
print("Can't set txLed")
# output (ptt, 1) # output (ptt, 1)
# output(pd, 0) # output(pd, 0)
if (camera_present == 1): if (camera_present == 1):
@ -714,12 +718,9 @@ if __name__ == "__main__":
if (command_tx == True): if (command_tx == True):
print ("Sending SSTV image") print ("Sending SSTV image")
GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4 # GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4
try: # setup(txLed, "out")
system("gpio -g mode " + str(txLed) + " out") output(txLed, 1)
system("gpio -g write " + str(txLed) + " 1")
except:
print("Can't set txLed")
# battery_saver_check() # battery_saver_check()
if (txc): if (txc):
@ -735,11 +736,8 @@ if __name__ == "__main__":
else: else:
system("cat /home/pi/CubeSatSim/sstv_image_2_320_x_256.jpg.wav | csdr convert_i16_f | csdr gain_ff 14000 | csdr convert_f_samplerf 20833 | sudo rpitx -i- -m RF -f " + tx + "e3 > /dev/null 2>&1") system("cat /home/pi/CubeSatSim/sstv_image_2_320_x_256.jpg.wav | csdr convert_i16_f | csdr gain_ff 14000 | csdr convert_f_samplerf 20833 | sudo rpitx -i- -m RF -f " + tx + "e3 > /dev/null 2>&1")
try: output(txLed, 0)
system("gpio -g write " + str(txLed) + " 0")
except:
print("Can't set txLed")
# sleep(1) # sleep(1)
except: except:
print("image 2 did not load - copy from CubeSatSim/sstv directory") print("image 2 did not load - copy from CubeSatSim/sstv directory")
@ -753,12 +751,9 @@ if __name__ == "__main__":
if (command_tx == True): if (command_tx == True):
print ("Sending SSTV image") print ("Sending SSTV image")
GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4 # GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4
try: # setup(txLed, "out")
system("gpio -g mode " + str(txLed) + " out") output(txLed, 1)
system("gpio -g write " + str(txLed) + " 1")
except:
print("Can't set txLed")
# battery_saver_check() # battery_saver_check()
if (txc): if (txc):
@ -774,10 +769,8 @@ if __name__ == "__main__":
system("cat /home/pi/CubeSatSim/camera_out.jpg.wav | csdr convert_i16_f | csdr gain_ff 14000 | csdr convert_f_samplerf 20833 | sudo rpitx -i- -m RF -f " + tx + "e3") system("cat /home/pi/CubeSatSim/camera_out.jpg.wav | csdr convert_i16_f | csdr gain_ff 14000 | csdr convert_f_samplerf 20833 | sudo rpitx -i- -m RF -f " + tx + "e3")
else: else:
system("cat /home/pi/CubeSatSim/camera_out.jpg.wav | csdr convert_i16_f | csdr gain_ff 14000 | csdr convert_f_samplerf 20833 | sudo rpitx -i- -m RF -f " + tx + "e3 > /dev/null 2>&1") system("cat /home/pi/CubeSatSim/camera_out.jpg.wav | csdr convert_i16_f | csdr gain_ff 14000 | csdr convert_f_samplerf 20833 | sudo rpitx -i- -m RF -f " + tx + "e3 > /dev/null 2>&1")
try:
system("gpio -g write " + str(txLed) + " 0") output(txLed, 0)
except:
print("Can't set txLed")
# output (ptt, 1) # output (ptt, 1)
# output(pd, 0) # output(pd, 0)
@ -796,12 +789,9 @@ if __name__ == "__main__":
if (command_tx == True): if (command_tx == True):
print ("Sending SSTV image") print ("Sending SSTV image")
GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4 # GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4
try: # setup(txLed, "out")
system("gpio -g mode " + str(txLed) + " out") output(txLed, 1)
system("gpio -g write " + str(txLed) + " 1")
except:
print("Can't set txLed")
# battery_saver_check() # battery_saver_check()
@ -817,10 +807,8 @@ if __name__ == "__main__":
system("cat /home/pi/CubeSatSim/sstv_image_1_320_x_256.jpg.wav | csdr convert_i16_f | csdr gain_ff 14000 | csdr convert_f_samplerf 20833 | sudo rpitx -i- -m RF -f " + tx + "e3") system("cat /home/pi/CubeSatSim/sstv_image_1_320_x_256.jpg.wav | csdr convert_i16_f | csdr gain_ff 14000 | csdr convert_f_samplerf 20833 | sudo rpitx -i- -m RF -f " + tx + "e3")
else: else:
system("cat /home/pi/CubeSatSim/sstv_image_1_320_x_256.jpg.wav | csdr convert_i16_f | csdr gain_ff 14000 | csdr convert_f_samplerf 20833 | sudo rpitx -i- -m RF -f " + tx + "e3 > /dev/null 2>&1") system("cat /home/pi/CubeSatSim/sstv_image_1_320_x_256.jpg.wav | csdr convert_i16_f | csdr gain_ff 14000 | csdr convert_f_samplerf 20833 | sudo rpitx -i- -m RF -f " + tx + "e3 > /dev/null 2>&1")
try:
system("gpio -g write " + str(txLed) + " 0") output(txLed, 0)
except:
print("Can't set txLed")
# output (ptt, 1) # output (ptt, 1)
# output(pd, 0) # output(pd, 0)
sleep(1) sleep(1)
@ -839,12 +827,9 @@ if __name__ == "__main__":
if (command_tx == True): if (command_tx == True):
print ("Sending SSTV image") print ("Sending SSTV image")
try: # GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4
GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4 # setup(txLed, "out")
system("gpio -g mode " + str(txLed) + " out") output(txLed, 1)
system("gpio -g write " + str(txLed) + " 1")
except:
print("Can't set txLed")
# battery_saver_check() # battery_saver_check()
if (txc): if (txc):
@ -859,10 +844,8 @@ if __name__ == "__main__":
system("cat /home/pi/CubeSatSim/sstv_image_2_320_x_256.jpg.wav | csdr convert_i16_f | csdr gain_ff 14000 | csdr convert_f_samplerf 20833 | sudo rpitx -i- -m RF -f " + tx + "e3") system("cat /home/pi/CubeSatSim/sstv_image_2_320_x_256.jpg.wav | csdr convert_i16_f | csdr gain_ff 14000 | csdr convert_f_samplerf 20833 | sudo rpitx -i- -m RF -f " + tx + "e3")
else: else:
system("cat /home/pi/CubeSatSim/sstv_image_2_320_x_256.jpg.wav | csdr convert_i16_f | csdr gain_ff 14000 | csdr convert_f_samplerf 20833 | sudo rpitx -i- -m RF -f " + tx + "e3 > /dev/null 2>&1") system("cat /home/pi/CubeSatSim/sstv_image_2_320_x_256.jpg.wav | csdr convert_i16_f | csdr gain_ff 14000 | csdr convert_f_samplerf 20833 | sudo rpitx -i- -m RF -f " + tx + "e3 > /dev/null 2>&1")
try:
system("gpio -g write " + str(txLed) + " 0") output(txLed, 0)
except:
print("Can't set txLed")
# output (ptt, 1) # output (ptt, 1)
# output(pd, 0) # output(pd, 0)
sleep(10) sleep(10)
@ -875,12 +858,9 @@ if __name__ == "__main__":
if (command_tx == True): if (command_tx == True):
# command_control_check() # command_control_check()
GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4 # GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4
try: # setup(txLed, "out")
system("gpio -g mode " + str(txLed) + " out") output(txLed, 1)
system("gpio -g write " + str(txLed) + " 1")
except:
print("Can't set txLed")
# battery_saver_check() # battery_saver_check()
@ -893,10 +873,8 @@ if __name__ == "__main__":
# output (pd, 0) # output (pd, 0)
else: else:
sleep(60) sleep(60)
try:
system("gpio -g write " + str(txLed) + " 0") output(txLed, 0)
except:
print("Can't set txLed")
# output (ptt, 1) # output (ptt, 1)
# output(pd, 0) # output(pd, 0)
sleep(10) sleep(10)
@ -910,11 +888,9 @@ if __name__ == "__main__":
print("turn on FM rx") print("turn on FM rx")
output(pd, 1) output(pd, 1)
output(ptt, 1) output(ptt, 1)
try:
GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi 4 # GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi 4
system("gpio -g mode " + str(txLed) + " out") # setup(txLed, "out")
except:
print("Can't set txLed")
if (command_tx == True): if (command_tx == True):
# system("sudo nc -l 8080 | csdr convert_i16_f | csdr fir_interpolate_cc 2 | csdr dsb_fc | csdr bandpass_fir_fft_cc 0.002 0.06 0.01 | csdr fastagc_ff | sudo /home/pi/rpitx/sendiq -i /dev/stdin -s 96000 -f 434.9e6 -t float &") # system("sudo nc -l 8080 | csdr convert_i16_f | csdr fir_interpolate_cc 2 | csdr dsb_fc | csdr bandpass_fir_fft_cc 0.002 0.06 0.01 | csdr fastagc_ff | sudo /home/pi/rpitx/sendiq -i /dev/stdin -s 96000 -f 434.9e6 -t float &")
@ -924,26 +900,20 @@ if __name__ == "__main__":
print("Initial image_id: " + str(image_id) + "\n") print("Initial image_id: " + str(image_id) + "\n")
while 1: while 1:
# print ("LED on") # print ("LED on")
try: output(txLed, 0)
system("gpio -g write " + str(txLed) + " 0")
except:
print("Can't set txLed")
sleep(0.4) sleep(0.4)
# if (command_tx == False): # if (command_tx == False):
# system("gpio -g write " + str(txLed) + " 1") # output(txLed, 1)
# sleep(0.03) # sleep(0.03)
# system("gpio -g write " + str(txLed) + " 0") # output(txLed, 0)
# command_control_check() # command_control_check()
if (command_tx == True): if (command_tx == True):
GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4 # GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4
try: # setup(txLed, "out")
system("gpio -g mode " + str(txLed) + " out") output(txLed, 1)
system("gpio -g write " + str(txLed) + " 1")
except:
print("Can't set txLed")
# print(txLed) # print(txLed)
# print(txLedOn) # print(1)
if (mode == 'b'): if (mode == 'b'):
sleep(4.2) sleep(4.2)
@ -979,14 +949,11 @@ if __name__ == "__main__":
print("turn on FM rx") print("turn on FM rx")
output(pd, 1) output(pd, 1)
output(ptt, 1) output(ptt, 1)
GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi 4 # GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi 4
try: # setup(txLed, "out")
system("gpio -g mode " + str(txLed) + " out") # GPIO.setup(powerPin, GPIO.OUT)
except: setup(squelch, "up") ## pull up in case pin is not connected
print("Can't set txLed") # GPIO.output(powerPin, 1) # was 0
# system("gpio -g mode " + str(powerPin) + " out")
GPIO.setup(squelch, GPIO.IN, pull_up_down=GPIO.PUD_UP) ## pull up in case pin is not connected
# system("gpio -g write " + str(powerPin) + " 1") # was 0
# txf = float(tx) - 288.9 # txf = float(tx) - 288.9
# print("Transmit frequency: ",txf) # print("Transmit frequency: ",txf)
if (command_tx != True): if (command_tx != True):
@ -994,24 +961,18 @@ if __name__ == "__main__":
print("Ready to detect carrier") print("Ready to detect carrier")
while True: while True:
if (GPIO.input(squelch) == False) and (command_tx == True): if (input(squelch) == False) and (command_tx == True):
print("Carrier detected, starting repeater") print("Carrier detected, starting repeater")
GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4 # GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4
try: # setup(txLed, "out")
system("gpio -g mode " + str(txLed) + " out") output(txLed, 1)
system("gpio -g write " + str(txLed) + " 1")
except:
print("Can't set txLed")
system("sudo nc -l 8011 | csdr convert_i16_f | csdr gain_ff 16000 | csdr convert_f_samplerf 20833 | sudo rpitx -i- -m RF -f " + tx + "e3 > /dev/null 2>&1 &") system("sudo nc -l 8011 | csdr convert_i16_f | csdr gain_ff 16000 | csdr convert_f_samplerf 20833 | sudo rpitx -i- -m RF -f " + tx + "e3 > /dev/null 2>&1 &")
sleep(0.5) sleep(0.5)
system("sudo arecord -D shared_mic -r48000 -fS16_LE -c1 | nc localhost 8011 &") system("sudo arecord -D shared_mic -r48000 -fS16_LE -c1 | nc localhost 8011 &")
while (GPIO.input(squelch) == False): while (input(squelch) == False):
sleep(1) sleep(1)
print("No carrier detected, stopping repeater") print("No carrier detected, stopping repeater")
try: output(txLed, 0)
system("gpio -g write " + str(txLed) + " 0")
except:
print("Can't set txLed")
system("sudo rpitx -i null > /dev/null 2>&1") system("sudo rpitx -i null > /dev/null 2>&1")
system("sudo killall -9 arecord > /dev/null 2>&1") system("sudo killall -9 arecord > /dev/null 2>&1")
system("sudo killall -9 nc > /dev/null 2>&1") system("sudo killall -9 nc > /dev/null 2>&1")
@ -1026,36 +987,27 @@ if __name__ == "__main__":
print("turn on FM rx") print("turn on FM rx")
output(pd, 1) output(pd, 1)
output(ptt, 1) output(ptt, 1)
try: # GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi 4
GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi 4 # setup(txLed, "out")
system("gpio -g mode " + str(txLed) + " out")
except:
print("Can't set txLed")
if (command_tx == True): if (command_tx == True):
system("sudo nc -l 8080 | csdr convert_i16_f | csdr gain_ff 7000 | csdr convert_f_samplerf 20833 | sudo /home/pi/rpitx/rpitx -i- -m RF -f " + tx + "e3 &") system("sudo nc -l 8080 | csdr convert_i16_f | csdr gain_ff 7000 | csdr convert_f_samplerf 20833 | sudo /home/pi/rpitx/rpitx -i- -m RF -f " + tx + "e3 &")
print("Turning LED on/off and listening for carrier") print("Turning LED on/off and listening for carrier")
while 1: while 1:
try: output(txLed, 0)
system("gpio -g write " + str(txLed) + " 0")
except:
print("Can't set txLed")
sleep(0.4) sleep(0.4)
# if (command_tx == False): # if (command_tx == False):
# system("gpio -g write " + str(txLed) + " 1") # output(txLed, 1)
# sleep(0.03) # sleep(0.03)
# system("gpio -g write " + str(txLed) + " 0") # output(txLed, 0)
# command_control_check() # command_control_check()
if (command_tx == True): if (command_tx == True):
try: # GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4
GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4 # setup(txLed, "out")
system("gpio -g mode " + str(txLed) + " out") output(txLed, 1)
system("gpio -g write " + str(txLed) + " 1")
except:
print("Can't set txLed")
# print(txLed) # print(txLed)
# print(txLedOn) # print(1)
sleep(4.2) sleep(4.2)
else: else:
print("No Low Pass Filter so no telemetry transmit. See http://cubesatsim.org/wiki for instructions on how to build the LPF.") print("No Low Pass Filter so no telemetry transmit. See http://cubesatsim.org/wiki for instructions on how to build the LPF.")

481
update

@ -1,481 +0,0 @@
#!/bin/bash
echo -e "\nupdate script for CubeSatSim v2.2\n"
FLAG=0
checkout=0
if [ -z "$1" ] ; then
checkout=0
else
checkout=1
branch="$1"
echo -n "changing to branch "
echo $branch
FLAG=1
fi
if [ "$1" = "n" ] ; then
noreboot=1
else
noreboot=0
fi
# echo "No reboot"
# echo $noreboot
sudo rm /home/pi/CubeSatSim/morse.wav /home/pi/CubeSatSim/id.txt /home/pi/CubeSatSim/cw.txt > /dev/null 2>&1
#if [ "$1" = "u" ]; then
# sudo apt-get update && sudo apt-get dist-upgrade -y
sudo apt-get update -y
sudo apt-get install -y git libasound2-dev i2c-tools build-essential libgd-dev libmagic-dev python3-pip minicom gpsd gpsd-clients libgps-dev python3-gps
#fi
sudo apt-get install -y gpsd gpsd-clients libgps-dev python3-gps
# sudo apt-get install -y python3-smbus libusb-1.0
sudo sed -i 's/update.sh/update /g' /etc/motd
sudo sed -i 's/installed and/installed\nand/g' /etc/motd
sudo sed -i 's/more information/more\ninformation/g' /etc/motd
sudo sed -i 's/update to/update\nto/g' /etc/motd
sudo sed -i 's/console=tty1 r/console=tty1 maxcpus=1 r/g' /boot/cmdline.txt # single core if Pi Zero 2
sudo sed -i 's/maxcpus=2/maxcpus=1/g' /boot/cmdline.txt # single core if Pi Zero 2
sudo sed -i 's/DEVICES=""/DEVICES="\/dev\/serial0"/g' /etc/default/gpsd
sudo sed -i 's/GPSD_OPTIONS=""/GPSD_OPTIONS="-s 9600"/g' /etc/default/gpsd
sudo systemctl disable gpsd > /dev/null 2>&1
sudo systemctl disable gpsd.socket > /dev/null 2>&1
cd /home/pi/CubeSatSim
git pull --no-rebase > .updated
if [ $checkout -eq 1 ]; then
git checkout $branch
git pull --no-rebase > .updated
FLAG=1
echo "Running update script again"
/home/pi/CubeSatSim/update
fi
make debug
FILE=/home/pi/CubeSatSim/command_tx
if [ -f "$FILE" ]; then
echo "$FILE exists."
else
echo "creating $FILE"
echo "True\n" > /home/pi/CubeSatSim/command_tx
fi
FILE=/home/pi/CubeSatSim/command_count.txt
if [ -f "$FILE" ]; then
echo "$FILE exists."
else
echo "creating $FILE"
echo "0\n" > /home/pi/CubeSatSim/command_count.txt
fi
if [[ $(diff systemd/cubesatsim.service /etc/systemd/system/cubesatsim.service) ]]; then
echo "changed cubesatsim.service."
sudo cp /home/pi/CubeSatSim/systemd/cubesatsim.service /etc/systemd/system/cubesatsim.service
FLAG=1
else
echo "no changes to cubesatsim.service."
fi
FILE=/etc/systemd/system/rpitx.service
if [ -f "$FILE" ]; then
sudo systemctl disable rpitx
sudo rm /etc/systemd/system/rpitx.service
fi
FILE=/etc/systemd/system/transmit.service
if [ -f "$FILE" ]; then
if [[ $(diff systemd/transmit.service /etc/systemd/system/transmit.service) ]]; then
echo "changed transmit.service."
sudo cp /home/pi/CubeSatSim/systemd/transmit.service /etc/systemd/system/transmit.service
FLAG=1
else
echo "no change to transmit.service."
fi
else
echo "creating transmit.service."
sudo cp /home/pi/CubeSatSim/systemd/transmit.service /etc/systemd/system/transmit.service
FLAG=1
fi
FILE=/etc/systemd/system/command.service
if [ -f "$FILE" ]; then
if [[ $(diff systemd/command.service /etc/systemd/system/command.service) ]]; then
echo "changed command.service."
sudo cp /home/pi/CubeSatSim/systemd/command.service /etc/systemd/system/command.service
FLAG=1
else
echo "no change to command.service."
fi
else
echo "creating command.service."
sudo cp /home/pi/CubeSatSim/systemd/command.service /etc/systemd/system/command.service
sudo systemctl enable command
FLAG=1
fi
FILE=/etc/asound.conf
if [ -f "$FILE" ]; then
if [[ $(diff /home/pi/CubeSatSim/asound.conf /etc/asound.conf) ]]; then
echo "changed /etc/asound.conf."
sudo cp /home/pi/CubeSatSim/asound.conf /etc/asound.conf
FLAG=1
else
echo "no change to /etc/asound.conf."
fi
else
echo "creating /etc/asound.conf."
sudo cp /home/pi/CubeSatSim/asound.conf /etc/asound.conf
FLAG=1
fi
FILE=/home/pi/CubeSatSim/sstv_image_1_320_x_256.jpg
if [ ! -f "$FILE" ]; then
echo "Copying SSTV image 1."
cp /home/pi/CubeSatSim/sstv/sstv_image_1_320_x_256.jpg /home/pi/CubeSatSim/sstv_image_1_320_x_256.jpg
fi
FILE=/home/pi/CubeSatSim/sstv_image_2_320_x_256.jpg
if [ ! -f "$FILE" ]; then
echo "Copying SSTV image 2."
cp /home/pi/CubeSatSim/sstv/sstv_image_2_320_x_256.jpg /home/pi/CubeSatSim/sstv_image_2_320_x_256.jpg
fi
grep 'update' /home/pi/CubeSatSim/.updated
if [[ $(grep 'update' /home/pi/CubeSatSim/.updated) ]]; then
echo "update script updated, running again"
/home/pi/CubeSatSim/update
fi
if [ ! -d "/home/pi/PiSSTVpp" ]; then
# sudo apt-get update && sudo apt-get dist-upgrade -y
sudo apt-get update -y
sudo apt-get install -y python-picamera python3-picamera build-essential libgd-dev libmagic-dev
cd
git clone https://github.com/alanbjohnston/PiSSTVpp.git
cd PiSSTVpp
make pisstvpp
cd
sudo raspi-config nonint do_camera 0
fi
if [ ! -d "/home/pi/rpitx" ]; then
cd
git clone https://github.com/alanbjohnston/rpitx.git
cd rpitx
./install.sh
cd
else
if [[ $(grep 'SYNCWITHPWM' /home/pi/rpitx/src/librpitx/src/fskburst.h) ]]; then
echo "rpitx library already updated"
else
echo "updating rpitx"
cd /home/pi/rpitx
git pull
./update.sh
cd
fi
fi
if [ ! -d "/home/pi/WiringPi" ]; then
cd
git clone https://github.com/alanbjohnston/WiringPi
cd WiringPi
./build debian
sudo dpkg -i debian-template/wiringpi-2.61-1.deb
cd
cd CubeSatSim
make debug
FLAG=1
cd
fi
if [ ! -d "/home/pi/ssdv" ]; then
echo "Installing SSDV for FUNcube mode"
cd
git clone https://github.com/alanbjohnston/ssdv.git # install ssdv for FUNcube images
cd ssdv
make
cd
FLAG=1
fi
if [ ! -d "/home/pi/fctelem" ]; then
echo "Installing fctelem binary v0.2 for FUNcube mode"
cd
mkdir /home/pi/fctelem
mkdir /home/pi/fctelem/public_html
cd fctelem
wget https://github.com/alanbjohnston/go/releases/download/v0.2/fctelem.zip
unzip -u fctelem.zip
FLAG=1
elif [ ! -f "/home/pi/fctelem/v0.2" ]; then
echo "Updating fctelem binary to version v0.2 for FUNcube mode"
cd
cd /home/pi/fctelem
sudo mv fctelem fctelem.bk
sudo mv fcdecode.conf fcdecode.conf.bk
sudo mv fctelem.zip fctelem.zip.1
wget https://github.com/alanbjohnston/go/releases/download/v0.2/fctelem.zip
unzip -u fctelem.zip
FLAG=1
fi
if [ ! -f "/home/pi/MPU6050-C-CPP-Library-for-Raspberry-Pi/mpu6050" ]; then
echo "Installing MPU6050-C-CPP-Library-for-Raspberry-Pi"
sudo apt-get install -y libi2c-dev
cd
git clone https://github.com/alanbjohnston/MPU6050-C-CPP-Library-for-Raspberry-Pi.git
cd MPU6050-C-CPP-Library-for-Raspberry-Pi
sudo make install
make payload
fi
cd /home/pi/MPU6050-C-CPP-Library-for-Raspberry-Pi
git checkout master
git pull --no-rebase > .updated_p
if [[ $(grep 'changed' /home/pi/MPU6050-C-CPP-Library-for-Raspberry-Pi/.updated_p) ]]; then
echo "updating MPU6050-C-CPP-Library-for-Raspberry-Pi"
sudo make install
make payload
else
echo "nothing to do for MPU6050-C-CPP-Library-for-Raspberry-Pi."
fi
if [ ! -f "/home/pi/raspberry-pi-bme280/bme280" ]; then
echo "Installing raspberry-pi-bme280"
sudo apt-get install -y libi2c-dev
cd
git clone https://github.com/alanbjohnston/raspberry-pi-bme280.git
cd raspberry-pi-bme280
git checkout payload
make
fi
cd /home/pi/raspberry-pi-bme280
git checkout payload
git pull --no-rebase > .updated_p
if [[ $(grep 'changed' /home/pi/raspberry-pi-bme280/.updated_p) ]]; then
echo "updating raspberry-pi-bme280"
make
else
echo "nothing to do for raspberry-pi-bme280."
fi
if [ ! -f "/home/pi/fcdctl/fcdctl" ]; then
echo "Installing fcdctl to set FUNcubeDongle Pro gain"
sudo rm /var/lib/dpkg/info/python3-pip.list
sudo apt install python3-pip --reinstall
sudo apt-get install -y python3-smbus libusb-1.0
cd
git clone https://github.com/csete/fcdctl.git
cd fcdctl
make fcdpp
fi
cd /home/pi/pi-power-button
git pull --no-rebase > .updated_p
git checkout master
# grep 'changed' /home/pi/pi-power-button/.updated_p
# if [[ $(grep 'changed' /home/pi/pi-power-button/.updated_p) ]]; then
echo "updating pi-power-button."
script/install
FLAG=1
# else
# echo "nothing to do for pi-power-button."
# fi
cd /home/pi/ssdv
git checkout master
git pull --no-rebase > .updated_p
grep 'changed' /home/pi/ssdv/.updated_p
if [[ $(grep 'changed' /home/pi/ssdv/.updated_p) ]]; then
echo "updating ssdv."
# git checkout master
script/install
FLAG=1
else
echo "nothing to do for ssdv."
fi
if [[ $(grep 'dtparam=audio=on' /boot/config.txt) ]]; then
echo "dtparam=audio=on already in /boot/config.txt"
else
echo "adding dtparam=audio=on to /boot/config.txt"
sudo sh -c 'echo "\ndtparam=audio=on" >> /boot/config.txt'
FLAG=1
fi
if [[ $(grep 'dtoverlay=audremap,enable_jack=on' /boot/config.txt) ]]; then
echo "dtoverlay=audremap,enable_jack=on already in /boot/config.txt"
else
echo "adding dtoverlay=audremap,enable_jack=on to /boot/config.txt"
sudo sh -c 'echo "\ndtoverlay=audremap,enable_jack=on" >> /boot/config.txt'
FLAG=1
fi
if [[ $(grep 'dtoverlay=pwm,pin=18,func=2' /boot/config.txt) ]]; then
echo "dtoverlay=pwm,pin=18,func=2 already in /boot/config.txt"
else
echo "adding dtoverlay=pwm,pin=18,func=2 to /boot/config.txt"
sudo sh -c 'echo "\ndtoverlay=pwm,pin=18,func=2" >> /boot/config.txt'
FLAG=1
# cd /home/pi/pi-power-button
# git pull --no-rebase
# git checkout reboot-mode-change
# script/install
## sudo apt-get update && sudo apt-get dist-upgrade -y
# sudo apt-get update -y
# sudo apt-get install -y libjpeg-dev zlib1g-dev libfreetype6-dev liblcms1-dev libopenjp2-7 libtiff5 python3-pil
# sudo pip3 install -y adafruit-blinka RPI.GPIO adafruit-extended-bus adafruit-circuitpython-ina219 pillow
fi
if [[ $(grep 'disable_splash=1' /boot/config.txt) ]]; then
echo "disable_splash=1 already in /boot/config.txt"
else
echo "adding to /boot/config.txt"
sudo sh -c 'echo "\ndisable_splash=1" >> /boot/config.txt'
FLAG=1
fi
if [[ $(grep 'boot_delay=0' /boot/config.txt) ]]; then
echo "boot_delay=0 already in /boot/config.txt"
else
echo "adding to /boot/config.txt"
sudo sh -c 'echo "\nboot_delay=0" >> /boot/config.txt'
FLAG=1
fi
if ! grep -q force_turbo=1 /boot/config.txt ; then
sudo sh -c 'echo "force_turbo=1" >> /boot/config.txt'
FLAG=1
fi
#if [ ! -f "/home/pi/CubeSatSim/telem_string.txt" ]; then
# sudo apt-get update && sudo apt-get dist-upgrade -y
# sudo apt-get install -y libjpeg-dev zlib1g-dev libfreetype6-dev liblcms1-dev libopenjp2-7 libtiff5 -y
# sudo pip3 install pillow
#fi
changed=0
value=`cat /home/pi/CubeSatSim/sim.cfg`
# echo "$value"
echo "$value" > /dev/null
set -- $value
if [ -z "$1" ] ; then n1="AMSAT" ; changed=1 ; else n1=$1 ; fi # callsign
if [ -z "$2" ] ; then n2="0" ; changed=1 ; else n2=$2 ; fi # reset count
if [ -z "$3" ] ; then n3="0" ; changed=1 ; else n3=$3 ; fi # lat
if [ -z "$4" ] ; then n4="0" ; changed=1 ; else n4=$4 ; fi # lon
if [ -z "$5" ] ; then n5="no" ; changed=1 ; else n5=$5 ; fi # sim mode
if [ -z "$6" ] ; then n6="3" ; changed=1 ; else n6=$6 ; fi # squelch
if [ -z "$7" ] ; then n7="434.9000" ; changed=1 ; else n7=$7 ; fi # transmit frequency
if [ -z "$8" ] ; then n8="435.0000" ; changed=1 ; else n8=$8 ; fi # receive frequency
if [ -z "$9" ] ; then n9="no" ; changed=1 ; else n9=$9 ; fi # hab mode
if [ -z "${10}" ] ; then m1="0" ; changed=1 ; else m1=${10} ; fi # rx pl code
if [ -z "${11}" ] ; then m2="0" ; changed=1 ; else m2=${11} ; fi # tx pl code
if [ $changed -eq 1 ]; then
echo -e "Current sim.cfg configuration file:"
echo
echo $1 $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${11}
echo -e "\nCubeSatSim configuration sim.cfg file updated to: \n"
echo
echo $n1 $n2 $n3 $n4 $n5 $n6 $n7 $n8 $n9 $m1 $m2
echo $n1 $n2 $n3 $n4 $n5 $n6 $n7 $n8 $n9 $m1 $m2 > /home/pi/CubeSatSim/sim.cfg
echo
fi
if [ "$noreboot" = "0" ] ; then
if [ $FLAG -eq 1 ]; then
echo "systemctl daemon-reload and reboot"
sudo systemctl daemon-reload
sudo reboot -h now
# sudo cubesatsim
else
grep 'changed' /home/pi/CubeSatSim/.updated
if [[ $(grep 'changed' /home/pi/CubeSatSim/.updated) ]]; then
echo "reboot due to code changes " | wall
sudo reboot -h now
# sudo cubesatsim
else
echo "nothing to do."
fi
fi
else
if [ $FLAG -eq 1 ]; then
echo "reboot needed for changes to take effect" | wall
fi
fi
echo "CubeSatSim update complete."

@ -0,0 +1 @@
install
Loading…
Cancel
Save

Powered by TurnKey Linux.