Merge pull request #386 from alanbjohnston/sim-fail-4

Random failure mode, push button to next failure mode
pull/395/head
Alan Johnston 4 months ago committed by GitHub
commit fd5353db4a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

326
config

@ -54,7 +54,7 @@ function transmit_command_fsk {
echo "Resuming command and control" echo "Resuming command and control"
sudo systemctl start command sudo systemctl start command
else
STRING="AMSAT-11>APCSS:=3901.40N\07704.39WShi hi MODE=f" STRING="AMSAT-11>APCSS:=3901.40N\07704.39WShi hi MODE=f"
sudo rm /home/pi/CubeSatSim/t.txt > /dev/null 2>&1 sudo rm /home/pi/CubeSatSim/t.txt > /dev/null 2>&1
@ -89,7 +89,7 @@ function transmit_command_bpsk {
echo "Resuming command and control" echo "Resuming command and control"
sudo systemctl start command sudo systemctl start command
else
STRING="AMSAT-11>APCSS:=3901.40N\07704.39WShi hi MODE=b" STRING="AMSAT-11>APCSS:=3901.40N\07704.39WShi hi MODE=b"
sudo rm /home/pi/CubeSatSim/t.txt > /dev/null 2>&1 sudo rm /home/pi/CubeSatSim/t.txt > /dev/null 2>&1
@ -292,37 +292,40 @@ if [ "$1" = "" ]; then
# cat $FILE # cat $FILE
case $fail in case $fail in
1) 1)
echo "+X Solar Panel Failure" echo "+Y Solar Panel Unplugged (1)"
;; ;;
2) 2)
echo "-X Solar Panel Degredation" echo "+X Solar Panel Failure (2)"
;; ;;
3) 3)
echo "-Y Solar Panel Short Circuit" echo "-X Solar Panel Degredation (3)"
;; ;;
4) 4)
echo "Failed I2C Bus 1" echo "-Y Solar Panel Short Circuit (4)"
;; ;;
5) 5)
echo "Failed I2C Bus 3" echo "Failed I2C Bus 1 (5)"
;; ;;
6) 6)
echo "Failed Camera" echo "Failed I2C Bus 3 (6)"
;; ;;
7) 7)
echo "Failed Payload" echo "Failed Camera (7)"
;; ;;
8) 8)
echo "Failed BME Sensor" echo "Failed Payload (8)"
;; ;;
9) 9)
echo "Failed MPU Sensor" echo "Failed BME Sensor (9)"
;;
10)
echo "Failed MPU Sensor (10)"
;;
"11")
echo "Failed FM Audio (11)"
;; ;;
# "10")
# echo "Failed FM Audio"
# ;;
*) *)
echo "Unknown Failure" echo "Unknown Failure"
;; ;;
@ -332,7 +335,12 @@ if [ "$1" = "" ]; then
else else
echo "No simulated failure" echo "No simulated failure"
fi fi
# echo
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
if [ "$9" = "yes" ] || [ "$9" = "y" ]; then if [ "$9" = "yes" ] || [ "$9" = "y" ]; then
echo "Balloon mode is ON" echo "Balloon mode is ON"
@ -398,7 +406,7 @@ if [ "$1" = "" ]; then
echo -e "Current sim.cfg configuration file:" echo -e "Current sim.cfg configuration file:"
# echo # 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
echo "To change, include an OPTION" echo "To change, include an OPTION"
@ -544,7 +552,7 @@ elif [ "$1" = "-t" ]; then
echo 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) " echo "Do you want Simulated Telemetry ON (y/n) "
read sim read sim
@ -562,8 +570,8 @@ elif [ "$1" = "-t" ]; then
# echo # echo
echo -e "\nCubeSatSim configuration sim.cfg file updated to: \n" echo -e "\nCubeSatSim configuration sim.cfg file updated to: \n"
# echo # 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} ${12} ${13}
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} > /home/pi/CubeSatSim/sim.cfg
echo echo
## echo "Rebooting CubeSatSim with new configuration file" ## echo "Rebooting CubeSatSim with new configuration file"
## echo ## echo
@ -590,7 +598,7 @@ elif [ "$1" = "-c" ]; then
echo $1 echo $1
echo 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: " echo "Enter callsign in all capitals: "
read callsign read callsign
@ -604,8 +612,8 @@ elif [ "$1" = "-c" ]; then
echo -e "\nCubeSatSim configuration sim.cfg file updated to: \n" 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} ${12} ${13}
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} > /home/pi/CubeSatSim/sim.cfg
fi fi
if [ "$norestart" = "1" ]; then if [ "$norestart" = "1" ]; then
@ -638,7 +646,7 @@ elif [ "$1" = "-r" ]; then
echo $2 echo $2
echo 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): " echo -e "Enter Reset Count (integer): "
@ -658,8 +666,8 @@ elif [ "$1" = "-r" ]; then
echo -e "\nCubeSatSim configuration sim.cfg file updated to: \n" 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} ${12} ${13}
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} > /home/pi/CubeSatSim/sim.cfg
fi fi
if [ "$norestart" = "1" ]; then if [ "$norestart" = "1" ]; then
@ -693,7 +701,7 @@ elif [ "$1" = "-l" ]; then
echo $3 echo $3
echo 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): " echo -e "Enter latitude (decimal degrees, positive is north): "
@ -735,8 +743,8 @@ elif [ "$1" = "-l" ]; then
fi fi
echo -e "\nCubeSatSim configuration sim.cfg file updated to: \n" 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} ${12} ${13}
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} > /home/pi/CubeSatSim/sim.cfg
if [ "$norestart" = "1" ]; then if [ "$norestart" = "1" ]; then
echo echo
@ -1028,7 +1036,7 @@ elif [ "$1" = "-q" ]; then
echo $6 echo $6
echo 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): " echo -e "Enter squelch (integer 1 - 8): "
@ -1050,8 +1058,8 @@ elif [ "$1" = "-q" ]; then
# echo # echo
echo -e "\nCubeSatSim configuration sim.cfg file updated to: \n" echo -e "\nCubeSatSim configuration sim.cfg file updated to: \n"
# echo # echo
echo $1 $2 $3 $4 $5 $sq $7 $8 $9 ${10} ${11} 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} > /home/pi/CubeSatSim/sim.cfg echo $1 $2 $3 $4 $4 $sq $7 $8 $9 ${10} ${11} ${12} ${13} > /home/pi/CubeSatSim/sim.cfg
echo echo
echo "Restarting CubeSatSim with new configuration file" echo "Restarting CubeSatSim with new configuration file"
## echo ## echo
@ -1073,7 +1081,7 @@ elif [ "$1" = "-P" ]; then
echo echo
echo "Editing the PL (Private Line) CTCSS/CDCSS setting in" echo "Editing the PL (Private Line) CTCSS/CDCSS setting in"
echo "the configuration file for CubeSatSim" echo "the configuration file for CubeSatSim"
echo echo
value=`cat /home/pi/CubeSatSim/sim.cfg` value=`cat /home/pi/CubeSatSim/sim.cfg`
@ -1087,7 +1095,7 @@ elif [ "$1" = "-P" ]; then
echo ${11} echo ${11}
echo 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" echo -e "Enter RX PL value integer 0: None, 01-38 CTCSS analog, 39-121CDCSS digital"
@ -1130,8 +1138,8 @@ elif [ "$1" = "-P" ]; then
# echo # echo
echo -e "\nCubeSatSim configuration sim.cfg file updated to: \n" echo -e "\nCubeSatSim configuration sim.cfg file updated to: \n"
# echo # 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 ${12} ${13}
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} > /home/pi/CubeSatSim/sim.cfg
echo echo
## echo "Rebooting CubeSatSim with new configuration file" ## echo "Rebooting CubeSatSim with new configuration file"
## echo ## echo
@ -1161,7 +1169,7 @@ elif [ "$1" = "-F" ]; then
echo $8 echo $8
echo 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: " echo "Enter tx frequency as 4XX.XXXX: "
read tx read tx
@ -1184,8 +1192,8 @@ elif [ "$1" = "-F" ]; then
echo -e "\nCubeSatSim configuration sim.cfg file updated to: \n" 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} ${12} ${13}
echo $1 $2 $3 $4 $5 $6 $tx $rx $9 ${10} ${11} > /home/pi/CubeSatSim/sim.cfg echo $1 $2 $3 $4 $5 $6 $tx $rx $9 ${10} ${11} ${12} ${13} > /home/pi/CubeSatSim/sim.cfg
# fi # fi
# if [ "$norestart" = "1" ]; then # if [ "$norestart" = "1" ]; then
@ -1267,7 +1275,7 @@ elif [ "$1" = "-H" ]; then
echo 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) " echo "Do you want Balloon mode ON (y/n) "
read hab read hab
@ -1284,8 +1292,8 @@ elif [ "$1" = "-H" ]; then
# echo # echo
echo -e "\nCubeSatSim configuration sim.cfg file updated to: \n" echo -e "\nCubeSatSim configuration sim.cfg file updated to: \n"
# echo # 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} ${12} ${13}
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} > /home/pi/CubeSatSim/sim.cfg
echo echo
## echo "Rebooting CubeSatSim with new configuration file" ## echo "Rebooting CubeSatSim with new configuration file"
## echo ## echo
@ -1498,42 +1506,45 @@ elif [ "$1" = "-M" ]; then
FILE=/home/pi/CubeSatSim/failure_mode.txt FILE=/home/pi/CubeSatSim/failure_mode.txt
if [ -f "$FILE" ]; then if [ -f "$FILE" ]; then
if [[ $(grep "\-1" $FILE) ]]; then if [[ $(grep "\-1" $FILE) ]]; then
echo "Currently, no simulated failure" echo "Currently, no simulated failure (0)"
else else
fail=$(<$FILE) fail=$(<$FILE)
echo -n "Currently, simulated " echo -n "Currently, simulated "
case $fail in case $fail in
1) 1)
echo "+X Solar Panel Failure" echo "+Y Solar Panel Unplugged (1)"
;; ;;
2) 2)
echo "-X Solar Panel Degredation" echo "+X Solar Panel Failure (2)"
;; ;;
3) 3)
echo "-Y Solar Panel Short Circuit" echo "-X Solar Panel Degredation (3)"
;; ;;
4) 4)
echo "Failed I2C Bus 1" echo "-Y Solar Panel Short Circuit (4)"
;; ;;
5) 5)
echo "Failed I2C Bus 3" echo "Failed I2C Bus 1 (5)"
;; ;;
6) 6)
echo "Failed Camera" echo "Failed I2C Bus 3 (6)"
;; ;;
7) 7)
echo "Failed Payload" echo "Failed Camera (7)"
;; ;;
8) 8)
echo "Failed BME Sensor" echo "Failed Payload (8)"
;; ;;
9) 9)
echo "Failed MPU Sensor" echo "Failed BME Sensor (9)"
;;
"10")
echo "Failed MPU Sensor (10)"
;;
"11")
echo "Failed FM Audio (11)"
;; ;;
# "10")
# echo "Failed FM Audio"
# ;;
*) *)
echo "Unknown Failure" echo "Unknown Failure"
;; ;;
@ -1548,20 +1559,20 @@ elif [ "$1" = "-M" ]; then
echo echo
echo " 0 No Failure (turn OFF)" echo " 0 No Failure (turn OFF)"
echo " 1 +X Solar Panel Failure" echo " 1 +Y Solar Panel Unplugged"
echo " 2 -X Solar Panel Degredation" echo " 2 +X Solar Panel Failure"
echo " 3 -Y Solar Panel Short Circuit" echo " 3 -X Solar Panel Degredation"
echo " 4 Failed I2C Bus 1" echo " 4 -Y Solar Panel Short Circuit"
echo " 5 Failed I2C Bus 3" echo " 5 Failed I2C Bus 1"
echo " 6 Failed Camera" echo " 6 Failed I2C Bus 3"
echo " 7 Failed Payload" echo " 7 Failed Camera"
echo " 8 Failed BME Sensor" echo " 8 Failed Payload"
echo " 9 Failed MPU Sensor" echo " 9 Failed BME Sensor"
# echo "10 Failed FM Audio" echo "10 Failed MPU Sensor"
echo "11 Failed FM Audio"
echo echo
# echo "Enter the failure number to set: 0 - 10" # 10 sometimes gets stuck on carrier echo "Enter the failure number to set: 0 - 11"
echo "Enter the failure number to set: 0 - 9"
read MODE read MODE
echo echo
fi fi
@ -1569,39 +1580,49 @@ elif [ "$1" = "-M" ]; then
if [ "$MODE" = "0" ]; then if [ "$MODE" = "0" ]; then
echo "Setting No Simulated Failure" echo "Setting No Simulated Failure"
MODE=-1 MODE=-1
# elif [ "$MODE" = "12" ]; then
# if [ "$norestart" = "1" ]; then
# echo
# else
# reboot=1
# fi
else else
case $MODE in case $MODE in
1) 1)
echo "+Y Solar Panel Unplugged"
;;
2)
echo "Setting Simulated +X Solar Panel Failure" echo "Setting Simulated +X Solar Panel Failure"
;; ;;
2) 3)
echo "Setting Simulated -X Solar Panel Degredation" echo "Setting Simulated -X Solar Panel Degredation"
;; ;;
3) 4)
echo "Setting Simulated -Y Solar Panel Short Circuit" echo "Setting Simulated -Y Solar Panel Short Circuit"
;; ;;
4) 5)
echo "Setting Simulated Failed I2C Bus 1" echo "Setting Simulated Failed I2C Bus 1"
;; ;;
5) 6)
echo "Setting Simulated Failed I2C Bus 3" echo "Setting Simulated Failed I2C Bus 3"
;; ;;
6) 7)
echo "Setting Simulated Failed Camera" echo "Setting Simulated Failed Camera"
;; ;;
7) 8)
echo "Setting Simulated Failed Payload" echo "Setting Simulated Failed Payload"
;; ;;
8) 9)
echo "Setting Simulated Failed BME Sensor" echo "Setting Simulated Failed BME Sensor"
;; ;;
9) "10")
echo "Setting Simulated Failed MPU Sensor" echo "Setting Simulated Failed MPU Sensor"
;; ;;
# "10") "11")
# echo "Setting Failed FM Audio" echo "Setting Failed FM Audio"
# ;; ;;
*) *)
echo "Setting No Simulated Failure" echo "Setting No Simulated Failure"
MODE=-1 MODE=-1
@ -1613,6 +1634,144 @@ elif [ "$1" = "-M" ]; then
echo echo
echo $MODE > /home/pi/CubeSatSim/failure_mode.txt 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" = "-h" ]; then elif [ "$1" = "-h" ]; then
echo "config OPTION" echo "config OPTION"
@ -1651,7 +1810,8 @@ elif [ "$1" = "-h" ]; then
echo " -L Change microphone level for command and control" echo " -L Change microphone level for command and control"
echo " -g Reset configuration back to default settings" echo " -g Reset configuration back to default settings"
echo " -M Set simulated failure mode" echo " -M Set simulated failure mode"
echo " -U Change the random failure mode setting"
echo " -N Set next mode or failure"
echo echo
exit exit

