Merge pull request #411 from alanbjohnston/pi-sensors-auto-gps

Pi sensors auto gps
master-psag
Alan Johnston 2 weeks ago committed by GitHub
commit 59b31048d6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -41,9 +41,10 @@ cubesatsim: libax5043.a
cubesatsim: afsk/ax25.o
cubesatsim: afsk/ax5043.o
cubesatsim: TelemEncoding.o
cubesatsim: sensor_extension.o
cubesatsim: main.o
cubesatsim: codecAO40.o
gcc -std=gnu99 $(DEBUG_BEHAVIOR) -o cubesatsim -Wall -Wextra -L./ afsk/ax25.o afsk/ax5043.o TelemEncoding.o codecAO40.o main.o -lwiringPi -lax5043 -lm
gcc -std=gnu99 $(DEBUG_BEHAVIOR) -o cubesatsim -Wall -Wextra -L./ afsk/ax25.o afsk/ax5043.o TelemEncoding.o sensor_extension.o codecAO40.o main.o -lwiringPi -lax5043 -lm
telem: telem.o
gcc -std=gnu99 $(DEBUG_BEHAVIOR) -o telem -Wall -Wextra -L./ telem.o -lwiringPi
@ -52,6 +53,9 @@ TelemEncoding.o: TelemEncoding.c
TelemEncoding.o: TelemEncoding.h
gcc -std=gnu99 $(DEBUG_BEHAVIOR) -Wall -Wextra -c TelemEncoding.c
sensor_extension.o: sensor_extension.c
gcc -std=gnu99 $(DEBUG_BEHAVIOR) -Wall -Wextra -c sensor_extension.c
codecAO40.o: codecAO40.c
codecAO40.o: codecAO40.h
gcc -std=gnu99 $(DEBUG_BEHAVIOR) -Wall -Wextra -c codecAO40.c

477
config

