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
echo -e "\ninstallation script for CubeSatSim v2.2\n"
FLAG=0
checkout=0
BULLSEYE=0
UPDATE=0
if [[ $(grep '11.' /etc/debian_version) ]]; then
echo "Installing on Debian 11 (Bullseye)"
FILE=/home/pi/CubeSatSim/cubesatsim # code has already been compiled
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/cmdline.txt /boot/cmdline.txt.0
sudo raspi-config nonint do_i2c 0
sudo raspi-config nonint do_camera 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=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'
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"
else
echo "adding disable_splash=1 to /boot/config.txt"
@ -106,25 +143,19 @@ echo -e "\ninstallation script for CubeSatSim v2.2\n"
fi
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/cmdline.txt /boot/firmware/cmdline.txt.0
sudo raspi-config nonint do_i2c 0
sudo raspi-config nonint do_camera 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=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'
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"
else
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'
else
echo "Your Pi OS version is not Bookworm."
elif [[ $(grep 'trixie' /etc/os-release) ]]; then
echo "Trixie detected, installation continuing."
echo "Your Pi OS version is not Bookworm or Bullseye."
echo "The software installation will likely not work."
echo "See the README.md for how to install using Bookworm."
echo
@ -232,9 +265,41 @@ fi
FILE=/home/pi/CubeSatSim/sim.cfg
if [ -f "$FILE" ]; then
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
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
if [[ $(grep 'cubesatsim' /etc/motd) ]]; then
@ -259,64 +324,84 @@ else
echo "creating $FILE"
echo "0\n" > /home/pi/CubeSatSim/command_count.txt
fi
touch /home/pi/CubeSatSim/command_control_direwolf
sudo apt-get update && sudo apt-get dist-upgrade -y
sudo apt-get remove pulseaudio -y
sudo apt-get install -y gcc g++ make cmake libasound2-dev libudev-dev libavahi-client-dev libgpiod-dev raspi-config
# 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
# if [ $BULLSEYE -eq 1 ]; then
# sudo apt purge -y python3-pip
# sudo apt install -y python3-pip
# fi
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
sudo systemctl disable gpsd.socket
if [ ! -d "/home/pi/direwolf" ]; then
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
git clone https://github.com/alanbjohnston/WiringPi
cd WiringPi
./build debian
sudo dpkg -i debian-template/wiringpi-2.61-1.deb
cd
if [ ! $BULLSEYE -eq 1 ]; then
sudo apt install -y libtiff6
fi
#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
@ -328,156 +413,267 @@ else
echo "b" > .mode
fi
cd
git clone https://github.com/alanbjohnston/pi-power-button.git
if [ ! -d "/home/pi/pi-power-button" ]; then
cd pi-power-button
git checkout master
cd
git clone https://github.com/alanbjohnston/pi-power-button.git
cd pi-power-button
git checkout master
./script/install
sudo apt-get install -y libraspberrypi-dev
./script/install
sudo apt-get install -y libraspberrypi-dev
cd
fi
echo "Installing SSDV for FUNcube mode"
git clone https://github.com/alanbjohnston/ssdv.git # install ssdv for FUNcube images
cd ssdv
make
cd
cd /home/pi/pi-power-button
echo "Installing fctelem binary v0.2 for FUNcube mode"
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
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
cd
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
echo "updating pi-power-button."
script/install
FLAG=1
fi
cd
git clone https://github.com/alanbjohnston/PiSSTVpp.git
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
if [ ! -d "/home/pi/PiSSTVpp" ]; 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
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
git clone https://github.com/alanbjohnston/rpitx.git
cd rpitx
fi
./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/GPSD_OPTIONS=""/GPSD_OPTIONS="-s 9600"/g' /etc/default/gpsd
changed=0
value=`cat /home/pi/CubeSatSim/sim.cfg`
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 n10="0" ; changed=1 ; else n10=${10} ; fi # rx pl code
if [ -z "${11}" ] ; then n11="0" ; changed=1 ; else n11=${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 $n10 $n11
echo $n1 $n2 $n3 $n4 $n5 $n6 $n7 $n8 $n9 $n10 $n11 > /home/pi/CubeSatSim/sim.cfg
echo
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
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
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
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
cd /home/pi/MPU6050-C-CPP-Library-for-Raspberry-Pi
git checkout master
git pull --no-rebase > .updated_p
cd
sudo apt install python3-venv
sudo python3 -m venv venv
source /home/pi/venv/bin/activate
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
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
sudo /home/pi/venv/bin/pip3 install adafruit-circuitpython-ina219
if [[ $(grep 'changed' /home/pi/raspberry-pi-bme280/.updated_p) ]]; then
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

@ -1,7 +1,7 @@
#!/usr/bin/env python
import RPi.GPIO as GPIO
from RPi.GPIO import output
#import RPi.GPIO as GPIO
#from RPi.GPIO import output
#import subprocess
import time
from time import sleep
@ -14,6 +14,43 @@ import serial
import random
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():
try:
global card
@ -46,7 +83,6 @@ def sim_failure_check():
except:
print("No failure mode")
card = "Headphones"
# card = "Device"
if sim_config:
sim_mode = True
@ -65,9 +101,9 @@ def battery_saver_check():
def blink(times):
powerPin = 16
for i in range(times):
system("gpio -g write " + str(powerPin) + " 0") # blink two times
output(powerPin, 0) # blink
sleep(0.1)
system("gpio -g write " + str(powerPin) + " 1")
output(powerPin, 1)
sleep(0.1)
def increment_mode():
@ -114,13 +150,13 @@ def increment_mode():
file.close()
print(".mode file written")
GPIO.setwarnings(False)
system("gpio -g write " + str(txLed) + " 0")
system("gpio -g write " + str(powerPin) + " 0")
# GPIO.setwarnings(False)
output(txLed, 0)
output(powerPin, 0)
print("sudo reboot -h now")
GPIO.setwarnings(False)
system("gpio -g mode " + str(powerPin) + " out")
system("gpio -g write " + str(powerPin) + " 0");
# GPIO.setwarnings(False)
setup(powerPin, "out")
output(powerPin, 0);
# system("reboot -h now")
# release = True;
@ -181,7 +217,7 @@ def camera_photo():
return True
else:
return False
print("CubeSatSim v2.2 transmit.py starting...")
pd = 21
@ -193,70 +229,52 @@ powerPin = 16
command_tx = True
try:
system("gpio -g write " + str(powerPin) + " 1")
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(13, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(12, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(txc_pin, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(green, GPIO.OUT)
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")
# GPIO.setmode(GPIO.BCM)
# GPIO.setwarnings(False)
setup(13, "up")
setup(12, "up")
setup(27, "up")
setup(txc_pin, "up")
setup(green, "out")
output(powerPin, 1)
transmit = False
txLed = 27
# txLed = 17
txLedOn = 1
txLedOff = 0
if GPIO.input(12) == False:
if input(12) == False:
print("LPF present")
transmit = True
else:
print("No LPF")
# system("gpio -g mode " + str(txLed) + " out")
# system("gpio -g write " + str(txLed) + " 0")
# GPIO.setup(txLed, GPIO.OUT)
# output(txLed, 0)
GPIO.setmode(GPIO.BCM) # Repeat to make LED work on Pi 4
GPIO.setwarnings(False)
try:
system("gpio -g mode " + str(txLed) + " out")
except:
print("Can't set txLed")
# GPIO.setmode(GPIO.BCM) # Repeat to make LED work on Pi 4
# GPIO.setwarnings(False)
setup(txLed, "out")
GPIO.setup(pd, GPIO.OUT)
setup(pd, "out")
#output(pd, 1)
output(pd, 0)
GPIO.setup(ptt, GPIO.OUT)
setup(ptt, "out")
output (ptt, 1)
txc = False
if GPIO.input(txc_pin) == False:
if input(txc_pin) == False:
print("TXC is present")
txc = True;
else:
print("TXC not present")
# txc = False # forcing it off
try:
system("gpio -g write " + str(txLed) + " 1")
sleep(1)
system("gpio -g write " + str(txLed) + " 0")
except:
print("Can't set txLed")
output(txLed, 1)
sleep(1)
output(txLed, 0)
battery_saver_check()
# print(txLedOn)
# print(1)
print(txLed)
# GPIO.setup(27, GPIO.OUT)
# GPIO.output(27, 0)
@ -440,10 +458,10 @@ if __name__ == "__main__":
try:
f = open("/home/pi/CubeSatSim/command_control", "r")
f.close()
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(squelch, GPIO.IN, pull_up_down=GPIO.PUD_UP) ## pull up in case pin is not connected
if GPIO.input(squelch) == False:
# GPIO.setmode(GPIO.BCM)
# GPIO.setwarnings(False)
setup(squelch, "up") ## pull up in case pin is not connected
if input(squelch) == False:
print("squelch not set correctly, no command input!")
else:
if (mode != 'n') and (mode != 'x'):
@ -458,16 +476,10 @@ if __name__ == "__main__":
print(callsign)
GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi 4
try:
print(txLed)
print(txLedOn)
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
# GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi 4
# print(txLed)
# print(1)
# setup(txLed, "out")
query = ["grep", "VERSION_CODENAME=bullseye", "/etc/os-release"]
try:
@ -486,6 +498,9 @@ if __name__ == "__main__":
else:
os_status = "bullseye"
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"]
try:
@ -532,12 +547,9 @@ if __name__ == "__main__":
print("Don't transmit CW ID since APRS HAB mode is active")
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
GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4
try:
system("gpio -g mode " + str(txLed) + " out")
system("gpio -g write " + str(txLed) + " 1")
except:
print("Can't set txLed")
# GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4
# setup(txLed, "out")
output(txLed, 1)
print("Transmit CW ID")
status = ""
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")
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")
try:
system("gpio -g write " + str(txLed) + " 0")
except:
print("Can't set txLed")
output(txLed, 0)
sleep(1)
else:
@ -570,7 +579,7 @@ if __name__ == "__main__":
if (mode == 'a'):
print("AFSK")
else:
# system("gpio -g write " + str(powerPin) + " 0")
# GPIO.output(powerPin, 0)
print("Transmit APRS Commands")
system("sudo systemctl stop command")
# 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("cat /home/pi/CubeSatSim/t.txt")
if (command_tx == True):
GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4
try:
system("gpio -g mode " + str(txLed) + " out")
system("gpio -g write " + str(txLed) + " 1")
except:
print("Can't set txLed")
# GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4
# setup(txLed, "out")
output(txLed, 1)
# output(pd, 1)
# output (ptt, 0)
# sleep(.1)
@ -618,10 +624,7 @@ if __name__ == "__main__":
sleep(0.1)
# output (ptt, 1)
# output(pd, 0)
try:
system("gpio -g write " + str(txLed) + " 0")
except:
print("Can't set txLed")
output(txLed, 0)
system("sudo rm /home/pi/CubeSatSim/ready")
f.close()
@ -651,12 +654,9 @@ if __name__ == "__main__":
system(command)
## chan = chan + 1
if (command_tx == True):
GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4
system("gpio -g mode " + str(txLed) + " out")
try:
system("gpio -g write " + str(txLed) + " 1")
except:
print("Can't set txLed")
# GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4
# setup(txLed, "out")
output(txLed, 1)
if (txc):
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")
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")
try:
system("gpio -g write " + str(txLed) + " 0")
except:
print("Can't set txLed")
output(txLed, 0)
# command_control_check()
sleep(2)
@ -688,21 +685,28 @@ if __name__ == "__main__":
print("SSTV")
# command_control_check()
output (ptt, 1)
output(pd, 1)
print("Testing for camera")
if camera_photo():
output(pd, 1)
try:
# from picamera import PiCamera
# 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
print("camera present")
else:
camera_present = 0
# camera.close()
except:
print("No camera available")
print(" -> if camera plugged in, is software enabled?")
try:
system("gpio -g write " + str(txLed) + " 0")
except:
print("Can't set txLed")
camera_present = 0
# while 1:
output(txLed, 0)
# output (ptt, 1)
# output(pd, 0)
if (camera_present == 1):
@ -714,12 +718,9 @@ if __name__ == "__main__":
if (command_tx == True):
print ("Sending SSTV image")
GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4
try:
system("gpio -g mode " + str(txLed) + " out")
system("gpio -g write " + str(txLed) + " 1")
except:
print("Can't set txLed")
# GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4
# setup(txLed, "out")
output(txLed, 1)
# battery_saver_check()
if (txc):
@ -735,11 +736,8 @@ if __name__ == "__main__":
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")
try:
system("gpio -g write " + str(txLed) + " 0")
except:
print("Can't set txLed")
output(txLed, 0)
# sleep(1)
except:
print("image 2 did not load - copy from CubeSatSim/sstv directory")
@ -753,12 +751,9 @@ if __name__ == "__main__":
if (command_tx == True):
print ("Sending SSTV image")
GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4
try:
system("gpio -g mode " + str(txLed) + " out")
system("gpio -g write " + str(txLed) + " 1")
except:
print("Can't set txLed")
# GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4
# setup(txLed, "out")
output(txLed, 1)
# battery_saver_check()
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")
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")
try:
system("gpio -g write " + str(txLed) + " 0")
except:
print("Can't set txLed")
output(txLed, 0)
# output (ptt, 1)
# output(pd, 0)
@ -796,12 +789,9 @@ if __name__ == "__main__":
if (command_tx == True):
print ("Sending SSTV image")
GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4
try:
system("gpio -g mode " + str(txLed) + " out")
system("gpio -g write " + str(txLed) + " 1")
except:
print("Can't set txLed")
# GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4
# setup(txLed, "out")
output(txLed, 1)
# 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")
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")
try:
system("gpio -g write " + str(txLed) + " 0")
except:
print("Can't set txLed")
output(txLed, 0)
# output (ptt, 1)
# output(pd, 0)
sleep(1)
@ -839,12 +827,9 @@ if __name__ == "__main__":
if (command_tx == True):
print ("Sending SSTV image")
try:
GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4
system("gpio -g mode " + str(txLed) + " out")
system("gpio -g write " + str(txLed) + " 1")
except:
print("Can't set txLed")
# GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4
# setup(txLed, "out")
output(txLed, 1)
# battery_saver_check()
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")
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")
try:
system("gpio -g write " + str(txLed) + " 0")
except:
print("Can't set txLed")
output(txLed, 0)
# output (ptt, 1)
# output(pd, 0)
sleep(10)
@ -875,12 +858,9 @@ if __name__ == "__main__":
if (command_tx == True):
# command_control_check()
GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4
try:
system("gpio -g mode " + str(txLed) + " out")
system("gpio -g write " + str(txLed) + " 1")
except:
print("Can't set txLed")
# GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4
# setup(txLed, "out")
output(txLed, 1)
# battery_saver_check()
@ -893,10 +873,8 @@ if __name__ == "__main__":
# output (pd, 0)
else:
sleep(60)
try:
system("gpio -g write " + str(txLed) + " 0")
except:
print("Can't set txLed")
output(txLed, 0)
# output (ptt, 1)
# output(pd, 0)
sleep(10)
@ -910,11 +888,9 @@ if __name__ == "__main__":
print("turn on FM rx")
output(pd, 1)
output(ptt, 1)
try:
GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi 4
system("gpio -g mode " + str(txLed) + " out")
except:
print("Can't set txLed")
# GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi 4
# setup(txLed, "out")
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 &")
@ -924,26 +900,20 @@ if __name__ == "__main__":
print("Initial image_id: " + str(image_id) + "\n")
while 1:
# print ("LED on")
try:
system("gpio -g write " + str(txLed) + " 0")
except:
print("Can't set txLed")
output(txLed, 0)
sleep(0.4)
# if (command_tx == False):
# system("gpio -g write " + str(txLed) + " 1")
# output(txLed, 1)
# sleep(0.03)
# system("gpio -g write " + str(txLed) + " 0")
# output(txLed, 0)
# command_control_check()
if (command_tx == True):
GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4
try:
system("gpio -g mode " + str(txLed) + " out")
system("gpio -g write " + str(txLed) + " 1")
except:
print("Can't set txLed")
# GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4
# setup(txLed, "out")
output(txLed, 1)
# print(txLed)
# print(txLedOn)
# print(1)
if (mode == 'b'):
sleep(4.2)
@ -979,14 +949,11 @@ if __name__ == "__main__":
print("turn on FM rx")
output(pd, 1)
output(ptt, 1)
GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi 4
try:
system("gpio -g mode " + str(txLed) + " out")
except:
print("Can't set txLed")
# 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
# GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi 4
# setup(txLed, "out")
# GPIO.setup(powerPin, GPIO.OUT)
setup(squelch, "up") ## pull up in case pin is not connected
# GPIO.output(powerPin, 1) # was 0
# txf = float(tx) - 288.9
# print("Transmit frequency: ",txf)
if (command_tx != True):
@ -994,24 +961,18 @@ if __name__ == "__main__":
print("Ready to detect carrier")
while True:
if (GPIO.input(squelch) == False) and (command_tx == True):
if (input(squelch) == False) and (command_tx == True):
print("Carrier detected, starting repeater")
GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4
try:
system("gpio -g mode " + str(txLed) + " out")
system("gpio -g write " + str(txLed) + " 1")
except:
print("Can't set txLed")
# GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4
# setup(txLed, "out")
output(txLed, 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)
system("sudo arecord -D shared_mic -r48000 -fS16_LE -c1 | nc localhost 8011 &")
while (GPIO.input(squelch) == False):
while (input(squelch) == False):
sleep(1)
print("No carrier detected, stopping repeater")
try:
system("gpio -g write " + str(txLed) + " 0")
except:
print("Can't set txLed")
output(txLed, 0)
system("sudo rpitx -i null > /dev/null 2>&1")
system("sudo killall -9 arecord > /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")
output(pd, 1)
output(ptt, 1)
try:
GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi 4
system("gpio -g mode " + str(txLed) + " out")
except:
print("Can't set txLed")
# GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi 4
# setup(txLed, "out")
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 &")
print("Turning LED on/off and listening for carrier")
while 1:
try:
system("gpio -g write " + str(txLed) + " 0")
except:
print("Can't set txLed")
output(txLed, 0)
sleep(0.4)
# if (command_tx == False):
# system("gpio -g write " + str(txLed) + " 1")
# output(txLed, 1)
# sleep(0.03)
# system("gpio -g write " + str(txLed) + " 0")
# output(txLed, 0)
# command_control_check()
if (command_tx == True):
try:
GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4
system("gpio -g mode " + str(txLed) + " out")
system("gpio -g write " + str(txLed) + " 1")
except:
print("Can't set txLed")
if (command_tx == True):
# GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4
# setup(txLed, "out")
output(txLed, 1)
# print(txLed)
# print(txLedOn)
# print(1)
sleep(4.2)
else:
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.