@ -2,6 +2,16 @@
echo -e "\ninstallation script for CubeSatSim v2.2\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 "This is not Debian 11 (Bullseye)!"
echo "Installation is not likely to work."
echo "Recommend you start with a Bullseye."
echo
sleep 10
fi
FILE=/home/pi/CubeSatSim/sim.cfg FILE=/home/pi/CubeSatSim/sim.cfg
if [ -f "$FILE" ]; then if [ -f "$FILE" ]; then
echo "$FILE exists." echo "$FILE exists."

@ -28,7 +28,8 @@ int main(int argc, char * argv[]) {
printf("\n\nCubeSatSim v2.2 starting...\n\n"); printf("\n\nCubeSatSim v2.2 starting...\n\n");
wiringPiSetup(); wiringPiSetup();
strcpy(fail_yes, "no");
// Open configuration file with callsign and reset count // Open configuration file with callsign and reset count
FILE * config_file = fopen("/home/pi/CubeSatSim/sim.cfg", "r"); FILE * config_file = fopen("/home/pi/CubeSatSim/sim.cfg", "r");
if (config_file == NULL) { if (config_file == NULL) {
@ -41,11 +42,11 @@ int main(int argc, char * argv[]) {
// char * cfg_buf[100]; // char * cfg_buf[100];
fscanf(config_file, "%s %d %f %f %s %d %s %s %s %d %d", fscanf(config_file, "%s %d %f %f %s %d %s %s %s %d %d %s %d",
call, & reset_count, & lat_file, & long_file, sim_yes, & squelch, tx, rx, hab_yes, & rx_pl, & tx_pl); call, &reset_count, &lat_file, &long_file, sim_yes, &squelch, tx, rx, hab_yes, &rx_pl, &tx_pl, fail_yes, &fail_time);
fclose(config_file); fclose(config_file);
fprintf(stderr,"Config file /home/pi/CubeSatSim/sim.cfg contains %s %d %f %f %s %d %s %s %s %d %d\n", fprintf(stderr,"Config file /home/pi/CubeSatSim/sim.cfg contains %s %d %f %f %s %d %s %s %s %d %d %s %d\n",
call, reset_count, lat_file, long_file, sim_yes, squelch, tx, rx, hab_yes, rx_pl, tx_pl); call, reset_count, lat_file, long_file, sim_yes, squelch, tx, rx, hab_yes, rx_pl, tx_pl, fail_yes, fail_time);
fprintf(stderr, "Transmit on %s MHz Receive on %s MHz\n", tx, rx); fprintf(stderr, "Transmit on %s MHz Receive on %s MHz\n", tx, rx);
@ -86,6 +87,10 @@ int main(int argc, char * argv[]) {
hab_mode = TRUE; hab_mode = TRUE;
fprintf(stderr, "HAB mode is ON\n"); fprintf(stderr, "HAB mode is ON\n");
} }
if (strcmp(fail_yes, "yes") == 0) {
fail_rnd_mode = TRUE;
fprintf(stderr, "Random fail mode is ON\n");
}
FILE * command_file = fopen("/home/pi/CubeSatSim/command_control", "r"); FILE * command_file = fopen("/home/pi/CubeSatSim/command_control", "r");
if (command_file == NULL) { if (command_file == NULL) {
@ -289,7 +294,8 @@ int main(int argc, char * argv[]) {
} }
config_file = fopen("sim.cfg", "w"); config_file = fopen("sim.cfg", "w");
fprintf(config_file, "%s %d %8.4f %8.4f %s %d %s %s %s %d %d", call, reset_count, lat_file, long_file, sim_yes, squelch, tx, rx, hab_yes, rx_pl, tx_pl); fprintf(config_file, "%s %d %8.4f %8.4f %s %d %s %s %s %d %d %s %d",
call, reset_count, lat_file, long_file, sim_yes, squelch, tx, rx, hab_yes, rx_pl, tx_pl, fail_yes, fail_time);
// fprintf(config_file, "%s %d", call, reset_count); // fprintf(config_file, "%s %d", call, reset_count);
fclose(config_file); fclose(config_file);
config_file = fopen("sim.cfg", "r"); config_file = fopen("sim.cfg", "r");
@ -496,8 +502,9 @@ int main(int argc, char * argv[]) {
get_tlm_fox(); // fill transmit buffer with reset count 0 packets that will be ignored get_tlm_fox(); // fill transmit buffer with reset count 0 packets that will be ignored
else if (((mode == FC))) // && !sim_mode) else if (((mode == FC))) // && !sim_mode)
get_tlm_fc(); // fill transmit buffer with reset count 0 packets that will be ignored get_tlm_fc(); // fill transmit buffer with reset count 0 packets that will be ignored
firstTime = 1; if (firstTime == 0)
firstTime = 1;
// if (!sim_mode) // always read sensors, even in sim mode // if (!sim_mode) // always read sensors, even in sim mode
{ {
@ -553,14 +560,16 @@ int main(int argc, char * argv[]) {
// #endif // #endif
fclose(uptime_file); fclose(uptime_file);
if (sim_mode) { if (fail_rnd_mode) {
if (loop % 10 == 0) { // if (loop % 10 == 0) {
if ((loopTime - failTime) > fail_time * 1000) {
// failureMode = (int) rnd_float(1, FAIL_COUNT); // failureMode = (int) rnd_float(1, FAIL_COUNT);
failureMode = (int) rnd_float(1, 9); failureMode = (int) rnd_float(1, 9);
printf("Sim Mode Random Failure Change\n"); printf("Sim Mode Random Failure Change\n");
FILE * failure_mode_file = fopen("/home/pi/CubeSatSim/failure_mode.txt", "w"); FILE * failure_mode_file = fopen("/home/pi/CubeSatSim/failure_mode.txt", "w");
fprintf(failure_mode_file, "%d", failureMode); fprintf(failure_mode_file, "%d", failureMode);
fclose(failure_mode_file); fclose(failure_mode_file);
failTime = loopTime;
} }
} }
// else // else
@ -1254,6 +1263,11 @@ void get_tlm_fox() {
// failureMode = (int) rnd_float(1, FAIL_COUNT); // failureMode = (int) rnd_float(1, FAIL_COUNT);
// printf("Random Failure\n"); // printf("Random Failure\n");
// } // }
if (failureMode == FAIL_UNPLUG) {
voltage[map[PLUS_Y]] = rnd_float(0.8, 0.95);
current[map[PLUS_Y]] = 0.0;
printf("+Y Solar Unplugged Failure\n");
}
if (failureMode == FAIL_SOLAR) { if (failureMode == FAIL_SOLAR) {
voltage[map[PLUS_X]] = 0.0; voltage[map[PLUS_X]] = 0.0;
current[map[PLUS_X]] = 0.0; current[map[PLUS_X]] = 0.0;
@ -1307,7 +1321,8 @@ void get_tlm_fox() {
// for (int frames = 0; frames < FRAME_CNT; frames++) // for (int frames = 0; frames < FRAME_CNT; frames++)
for (int frames = 0; frames < frameCnt; frames++) { for (int frames = 0; frames < frameCnt; frames++) {
if (firstTime != ON) { // if (firstTime != ON) {
if (TRUE) {
// delay for sample period // delay for sample period
/**/ /**/
@ -1325,7 +1340,7 @@ void get_tlm_fox() {
sampleTime = (unsigned int) millis(); sampleTime = (unsigned int) millis();
} else } else
printf("first time - no sleep\n"); printf("first or second time - no sleep\n");
printf("++++ Loop time: %5.3f sec +++++\n", (millis() - loopTime)/1000.0); printf("++++ Loop time: %5.3f sec +++++\n", (millis() - loopTime)/1000.0);
fflush(stdout); fflush(stdout);

@ -98,6 +98,7 @@ int socket_open = 0;
int sock = 0; int sock = 0;
int loop = -1, loop_count = 0; int loop = -1, loop_count = 0;
int firstTime = ON; // 0; int firstTime = ON; // 0;
int secondTime = ON;
long start; long start;
int testCount = 0; int testCount = 0;
long time_start; long time_start;
@ -121,18 +122,19 @@ FILE *image_file;
#define REPEATER 7 #define REPEATER 7
#define TXCOMMAND 12 #define TXCOMMAND 12
#define FAIL_COUNT 10 #define FAIL_COUNT 11
#define FAIL_NONE -1 #define FAIL_NONE -1
#define FAIL_SOLAR 1 #define FAIL_UNPLUG 1
#define FAIL_DEGRADE 2 #define FAIL_SOLAR 2
#define FAIL_SHORT 3 #define FAIL_DEGRADE 3
#define FAIL_I2C1 4 #define FAIL_SHORT 4
#define FAIL_I2C3 5 #define FAIL_I2C1 5
#define FAIL_CAMERA 6 #define FAIL_I2C3 6
#define FAIL_PAYLOAD 7 #define FAIL_CAMERA 7
#define FAIL_PAYLOAD 8
#define FAIL_BME 8 #define FAIL_BME 8
#define FAIL_MPU 9 #define FAIL_MPU 10
#define FAIL_AUDIO 10 #define FAIL_AUDIO 11
int failureMode = FAIL_NONE; int failureMode = FAIL_NONE;
int transmitStatus = -1; int transmitStatus = -1;
@ -159,6 +161,8 @@ long int uptime;
char call[5]; char call[5];
char sim_yes[10]; char sim_yes[10];
char hab_yes[10]; char hab_yes[10];
char fail_yes[10];
int fail_time = 60;
int squelch = 3; // default squelch int squelch = 3; // default squelch
char rx[12], tx[12]; char rx[12], tx[12];
int tx_pl = 0; int tx_pl = 0;
@ -223,8 +227,10 @@ int pi_zero_2_offset = 0;
int hab_mode = FALSE; int hab_mode = FALSE;
int fail_rnd_mode = FALSE;
int battery_saver_mode = FALSE; int battery_saver_mode = FALSE;
long int loopTime; long int loopTime;
long int failTime = 0;
int error_count = 0; int error_count = 0;
int groundCommandCount = 0; int groundCommandCount = 0;

@ -27,7 +27,7 @@ def sim_failure_check():
elif (fail_mode == 6): elif (fail_mode == 6):
cam_fail = True cam_fail = True
print("Failure mode camera fail") print("Failure mode camera fail")
elif (fail_mode == 0): elif (fail_mode == -1):
print("No failure mode") print("No failure mode")
else: else:
print("Other failure mode") print("Other failure mode")

@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
echo -e "\nupdate script for CubeSatSim v2.1\n" echo -e "\nupdate script for CubeSatSim v2.2\n"
FLAG=0 FLAG=0
checkout=0 checkout=0
@ -288,24 +288,22 @@ fi
cd /home/pi/pi-power-button cd /home/pi/pi-power-button
git checkout master
git pull --no-rebase > .updated_p git pull --no-rebase > .updated_p
grep 'changed' /home/pi/pi-power-button/.updated_p git checkout next
if [[ $(grep 'changed' /home/pi/pi-power-button/.updated_p) ]]; then
# 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." echo "updating pi-power-button."
# git checkout master
script/install script/install
FLAG=1 FLAG=1
else # else
echo "nothing to do for pi-power-button." # echo "nothing to do for pi-power-button."
fi # fi
cd /home/pi/ssdv cd /home/pi/ssdv

Loading…
Cancel
Save

Powered by TurnKey Linux.