@ -107,7 +107,8 @@ function check_restart {
fi
}
echo "CubeSatSim v2.1 configuration tool"
echo
echo "CubeSatSim v2.2 configuration tool"
echo
# echo $1
# echo $2
@ -115,12 +116,17 @@ echo
sudo modprobe snd-aloop
# if [ "$2" = "n" ] ; then
if [ -z "$2" ] ; then
noreboot=0
else
if [ "$2" = "n" ] ; then
#if [ -z "$2" ] ; then # need to swap else if change
noreboot=1
echo "Reboot disabled"
noreboot=1
else
noreboot=0
fail=$2
fi
fi
# echo "No reboot"
@ -171,7 +177,67 @@ if [ "$1" = "" ]; then
# sim="no"
echo "Simulated Telemetry is OFF"
fi
echo
# echo
FILE=/home/pi/CubeSatSim/failure_mode.txt
if [ -f "$FILE" ]; then
if [[ $(grep "\-1" $FILE) ]]; then
echo "No simulated failure"
else
fail=$(<$FILE)
echo -n "Simulated "
# cat $FILE
case $fail in
1)
echo "+Y Solar Panel Unplugged (1)"
;;
2)
echo "+X Solar Panel Failure (2)"
;;
3)
echo "-X Solar Panel Degredation (3)"
;;
4)
echo "-Y Solar Panel Short Circuit (4)"
;;
5)
echo "Failed I2C Bus 1 (5)"
;;
6)
echo "Failed I2C Bus 3 (6)"
;;
7)
echo "Failed Camera (7)"
;;
8)
echo "Failed Payload (8)"
;;
9)
echo "Failed BME Sensor (9)"
;;
10)
echo "Failed MPU Sensor (10)"
;;
"11")
echo "Failed FM Audio (11)"
;;
*)
echo "Unknown Failure"
;;
esac
# echo $fail
fi
else
echo "No simulated failure"
fi
if [ "${12}" = "y" ] || [ "${12}" = "yes" ] ; then
echo "Random Failure Mode is ON with time period" ${13} "seconds"
else
echo "Random Failure Mode is OFF"
fi
echo -n "TX Frequency is: "
echo -n ${7}
@ -185,7 +251,7 @@ if [ "$1" = "" ]; then
echo "Balloon mode is OFF"
fi
echo
# echo
echo -n "Current command count is: "
cat /home/pi/CubeSatSim/command_count.txt
echo
@ -196,7 +262,7 @@ if [ "$1" = "" ]; then
echo -n "Squelch level is: "
echo $6
echo
# echo
FILE=/home/pi/CubeSatSim/command_control
if [ -f "$FILE" ]; then
@ -215,14 +281,14 @@ if [ "$1" = "" ]; then
echo "Radio command and control is OFF"
fi
echo
# echo
echo -n "RX PL code is: "
echo -n ${10}
# echo
echo -n " TX PL code is: "
echo ${11}
echo
# echo
FILE=/home/pi/CubeSatSim/battery_saver
if [ -f "$FILE" ]; then
@ -231,7 +297,7 @@ if [ "$1" = "" ]; then
echo "Battery saver mode is OFF"
fi
echo
# echo
FILE=/home/pi/CubeSatSim/beacon_off
if [ -f "$FILE" ]; then
echo "Transmit beacon telemetry is OFF"
@ -243,7 +309,7 @@ if [ "$1" = "" ]; then
echo -e "Current sim.cfg configuration file:"
# echo
echo $1 $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${11}
echo $1 $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${11} ${12} ${13}
echo
echo "To change, include an OPTION"
@ -364,7 +430,7 @@ elif [ "$1" = "-t" ]; then
echo
# $1 $2 $3 $4 $5 $6 $7 $8 $9 ${10}
# $1 $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${12} ${13}
echo "Do you want Simulated Telemetry ON (y/n) "
read sim
@ -376,13 +442,14 @@ elif [ "$1" = "-t" ]; then
else
sim="no"
echo "Simulated Telemetry is OFF"
echo "-1" > /home/pi/CubeSatSim/failure_mode.txt # make sure to turn off any simulated failures
fi
# echo
echo -e "\nCubeSatSim configuration sim.cfg file updated to: \n"
# echo
echo $1 $2 $3 $4 $sim $6 $7 $8 $9 ${10} ${11}
echo $1 $2 $3 $4 $sim $6 $7 $8 $9 ${10} ${11} > /home/pi/CubeSatSim/sim.cfg
echo $1 $2 $3 $4 $sim $6 $7 $8 $9 ${10} ${11} ${12} ${13}
echo $1 $2 $3 $4 $sim $6 $7 $8 $9 ${10} ${11} ${12} ${13} > /home/pi/CubeSatSim/sim.cfg
echo
## echo "Rebooting CubeSatSim with new configuration file"
## echo
@ -409,7 +476,7 @@ elif [ "$1" = "-c" ]; then
echo $1
echo
# echo $1 $2 $3 $4 $5 $6 $7 $8 $9 ${10}
# echo $1 $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${12} ${13}
echo "Enter callsign in all capitals: "
read callsign
@ -423,8 +490,8 @@ elif [ "$1" = "-c" ]; then
echo -e "\nCubeSatSim configuration sim.cfg file updated to: \n"
echo $callsign $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${11}
echo $callsign $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${11} > /home/pi/CubeSatSim/sim.cfg
echo $callsign $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${11} ${12} ${13}
echo $callsign $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${11} ${12} ${13} > /home/pi/CubeSatSim/sim.cfg
fi
if [ "$norestart" = "1" ]; then
@ -457,7 +524,7 @@ elif [ "$1" = "-r" ]; then
echo $2
echo
# echo $1 $2 $3 $4 $5 $6 $7 $8 $9 ${10}
# echo $1 $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${11} ${12} ${13}
echo -e "Enter Reset Count (integer): "
@ -477,8 +544,8 @@ elif [ "$1" = "-r" ]; then
echo -e "\nCubeSatSim configuration sim.cfg file updated to: \n"
echo $1 $resets $3 $4 $5 $6 $7 $8 $9 ${10} ${11}
echo $1 $resets $3 $4 $5 $6 $7 $8 $9 ${10} ${11} > /home/pi/CubeSatSim/sim.cfg
echo $1 $resets $3 $4 $5 $6 $7 $8 $9 ${10} ${11} ${12} ${13}
echo $1 $resets $3 $4 $5 $6 $7 $8 $9 ${10} ${11} ${12} ${13} > /home/pi/CubeSatSim/sim.cfg
fi
if [ "$norestart" = "1" ]; then
@ -512,7 +579,7 @@ elif [ "$1" = "-l" ]; then
echo $3
echo
# echo $1 $2 $3 $4 $5 $6 $7 $8 $9 ${10}
# echo $1 $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${11} ${12} ${13}
echo -e "Enter latitude (decimal degrees, positive is north): "
@ -554,8 +621,8 @@ elif [ "$1" = "-l" ]; then
fi
echo -e "\nCubeSatSim configuration sim.cfg file updated to: \n"
echo $1 $2 $lat $long $5 $6 $7 $8 $9 ${10} ${11}
echo $1 $2 $lat $long $5 $6 $7 $8 $9 ${10} ${11} > /home/pi/CubeSatSim/sim.cfg
echo $1 $2 $lat $long $5 $6 $7 $8 $9 ${10} ${11} ${12} ${13}
echo $1 $2 $lat $long $5 $6 $7 $8 $9 ${10} ${11} ${12} ${13} > /home/pi/CubeSatSim/sim.cfg
if [ "$norestart" = "1" ]; then
echo
@ -865,7 +932,7 @@ elif [ "$1" = "-q" ]; then
echo $6
echo
# echo $1 $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${11}
# echo $1 $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${11} ${12} ${13}
echo -e "Enter squelch (integer 1 - 8): "
@ -887,8 +954,8 @@ elif [ "$1" = "-q" ]; then
# echo
echo -e "\nCubeSatSim configuration sim.cfg file updated to: \n"
# echo
echo $1 $2 $3 $4 $5 $sq $7 $8 $9 ${10} ${11}
echo $1 $2 $3 $4 $4 $sq $7 $8 $9 ${10} ${11} > /home/pi/CubeSatSim/sim.cfg
echo $1 $2 $3 $4 $5 $sq $7 $8 $9 ${10} ${11} ${12} ${13}
echo $1 $2 $3 $4 $4 $sq $7 $8 $9 ${10} ${11} ${12} ${13} > /home/pi/CubeSatSim/sim.cfg
echo
echo "Restarting CubeSatSim with new configuration file"
## echo
@ -924,7 +991,7 @@ elif [ "$1" = "-P" ]; then
echo ${11}
echo
# echo $1 $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${11}
# echo $1 $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${11} ${12} ${13}
echo -e "Enter RX PL value integer 0: None, 01-38 CTCSS analog, 39-121CDCSS digital"
@ -967,8 +1034,8 @@ elif [ "$1" = "-P" ]; then
# echo
echo -e "\nCubeSatSim configuration sim.cfg file updated to: \n"
# echo
echo $1 $2 $3 $4 $5 $6 $7 $8 $9 $rxpl $txpl
echo $1 $2 $3 $4 $5 $6 $7 $8 $9 $rxpl $txpl > /home/pi/CubeSatSim/sim.cfg
echo $1 $2 $3 $4 $5 $6 $7 $8 $9 $rxpl $txpl ${12} ${13}
echo $1 $2 $3 $4 $5 $6 $7 $8 $9 $rxpl $txpl ${12} ${13} > /home/pi/CubeSatSim/sim.cfg
echo
## echo "Rebooting CubeSatSim with new configuration file"
## echo
@ -998,7 +1065,7 @@ elif [ "$1" = "-F" ]; then
echo $8
echo
# echo $1 $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${11}
# echo $1 $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${11} ${12} ${13}
echo "Enter tx frequency as 4XX.XXXX: "
read tx
@ -1017,24 +1084,25 @@ elif [ "$1" = "-F" ]; then
rx="$8"
echo "Keeping value of" $rx
fi
# else
echo -e "\nCubeSatSim configuration sim.cfg file updated to: \n"
echo $1 $2 $3 $4 $5 $6 $tx $rx $9 ${10} ${11}
echo $1 $2 $3 $4 $5 $6 $tx $rx $9 ${10} ${11} > /home/pi/CubeSatSim/sim.cfg
# fi
echo $1 $2 $3 $4 $5 $6 $tx $rx $9 ${10} ${11} ${12} ${13}
echo $1 $2 $3 $4 $5 $6 $tx $rx $9 ${10} ${11} ${12} ${13} > /home/pi/CubeSatSim/sim.cfg
# if [ "$norestart" = "1" ]; then
# echo
# else
echo
echo "Restarting CubeSatSim with new configuration file"
## echo
# reboot=1
## sudo reboot now
if [[ $(sudo systemctl is-active gpsd.socket | grep inactive) ]]; then
sudo systemctl restart transmit
# fi
else
echo
echo "temporarily disabling gpsd and rebooting to program FM module"
echo "this will take about 40 seconds"
sudo systemctl stop gpsd.socket
sudo systemctl restart transmit
sleep 10
reboot=1
fi
elif [ "$1" = "-o" ]; then
@ -1105,7 +1173,7 @@ elif [ "$1" = "-H" ]; then
echo
# echo $1 $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${11}
# echo $1 $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${11} ${12} ${13}
echo "Do you want Balloon mode ON (y/n) "
read hab
@ -1122,8 +1190,8 @@ elif [ "$1" = "-H" ]; then
# echo
echo -e "\nCubeSatSim configuration sim.cfg file updated to: \n"
# echo
echo $1 $2 $3 $4 $5 $6 $7 $8 $hab ${10} ${11}
echo $1 $2 $3 $4 $5 $6 $7 $8 $hab ${10} ${11} > /home/pi/CubeSatSim/sim.cfg
echo $1 $2 $3 $4 $5 $6 $7 $8 $hab ${10} ${11} ${12} ${13}
echo $1 $2 $3 $4 $5 $6 $7 $8 $hab ${10} ${11} ${12} ${13} > /home/pi/CubeSatSim/sim.cfg
echo
## echo "Rebooting CubeSatSim with new configuration file"
## echo
@ -1344,6 +1412,321 @@ elif [ "$1" = "-j" ]; then
restart=1
fi
elif [ "$1" = "-M" ]; then
if [ $fail ]; then
MODE=$fail
else
FILE=/home/pi/CubeSatSim/failure_mode.txt
if [ -f "$FILE" ]; then
if [[ $(grep "\-1" $FILE) ]]; then
echo "Currently, no simulated failure (0)"
else
fail=$(<$FILE)
echo -n "Currently, simulated "
case $fail in
1)
echo "+Y Solar Panel Unplugged (1)"
;;
2)
echo "+X Solar Panel Failure (2)"
;;
3)
echo "-X Solar Panel Degredation (3)"
;;
4)
echo "-Y Solar Panel Short Circuit (4)"
;;
5)
echo "Failed I2C Bus 1 (5)"
;;
6)
echo "Failed I2C Bus 3 (6)"
;;
7)
echo "Failed Camera (7)"
;;
8)
echo "Failed Payload (8)"
;;
9)
echo "Failed BME Sensor (9)"
;;
"10")
echo "Failed MPU Sensor (10)"
;;
"11")
echo "Failed FM Audio (11)"
;;
*)
echo "Unknown Failure"
;;
esac
fi
else
echo "Currently, no simulated failure"
fi
echo
echo "Set simulated failure mode (or Return to turn OFF)"
echo
echo " 0 No Failure (turn OFF)"
echo " 1 +Y Solar Panel Unplugged"
echo " 2 +X Solar Panel Failure"
echo " 3 -X Solar Panel Degredation"
echo " 4 -Y Solar Panel Short Circuit"
echo " 5 Failed I2C Bus 1"
echo " 6 Failed I2C Bus 3"
echo " 7 Failed Camera"
echo " 8 Failed Payload"
echo " 9 Failed BME Sensor"
echo "10 Failed MPU Sensor"
echo "11 Failed FM Audio"
echo
echo "Enter the failure number to set: 0 - 11"
read MODE
echo
fi
if [ "$MODE" = "0" ]; then
echo "Setting No Simulated Failure"
MODE=-1
# elif [ "$MODE" = "12" ]; then
# if [ "$norestart" = "1" ]; then
# echo
# else
# reboot=1
# fi
else
case $MODE in
1)
echo "+Y Solar Panel Unplugged"
;;
2)
echo "Setting Simulated +X Solar Panel Failure"
;;
3)
echo "Setting Simulated -X Solar Panel Degredation"
;;
4)
echo "Setting Simulated -Y Solar Panel Short Circuit"
;;
5)
echo "Setting Simulated Failed I2C Bus 1"
;;
6)
echo "Setting Simulated Failed I2C Bus 3"
;;
7)
echo "Setting Simulated Failed Camera"
;;
8)
echo "Setting Simulated Failed Payload"
;;
9)
echo "Setting Simulated Failed BME Sensor"
;;
"10")
echo "Setting Simulated Failed MPU Sensor"
;;
"11")
echo "Setting Failed FM Audio"
;;
*)
echo "Setting No Simulated Failure"
MODE=-1
;;
esac
fi
# echo $MODE
echo
echo $MODE > /home/pi/CubeSatSim/failure_mode.txt
echo "Changing simulated failure mode to $MODE" | wall
elif [ "$1" = "-N" ]; then
FILE=/home/pi/CubeSatSim/failure_mode.txt
if [ -f "$FILE" ]; then
if [[ $(grep "\-1" $FILE) ]]; then
echo "No simulated failure"
fail=0
else
echo "Simulated failure mode"
fail=$(<$FILE)
echo $fail
fi
else
echo "No simulated failure"
fail=0
fi
if [ $fail == 0 ]; then
echo "Changing to next mode"
value=`cat /home/pi/CubeSatSim/.mode`
echo "$value" > /dev/null
set -- $value
if [ "$1" = "a" ]; then
echo "Current mode is APRS"
echo "Next mode is FSK"
/home/pi/CubeSatSim/config -f
elif [ "$1" = "m" ]; then
echo "Current mode is CW"
echo "Next mode is FunCube"
/home/pi/CubeSatSim/config -j
elif [ "$1" = "f" ]; then
echo "Current mode is FSK"
echo "Next mode is BPSK"
/home/pi/CubeSatSim/config -b
elif [ "$1" = "b" ]; then
echo "Current mode is BPSK"
echo "Next mode is SSTV"
/home/pi/CubeSatSim/config -s
elif [ "$1" = "s" ]; then
echo "Current mode is SSTV"
echo "Next mode is CW"
/home/pi/CubeSatSim/config -m
elif [ "$1" = "e" ]; then
echo "Current mode is Repeater"
echo "Next mode is APRS"
/home/pi/CubeSatSim/config -a
elif [ "$1" = "j" ]; then
echo "Current mode is FUNcube"
echo "Next mode is Repeater"
/home/pi/CubeSatSim/config -e
else
echo "Unknown mode"
fi
else
echo "Changing to next simulated failure mode"
fail=$((fail + 1))
# if [ $fail == 12 ]; then
if [ "$fail" -gt "11" ]; then
fail=1
fi
echo $fail
/home/pi/CubeSatSim/config -M $fail
fi
elif [ "$1" = "-U" ]; then
echo
echo "Changing the Random Simulated Failure setting in"
echo "the configuration file for CubeSatSim"
echo
value=`cat /home/pi/CubeSatSim/sim.cfg`
echo "$value" > /dev/null
set -- $value
if [ "${12}" = "yes" ] || [ "${12}" = "y" ]; then
echo "Random Simulated Failure is ON"
else
echo "Random Simulated Failure is OFF"
fi
echo
# $1 $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${12} ${13}
echo "Do you want Random Simulated Failure ON (y/n) "
read sim
echo
if [ "$sim" = "y" ] || [ "$sim" = "yes" ] ; then
sim="yes"
echo "Random Simulated Failure is ON"
echo
echo "A new random failure is selected every"
echo ${13} "seconds."
echo
echo "Enter a new value or Return keeps current value."
echo "Enter time in seconds (integer): "
read time
if [ -z $time ] ; then
time="${13}"
echo "Keeping value of " $time " seconds"
fi
if ! [[ $time =~ ^[0-9]+$ ]] ; then
echo "Error: not an integer!"
time="${13}"
echo "Keeping value of" $time
fi
else
sim="no"
echo "Random Simulated Failure is OFF"
time="${13}"
# echo "-1" > /home/pi/CubeSatSim/failure_mode.txt # make sure to turn off any simulated failures
fi
# echo
echo -e "\nCubeSatSim configuration sim.cfg file updated to: \n"
# echo
echo $1 $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${11} $sim $time
echo $1 $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${11} $sim $time > /home/pi/CubeSatSim/sim.cfg
echo
if [ "${12}" != "$sim" ] || [ "${13}" != "$time" ] ; then
reboot=1
fi
elif [ "$1" = "-u" ]; then
echo
echo "Change gpsd state"
echo
if [[ $(sudo systemctl is-active gpsd.socket | grep inactive) ]]; then
echo "gpsd is inactive"
echo
echo "Do you want to turn gpsd to ON (y/n) "
read reset
echo
if [ "$reset" = "y" ] || [ "$reset" = "yes" ] ; then
echo "gpsd set to ON"
sudo systemctl enable gpsd
sudo systemctl enable gpsd.socket
echo
echo "Unless you configure gpsd otherwise, the gps is connected to serial0 on the Pi."
echo "To monitor your gps device, use the command gpsmon"
echo
reboot=1
fi
else
echo "gpsd is active"
echo
echo "Do you want to turn gpsd to OFF (y/n) "
read reset
echo
if [ "$reset" = "y" ] || [ "$reset" = "yes" ] ; then
echo "gpsd set to OFF"
sudo systemctl disable gpsd
sudo systemctl disable gpsd.socket
reboot=1
fi
fi
elif [ "$1" = "-h" ]; then
echo "config OPTION"
@ -1382,7 +1765,9 @@ elif [ "$1" = "-h" ]; then
echo " -o Change telemetry beacon transmit state"
echo " -L Change microphone level for command and control"
echo " -g Reset configuration back to default settings"
echo " -M Set simulated failure mode"
echo " -U Change the random failure mode setting"
echo " -N Set next mode or failure"
echo
exit

@ -0,0 +1,72 @@
#! /usr/bin/env python3
"""
example Python gpsd client
run this way: python3 example1.py.txt
"""
# from https://gpsd.gitlab.io/gpsd/gpsd-client-example-code.html
# this client is for the CubeSatSim Lite which does not have a Pico microcontroller
import gps # the gpsd interface module
import time
try:
mode = -1
lat = 0
lon = 0
alt = 0
session = gps.gps(mode=gps.WATCH_ENABLE)
start = time.perf_counter()
try:
# while (session.read() == 0) and ((time.perf_counter() - start) < 2) and (mode < 2):
while ((time.perf_counter() - start) < 2) and (mode < 2):
if session.waiting(2.0):
session.read()
# print(gps.MODE_SET)
# print(session.valid)
if (session.valid):
# not useful, probably not a TPV message
# continue
# print('Mode: %s(%d) Time: ' %
# (("Invalid", "NO_FIX", "2D", "3D")[session.fix.mode],
# session.fix.mode), end="")
# print time, if we have it
# print("%d " % session.fix.mode, end="")
if (session.fix.mode > mode):
mode = session.fix.mode
# if gps.TIME_SET & session.valid:
# print(session.fix.time, end="")
# else:
# print('n/a', end="")
if gps.isfinite(session.fix.latitude):
lat = session.fix.latitude
if gps.isfinite(session.fix.longitude):
lon = session.fix.longitude
if gps.isfinite(session.fix.altitude):
alt = session.fix.altitude
# print("%.6f %.6f %.6f" % (session.fix.latitude, session.fix.longitude, session.fix.altitude))
# else:
# print(" 0 0 0")
except KeyboardInterrupt:
# got a ^C. Say bye, bye
print('')
# Got ^C, or fell out of the loop. Cleanup, and leave.
session.close()
print("%d %.6f %.6f %.1f" % (mode, lat, lon, alt))
# exit(0)
except:
print("-1 0 0 0")
exit(0)

@ -1,6 +1,17 @@
#!/bin/bash
echo -e "\ninstallation script for CubeSatSim v2.1\n"
echo -e "\ninstallation script for CubeSatSim v2.2\n"
if [[ $(grep '11.' /etc/debian_version) ]]; then
echo "Installing on Debian 11 (Bullseye)"
else
echo "The OS is not Debian 11 (Bullseye)!"
echo "Installation is not likely to work."
echo "It is recommended you start with"
echo "Bullseye as your OS."
echo
sleep 10
fi
if [[ $(grep 'bullseye' /etc/os-release) ]]; then
echo "Bullseye detected, installation continuing."
@ -61,7 +72,7 @@ sudo apt-get update && sudo apt-get dist-upgrade -y
sudo apt-get remove pulseaudio -y
# 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 apt-get install -y git libasound2-dev i2c-tools build-essential libgd-dev libmagic-dev minicom gpsd gpsd-clients libgps-dev python3-gps
cd /tmp
@ -136,7 +147,7 @@ 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 -o fctelem.zip
unzip -u fctelem.zip
cd
echo "Installing fcdctl to set FUNcubeDongle Pro gain"
@ -285,6 +296,8 @@ sudo raspi-config nonint do_legacy 0
sudo sh -c 'echo "\n" >> /boot/config.txt'
sudo sed -i 's/DEVICES=""/DEVICES="\/dev\/serial0"/g' /etc/default/gpsd
changed=0
value=`cat /home/pi/CubeSatSim/sim.cfg`
echo "$value" > /dev/null

767
main.c

File diff suppressed because it is too large Load Diff

@ -39,24 +39,29 @@
#define PRES 3
#define ALT 4
#define HUMI 5
#define GYRO_X 7 // MPU6050 is posisition 6
#define GYRO_X 7 // MPU6050 label is posisition 6
#define GYRO_Y 8
#define GYRO_Z 9
#define ACCEL_X 10
#define ACCEL_Y 11
#define ACCEL_Z 12
#define GPS1 14 // GPS is position 13
#define GPS2 15
#define GPS3 16
#define DTEMP 18 // TMP is position 17
#define GPS 13 // GPS label
#define GPS1 14 // latitude
#define GPS2 15 // longitude
#define GPS3 16 // altitude
#define DTEMP 18 // TMP label is position 17
#define XS1 20 // NEW user defined token will be position 19
#define XS2 21
#define XS3 22
#define SENSOR_FIELDS 26
#define NEW_SENSOR_FIELDS_MAX 6
#define SENSOR_FIELDS (26 + 6)
#define FC_EPS 1
#define FC_BOB 25
#define FC_SW 50
#define FC_PAYLOAD 55
#define X 0
#define Y 1
#define Z 2
#define RSSI 0
#define IHU_TEMP 2
@ -73,9 +78,6 @@ uint32_t tx_freq_hz = 434900000 + FREQUENCY_OFFSET;
uint8_t data[1024];
uint32_t tx_channel = 0;
ax5043_conf_t hax5043;
ax25_conf_t hax25;
int twosToInt(int val, int len);
float toAprsFormat(float input);
float rnd_float(double min, double max);
@ -101,6 +103,7 @@ int socket_open = 0;
int sock = 0;
int loop = -1, loop_count = 0;
int firstTime = ON; // 0;
int secondTime = ON;
long start;
int testCount = 0;
long time_start;
@ -124,6 +127,21 @@ FILE *image_file;
#define REPEATER 7
#define TXCOMMAND 12
#define FAIL_COUNT 11
#define FAIL_NONE -1
#define FAIL_UNPLUG 1
#define FAIL_SOLAR 2
#define FAIL_DEGRADE 3
#define FAIL_SHORT 4
#define FAIL_I2C1 5
#define FAIL_I2C3 6
#define FAIL_CAMERA 7
#define FAIL_PAYLOAD 8
#define FAIL_BME 9
#define FAIL_MPU 10
#define FAIL_AUDIO 11
int failureMode = FAIL_NONE;
int transmitStatus = -1;
float amplitude; // = ; // 20000; // 32767/(10%amp+5%amp+100%amp)
@ -148,6 +166,8 @@ long int uptime;
char call[5];
char sim_yes[10];
char hab_yes[10];
char fail_yes[10];
int fail_time = 60;
int squelch = 3; // default squelch
char rx[12], tx[12];
int tx_pl = 0;
@ -158,16 +178,16 @@ float sleepTime;
unsigned int sampleTime = 0;
int frames_sent = 0;
int cw_id = ON;
int vB4 = FALSE, vB5 = FALSE, vB3 = FALSE, ax5043 = FALSE, transmit = FALSE, onLed, onLedOn, onLedOff, txLed, txLedOn, txLedOff, payload = OFF;
int transmit = FALSE, onLed, onLedOn, onLedOff, txLed, txLedOn, txLedOff, payload = OFF;
// float voltageThreshold = 3.6, batteryVoltage = 4.5, batteryCurrent = 0, currentThreshold = 100;
float voltageThreshold = 3.5, batteryVoltage = 4.5, batteryCurrent = 0, currentThreshold = 100;
float voltageThreshold = 3.55, batteryVoltage = 4.5, batteryCurrent = 0, currentThreshold = 100;
float latitude = 39.027702f, longitude = -77.078064f;
float lat_file, long_file;
double cpuTemp;
int frameTime;
long int newGpsTime;
float axis[3], angle[3], volts_max[3], amps_max[3], batt, speed, period, tempS, temp_max, temp_min, eclipse;
float axis[3], angle[3], volts_max[3], amps_max[3], batt, speed, period, tempS, temp_max, temp_min, eclipse, atmosphere;
int i2c_bus0 = OFF, i2c_bus1 = OFF, i2c_bus3 = OFF, camera = OFF, sim_mode = FALSE, SafeMode = FALSE;
int rxAntennaDeployed = 0, txAntennaDeployed = 0, c2cStatus = 0;
int sim_config = FALSE; // sim mode not set by configuration
@ -175,6 +195,7 @@ double eclipse_time;
float voltage[9], current[9], sensor[SENSOR_FIELDS], other[3];
char sensor_payload[500];
char sensor_string[SENSOR_FIELDS][32];
int test_i2c_bus(int bus);
@ -211,8 +232,11 @@ int pi_zero_2_offset = 0;
int hab_mode = FALSE;
int fail_rnd_mode = FALSE;
int battery_saver_mode = FALSE;
long int loopTime;
long int failTime = 0;
int gps_status = OFF;
int error_count = 0;
int groundCommandCount = 0;
@ -223,6 +247,9 @@ int groundCommandCount = 0;
int m_ileaver_index; /* Byte counter for interleaver */
unsigned char m_conv_sr; /* Convolutional encoder shift register state */
void sensor_setup(); // defined in sensor_extension.c
int sensor_loop(char *sensor_buffer); // defined in sensor_extension.c
int pi_sensors(char *buffer); // used to read BME and MPU sensor if connected to Pi
// from funcubeLib/common/fecConstants.h

@ -0,0 +1,34 @@
// Use this template for adding additional sensors
// see example ...
// put your library includes here
#include <stdio.h>
#include <string.h>
// put your globals here
// put your setup code here
void sensor_setup() {
// printf("Starting new sensor!\n");
}
// put your loop code here
// Very Important: only use print, not println!!
int sensor_loop(char *sensor_buffer) {
int sensors = 0; // set to the number of sensor readings adding.
sensor_buffer[0] = 0; // make sure buffer is empty
// printf("Reading new sensors!\n");
// sensors = 3;
// strcpy(sensor_buffer, "NEW 0.0 0.0 0.0");
// printf("New sensor string: %s\n", sensor_buffer);
return(sensors);
}

@ -1,4 +1,4 @@
61,TYPE,FIELD,BITS,UNIT,CONVERSION,MODULE,MODULE_NUM,MODULE_LINE,LINE_TYPE,SHORT_NAME,DESCRIPTION
62,TYPE,FIELD,BITS,UNIT,CONVERSION,MODULE,MODULE_NUM,MODULE_LINE,LINE_TYPE,SHORT_NAME,DESCRIPTION
0,realTime,Sensor 2,12,integer,1,Experiments,6,8,3,Sensor 2,STEM Payload Extra Sensor 2
1,realTime,Sensor 3,12,integer,1,Experiments,6,9,3,Sensor 3,STEM Payload Extra Sensor 3
2,realTime,BATT_V,12,V,cubesatsim_voltage|FLOAT2,Battery,4,1,3,Battery Voltage,INA219 Battery Voltage
@ -41,22 +41,23 @@
39,realTime,I2CBus1Failure,1,-,17,Computer Hardware,2,2,0,I2C Bus 1,I2C bus 1 failure indicator
40,realTime,I2CBus3Failure,1,-,17,Computer Hardware,2,3,0,I2C Bus 3,I2C bus 3 failure indicator
41,realTime,CameraFailure,1,-,17,Computer Hardware,2,4,0,Camera,Camera failure indicator
42,realTime,GroundCommands,4,-,1,Computer Software,3,3,0,Ground Commands,Number of ground commands received
42,realTime,GroundCommands,4,-,1,NONE,0,0,0,Ground Commands,Number of ground commands received
43,realTime,RxAntenna,1,-,16,Radio,1,3,0,RX Antenna,Receive antenna status
44,realTime,TxAntenna,1,-,16,Radio,1,2,0,TX Antenna,Transmit antenna status
45,realTime,C2CStatus,2,-,COMMAND_STATUS,Computer Software,3,5,0,Command Control, Command & Control Status
46,realTime,ICR3VProt,12,V,43,NONE,7,2,3,3V Prot,ICR 3V Proteted
47,realTime,ICR2dot5V,12,V,43,NONE,7,3,3,2.5V,ICR 2.5V
48,realTime,ICR2dot5VProt,12,V,43,NONE,7,4,3,2.5V Prot,ICR 2.5V Protected
49,realTime,rf6,12,-,0,NONE,0,0,0,None,None
50,realTime,rf7,12,-,0,NONE,0,0,0,None,None
51,realTime,MuxTest,12,V,43,NONE,7,5,3,Sensor Power,Sensor Power Voltage at the ICR
52,realTime,LtVGACtl,12,V,42,NONE,1,4,3,VGA Control,Control Voltage to the Variable Gain Amplifier (VGA)
53,realTime,pad,4,-,34,NONE,0,0,0,None,Unused
54,realTime,IHUdiagData,32,-,18,NONE,3,2,0,Diagnostic Info,Diagnostic Data on IHU Performance
55,realTime,pad1,1,-,0,NONE,0,0,0,NONE,Filler
56,realTime,wodSize,8,000s,36,NONE,3,3,0,WOD Stored,Number of WOD data payloads kept for each of Science and Housekeeping. In hundreds
57,realTime,swCmds,32,-,35,NONE,7,6,0,Diagnostic,ICR Diagnostic information
58,realTime,hwCmdCnt,6,-,1,NONE,7,7,0,HW Command Count,Number of hardware commands since last reset
59,realTime,swCmdCnt,6,-,1,NONE,7,8,0,SW Command Count,Number of software commands since last reset
60,realTime,pad2,27,-,0,NONE,0,0,0,NONE,Filler
46,realTime,GroundCommands2,10,-,1,Computer Software,3,3,0,Ground Commands,Number of ground commands received
47,realTime,ICR3VProt,12,V,43,NONE,7,2,3,3V Prot,ICR 3V Proteted
48,realTime,ICR2dot5V,12,V,43,NONE,7,3,3,2.5V,ICR 2.5V
49,realTime,ICR2dot5VProt,12,V,43,NONE,7,4,3,2.5V Prot,ICR 2.5V Protected
50,realTime,rf6,12,-,0,NONE,0,0,0,None,None
51,realTime,rf7,12,-,0,NONE,0,0,0,None,None
52,realTime,MuxTest,12,V,43,NONE,7,5,3,Sensor Power,Sensor Power Voltage at the ICR
53,realTime,LtVGACtl,12,V,42,NONE,1,4,3,VGA Control,Control Voltage to the Variable Gain Amplifier (VGA)
54,realTime,pad,4,-,34,NONE,0,0,0,None,Unused
55,realTime,IHUdiagData,32,-,18,NONE,3,2,0,Diagnostic Info,Diagnostic Data on IHU Performance
56,realTime,pad1,1,-,0,NONE,0,0,0,NONE,Filler
57,realTime,wodSize,8,000s,36,NONE,3,3,0,WOD Stored,Number of WOD data payloads kept for each of Science and Housekeeping. In hundreds
58,realTime,swCmds,32,-,35,NONE,7,6,0,Diagnostic,ICR Diagnostic information
59,realTime,hwCmdCnt,6,-,1,NONE,7,7,0,HW Command Count,Number of hardware commands since last reset
60,realTime,swCmdCnt,6,-,1,NONE,7,8,0,SW Command Count,Number of software commands since last reset
61,realTime,pad2,17,-,0,NONE,0,0,0,NONE,Filler

1 61 62 TYPE FIELD BITS UNIT CONVERSION MODULE MODULE_NUM MODULE_LINE LINE_TYPE SHORT_NAME DESCRIPTION
2 0 realTime Sensor 2 12 integer 1 Experiments 6 8 3 Sensor 2 STEM Payload Extra Sensor 2
3 1 realTime Sensor 3 12 integer 1 Experiments 6 9 3 Sensor 3 STEM Payload Extra Sensor 3
4 2 realTime BATT_V 12 V cubesatsim_voltage|FLOAT2 Battery 4 1 3 Battery Voltage INA219 Battery Voltage
41 39 realTime I2CBus1Failure 1 - 17 Computer Hardware 2 2 0 I2C Bus 1 I2C bus 1 failure indicator
42 40 realTime I2CBus3Failure 1 - 17 Computer Hardware 2 3 0 I2C Bus 3 I2C bus 3 failure indicator
43 41 realTime CameraFailure 1 - 17 Computer Hardware 2 4 0 Camera Camera failure indicator
44 42 realTime GroundCommands 4 - 1 Computer Software NONE 3 0 3 0 0 Ground Commands Number of ground commands received
45 43 realTime RxAntenna 1 - 16 Radio 1 3 0 RX Antenna Receive antenna status
46 44 realTime TxAntenna 1 - 16 Radio 1 2 0 TX Antenna Transmit antenna status
47 45 realTime C2CStatus 2 - COMMAND_STATUS Computer Software 3 5 0 Command Control Command & Control Status
48 46 realTime ICR3VProt GroundCommands2 12 10 V - 43 1 NONE Computer Software 7 3 2 3 3 0 3V Prot Ground Commands ICR 3V Proteted Number of ground commands received
49 47 realTime ICR2dot5V ICR3VProt 12 V 43 NONE 7 3 2 3 2.5V 3V Prot ICR 2.5V ICR 3V Proteted
50 48 realTime ICR2dot5VProt ICR2dot5V 12 V 43 NONE 7 4 3 3 2.5V Prot 2.5V ICR 2.5V Protected ICR 2.5V
51 49 realTime rf6 ICR2dot5VProt 12 - V 0 43 NONE 0 7 0 4 0 3 None 2.5V Prot None ICR 2.5V Protected
52 50 realTime rf7 rf6 12 - 0 NONE 0 0 0 None None
53 51 realTime MuxTest rf7 12 V - 43 0 NONE 7 0 5 0 3 0 Sensor Power None Sensor Power Voltage at the ICR None
54 52 realTime LtVGACtl MuxTest 12 V 42 43 NONE 1 7 4 5 3 VGA Control Sensor Power Control Voltage to the Variable Gain Amplifier (VGA) Sensor Power Voltage at the ICR
55 53 realTime pad LtVGACtl 4 12 - V 34 42 NONE 0 1 0 4 0 3 None VGA Control Unused Control Voltage to the Variable Gain Amplifier (VGA)
56 54 realTime IHUdiagData pad 32 4 - 18 34 NONE 3 0 2 0 0 Diagnostic Info None Diagnostic Data on IHU Performance Unused
57 55 realTime pad1 IHUdiagData 1 32 - 0 18 NONE 0 3 0 2 0 NONE Diagnostic Info Filler Diagnostic Data on IHU Performance
58 56 realTime wodSize pad1 8 1 000s - 36 0 NONE 3 0 3 0 0 WOD Stored NONE Number of WOD data payloads kept for each of Science and Housekeeping. In hundreds Filler
59 57 realTime swCmds wodSize 32 8 - 000s 35 36 NONE 7 3 6 3 0 Diagnostic WOD Stored ICR Diagnostic information Number of WOD data payloads kept for each of Science and Housekeeping. In hundreds
60 58 realTime hwCmdCnt swCmds 6 32 - 1 35 NONE 7 7 6 0 HW Command Count Diagnostic Number of hardware commands since last reset ICR Diagnostic information
61 59 realTime swCmdCnt hwCmdCnt 6 - 1 NONE 7 8 7 0 SW Command Count HW Command Count Number of software commands since last reset Number of hardware commands since last reset
62 60 realTime pad2 swCmdCnt 27 6 - 0 1 NONE 0 7 0 8 0 NONE SW Command Count Filler Number of software commands since last reset
63 61 realTime pad2 17 - 0 NONE 0 0 0 NONE Filler

@ -1,4 +1,4 @@
47,TYPE,FIELD,BITS,UNIT,CONVERSION,MODULE,MODULE_NUM,MODULE_LINE,LINE_TYPE,SHORT_NAME,DESCRIPTION
48,TYPE,FIELD,BITS,UNIT,CONVERSION,MODULE,MODULE_NUM,MODULE_LINE,LINE_TYPE,SHORT_NAME,DESCRIPTION
0,RT,Sensor 2,12,integer,1,Experiments,6,8,3,Sensor 2,STEM Payload Extra Sensor 2
1,RT,Sensor 3,12,integer,1,Experiments,6,9,3,Sensor 3,STEM Payload Extra Sensor 3
2,RT,BATT_V,12,V,cubesatsim_voltage|FLOAT2,Battery,4,1,3,Battery Voltage,INA219 Battery Voltage
@ -41,8 +41,9 @@
39,RT,I2CBus1Failure,1,-,17,Computer Hardware,2,2,0,I2C Bus 1,I2C bus 1 failure indicator
40,RT,I2CBus3Failure,1,-,17,Computer Hardware,2,3,0,I2C Bus 3,I2C bus 3 failure indicator
41,RT,CameraFailure,1,-,17,Computer Hardware,2,4,0,Camera,Camera failure indicator
42,RT,GroundCommands,4,-,1,Computer Software,3,3,0,Ground Commands,Number of ground commands received
42,RT,GroundCommands,4,-,1,NONE,0,0,0,Ground Commands,Number of ground commands received
43,RT,RXAntenna,1,-,16,Radio,1,3,0,RX Antenna,Receive antenna status
44,RT,TXAntenna,1,-,16,Radio,1,2,0,TX Antenna,Transmit antenna status
45,RT,C2CStatus,2,-,COMMAND_STATUS,Computer Software,3,5,0,Command Control, Command & Control Status
46,RT,Pad,56,-,0,NONE,0,0,0,NONE,NONE
46,RT,GroundCommands2,10,-,1,Computer Software,3,3,0,Ground Commands,Number of ground commands received
47,RT,Pad,46,-,0,NONE,0,0,0,NONE,NONE

1 47 48 TYPE FIELD BITS UNIT CONVERSION MODULE MODULE_NUM MODULE_LINE LINE_TYPE SHORT_NAME DESCRIPTION
2 0 RT Sensor 2 12 integer 1 Experiments 6 8 3 Sensor 2 STEM Payload Extra Sensor 2
3 1 RT Sensor 3 12 integer 1 Experiments 6 9 3 Sensor 3 STEM Payload Extra Sensor 3
4 2 RT BATT_V 12 V cubesatsim_voltage|FLOAT2 Battery 4 1 3 Battery Voltage INA219 Battery Voltage
41 39 RT I2CBus1Failure 1 - 17 Computer Hardware 2 2 0 I2C Bus 1 I2C bus 1 failure indicator
42 40 RT I2CBus3Failure 1 - 17 Computer Hardware 2 3 0 I2C Bus 3 I2C bus 3 failure indicator
43 41 RT CameraFailure 1 - 17 Computer Hardware 2 4 0 Camera Camera failure indicator
44 42 RT GroundCommands 4 - 1 Computer Software NONE 3 0 3 0 0 Ground Commands Number of ground commands received
45 43 RT RXAntenna 1 - 16 Radio 1 3 0 RX Antenna Receive antenna status
46 44 RT TXAntenna 1 - 16 Radio 1 2 0 TX Antenna Transmit antenna status
47 45 RT C2CStatus 2 - COMMAND_STATUS Computer Software 3 5 0 Command Control Command & Control Status
48 46 RT Pad GroundCommands2 56 10 - 0 1 NONE Computer Software 0 3 0 3 0 NONE Ground Commands NONE Number of ground commands received
49 47 RT Pad 46 - 0 NONE 0 0 0 NONE NONE

@ -1,7 +1,7 @@
These files update the spacecraft files in FoxTelem version 1.13i or later and fix a bug in the payload altitude sensor display.
You can download them as a zip file: [foxtelem_spacecraft_files.zip](https://github.com/user-attachments/files/23217474/foxtelem_spacecraft_files.zip)
You can download them as a zip file: [foxtelem_spacecraft_files.zip](https://github.com/user-attachments/files/23393444/foxtelem_spacecraft_files.zip)
Extract (unzip foxtelem_spacecraft_files) and copy into FoxTelem spacecraft folder, replacing existing files.
Extract (unzip foxtelem_spacecraft_files.zip) and copy into FoxTelem spacecraft folder, replacing existing files.
Next time you run FoxTelem, the CubeSatSim-FSK and CubeSatSim-BPSK spacecraft will be automatically updated.

@ -15,7 +15,7 @@ int main(int argc, char *argv[]) {
}
}
printf("CubeSatSim v2.1 INA219 Voltage and Current Telemetry\n");
printf("CubeSatSim v2.2 INA219 Voltage and Current Telemetry\n");
map[MINUS_X] = MINUS_Y;
map[PLUS_Z] = MINUS_X;
map[MINUS_Y] = PLUS_Z;

@ -11,6 +11,31 @@ from os import system
from PIL import Image, ImageDraw, ImageFont, ImageColor
import serial
import random
import subprocess
def sim_failure_check():
try:
global card
global cam_fail
cam_fail = False
file = open("/home/pi/CubeSatSim/failure_mode.txt")
fail_mode = int(file.read(2))
# print("Fail_mode: ")
# print(fail_mode)
if (fail_mode == 11):
card = "Device" # Change audio so no FM audio plays
print("Failure mode no FM audio")
elif (fail_mode == 7):
cam_fail = True
print("Failure mode camera fail")
elif (fail_mode == -1):
print("No failure mode")
else:
print("Other failure mode")
card = "Headphones"
except:
print("No failure mode")
card = "Headphones"
def battery_saver_check():
try:
@ -95,6 +120,8 @@ def increment_mode():
print("can't write to .mode file")
def camera_photo():
global cam_fail
sim_failure_check()
system("sudo rm /home/pi/CubeSatSim/camera_out.jpg")
stored_image = False
try:
@ -102,6 +129,10 @@ def camera_photo():
f = open("/home/pi/CubeSatSim/camera_out.jpg")
f.close()
print("Photo taken")
if (cam_fail == True):
system("cp /home/pi/CubeSatSim/sstv//sstv_image_2_320_x_256.jpeg /home/pi/CubeSatSim/camera_out.jpg")
print("Using stored image")
stored_image = True
except:
system("cp /home/pi/CubeSatSim/sstv//sstv_image_2_320_x_256.jpeg /home/pi/CubeSatSim/camera_out.jpg")
print("Using stored image")
@ -126,11 +157,11 @@ def camera_photo():
# draw.text((120, 10), telem_string, font=font2, fill='white')
draw.text((12, 12), callsign, font=font1, fill='black')
draw.text((10, 10), callsign, font=font1, fill='white')
draw.text((122, 12), telem_string, font=font2, fill='black')
draw.text((120, 10), telem_string, font=font2, fill='white')
draw.text((112, 12), telem_string, font=font2, fill='black') # was 122
draw.text((110, 10), telem_string, font=font2, fill='white') # was 120
img.save(file)
print("CubeSatSim v2.1 transmit.py starting...")
print("CubeSatSim v2.2 transmit.py starting...")
pd = 21
ptt = 20
@ -368,7 +399,20 @@ if __name__ == "__main__":
card = "Headphones" # default using pcm audio output of Pi Zero
# card = "Device" # using USB sound card for audio output
if (mode != 'e'):
query = ["sudo", "systemctl", "is-active", "gpsd.socket"]
try:
result = subprocess.run(query, capture_output=True, text=True, check=True)
print(f"Command run was: {query}")
gpsd_status = result.stdout.strip()
print(f"Output of the command (stdout): {gpsd_status}")
except subprocess.CalledProcessError as e:
# print(f"Command failed with return code: {e.returncode}")
print(f"Command run was: {e.cmd}")
gpsd_status = e.stdout.strip()
print(f"Output of the command (stdout): {e.stdout}")
# print(f"Error output of the command (stderr): {e.stderr}")
if (mode != 'e') and (gpsd_status != "active"):
print("Programming FM module!\n");
output(pd, 1)
output (ptt, 1)
@ -450,6 +494,7 @@ if __name__ == "__main__":
#
# battery_saver_check()
if (txc):
sim_failure_check()
# output(pd, 1)
sleep(0.1) # add delay before transmit
output (ptt, 0)
@ -476,6 +521,7 @@ if __name__ == "__main__":
print("Ready for next packet!")
sleep(0.5)
except:
# command_control_check()
sleep(1)
@ -502,6 +548,7 @@ if __name__ == "__main__":
output(txLed, txLedOn)
if (txc):
sim_failure_check()
# output (pd, 1)
sleep(0.3)
output (ptt, 0)
@ -563,6 +610,7 @@ if __name__ == "__main__":
# battery_saver_check()
if (txc):
sim_failure_check()
# output(pd, 1)
output (ptt, 0)
system("aplay -D plughw:CARD=" + card + ",DEV=0 /home/pi/CubeSatSim/sstv_image_2_320_x_256.jpg.wav")
@ -582,34 +630,6 @@ if __name__ == "__main__":
while 1:
# command_control_check()
camera_photo()
## system("raspistill -o /home/pi/CubeSatSim/camera_out.jpg -w 320 -h 256") # > /dev/null 2>&1")
## print("Photo taken")
##
## file='/home/pi/CubeSatSim/camera_out.jpg'
## font1 = ImageFont.truetype('DejaVuSerif.ttf', 20)
## font2 = ImageFont.truetype('DejaVuSerif-Bold.ttf', 16)
##
## try:
## filep = open("/home/pi/CubeSatSim/telem_string.txt")
## telem_string = filep.readline()
## except:
## telem_string = ""
## if (debug_mode == 1):
## print("Can't read telem_string.txt")
## print(telem_string)
##
## img = Image.open(file)
## draw = ImageDraw.Draw(img)
# draw.text((10, 10), callsign, font=font2, fill='white')
# draw.text((120, 10), telem_string, font=font2, fill='white')
## draw.text((12, 12), callsign, font=font1, fill='black')
## draw.text((10, 10), callsign, font=font1, fill='white')
## draw.text((122, 12), telem_string, font=font2, fill='black')
## draw.text((120, 10), telem_string, font=font2, fill='white')
## img.save(file)
# command_control_check()
system("/home/pi/PiSSTVpp/pisstvpp -r 48000 -p s2 /home/pi/CubeSatSim/camera_out.jpg")
system("sudo rm /home/pi/CubeSatSim/camera_out.jpg > /dev/null 2>&1")
@ -623,6 +643,7 @@ if __name__ == "__main__":
# battery_saver_check()
if (txc):
sim_failure_check()
# output(pd, 1)
output (ptt, 0)
system("aplay -D plughw:CARD=" + card + ",DEV=0 /home/pi/CubeSatSim/camera_out.jpg.wav")
@ -660,6 +681,7 @@ if __name__ == "__main__":
# battery_saver_check()
if (txc):
sim_failure_check()
# output(pd, 1)
output (ptt, 0)
system("aplay -D plughw:CARD=" + card + ",DEV=0 /home/pi/CubeSatSim/sstv_image_1_320_x_256.jpg.wav")
@ -696,6 +718,7 @@ if __name__ == "__main__":
# battery_saver_check()
if (txc):
sim_failure_check()
# output(pd, 1)
output (ptt, 0)
system("aplay -D plughw:CARD=" + card + ",DEV=0 /home/pi/CubeSatSim/sstv_image_1_320_x_256.jpg.wav")
@ -727,6 +750,7 @@ if __name__ == "__main__":
# battery_saver_check()
if (txc):
sim_failure_check()
# output(pd, 1)
output (ptt, 0)
system("aplay -D plughw:CARD=" + card + ",DEV=0 /home/pi/CubeSatSim/sstv.wav")

@ -1,6 +1,6 @@
#!/bin/bash
echo -e "\nupdate script for CubeSatSim v2.1\n"
echo -e "\nupdate script for CubeSatSim v2.2\n"
FLAG=0
checkout=0
@ -31,10 +31,12 @@ 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
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
@ -49,6 +51,11 @@ sudo sed -i 's/console=tty1 r/console=tty1 maxcpus=1 r/g' /boot/cmdline.txt # si
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 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
@ -236,7 +243,7 @@ if [ ! -d "/home/pi/fctelem" ]; then
mkdir /home/pi/fctelem/public_html
cd fctelem
wget https://github.com/alanbjohnston/go/releases/download/v0.2/fctelem.zip
unzip 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"
@ -246,15 +253,61 @@ elif [ ! -f "/home/pi/fctelem/v0.2" ]; then
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 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 -y
sudo apt-get install -y python3-smbus libusb-1.0
cd
git clone https://github.com/csete/fcdctl.git
cd fcdctl
@ -263,24 +316,22 @@ fi
cd /home/pi/pi-power-button
git checkout master
git pull --no-rebase > .updated_p
grep 'changed' /home/pi/pi-power-button/.updated_p
if [[ $(grep 'changed' /home/pi/pi-power-button/.updated_p) ]]; then
git checkout master
echo "updating pi-power-button."
# grep 'changed' /home/pi/pi-power-button/.updated_p
# if [[ $(grep 'changed' /home/pi/pi-power-button/.updated_p) ]]; then
# git checkout master
echo "updating pi-power-button."
script/install
FLAG=1
else
echo "nothing to do for pi-power-button."
fi
# else
# echo "nothing to do for pi-power-button."
# fi
cd /home/pi/ssdv

Loading…
Cancel
Save

Powered by TurnKey Linux.