diff --git a/config b/config index ab01910e..f36c9af8 100755 --- a/config +++ b/config @@ -54,7 +54,7 @@ function transmit_command_fsk { echo "Resuming command and control" sudo systemctl start command - else + STRING="AMSAT-11>APCSS:=3901.40N\07704.39WShi hi MODE=f" sudo rm /home/pi/CubeSatSim/t.txt > /dev/null 2>&1 @@ -89,7 +89,7 @@ function transmit_command_bpsk { echo "Resuming command and control" sudo systemctl start command - else + STRING="AMSAT-11>APCSS:=3901.40N\07704.39WShi hi MODE=b" sudo rm /home/pi/CubeSatSim/t.txt > /dev/null 2>&1 @@ -292,37 +292,40 @@ if [ "$1" = "" ]; then # cat $FILE case $fail in - + 1) - echo "+X Solar Panel Failure" - ;; + echo "+Y Solar Panel Unplugged (1)" + ;; 2) - echo "-X Solar Panel Degredation" + echo "+X Solar Panel Failure (2)" ;; 3) - echo "-Y Solar Panel Short Circuit" + echo "-X Solar Panel Degredation (3)" ;; 4) - echo "Failed I2C Bus 1" + echo "-Y Solar Panel Short Circuit (4)" ;; 5) - echo "Failed I2C Bus 3" + echo "Failed I2C Bus 1 (5)" ;; 6) - echo "Failed Camera" + echo "Failed I2C Bus 3 (6)" ;; 7) - echo "Failed Payload" + echo "Failed Camera (7)" ;; 8) - echo "Failed BME Sensor" + echo "Failed Payload (8)" ;; 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" ;; @@ -332,7 +335,12 @@ if [ "$1" = "" ]; then else echo "No simulated failure" 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 echo "Balloon mode is ON" @@ -398,7 +406,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" @@ -544,7 +552,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 @@ -562,8 +570,8 @@ elif [ "$1" = "-t" ]; then # 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 @@ -590,7 +598,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 @@ -604,8 +612,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 @@ -638,7 +646,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): " @@ -658,8 +666,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 @@ -693,7 +701,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): " @@ -735,8 +743,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 @@ -1028,7 +1036,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): " @@ -1050,8 +1058,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 @@ -1073,7 +1081,7 @@ elif [ "$1" = "-P" ]; then echo echo "Editing the PL (Private Line) CTCSS/CDCSS setting in" - echo "the configuration file for CubeSatSim" + echo "the configuration file for CubeSatSim" echo value=`cat /home/pi/CubeSatSim/sim.cfg` @@ -1087,7 +1095,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-121:CDCSS (digital)" @@ -1130,8 +1138,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 @@ -1161,7 +1169,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 @@ -1184,8 +1192,8 @@ elif [ "$1" = "-F" ]; then 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 + 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 # fi # if [ "$norestart" = "1" ]; then @@ -1267,7 +1275,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 @@ -1284,8 +1292,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 @@ -1498,42 +1506,45 @@ elif [ "$1" = "-M" ]; then FILE=/home/pi/CubeSatSim/failure_mode.txt if [ -f "$FILE" ]; then if [[ $(grep "\-1" $FILE) ]]; then - echo "Currently, no simulated failure" + echo "Currently, no simulated failure (0)" else fail=$(<$FILE) echo -n "Currently, simulated " case $fail in - + 1) - echo "+X Solar Panel Failure" - ;; + echo "+Y Solar Panel Unplugged (1)" + ;; 2) - echo "-X Solar Panel Degredation" + echo "+X Solar Panel Failure (2)" ;; 3) - echo "-Y Solar Panel Short Circuit" + echo "-X Solar Panel Degredation (3)" ;; 4) - echo "Failed I2C Bus 1" + echo "-Y Solar Panel Short Circuit (4)" ;; 5) - echo "Failed I2C Bus 3" + echo "Failed I2C Bus 1 (5)" ;; 6) - echo "Failed Camera" + echo "Failed I2C Bus 3 (6)" ;; 7) - echo "Failed Payload" + echo "Failed Camera (7)" ;; 8) - echo "Failed BME Sensor" + echo "Failed Payload (8)" ;; 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" ;; @@ -1548,20 +1559,20 @@ elif [ "$1" = "-M" ]; then echo echo " 0 No Failure (turn OFF)" - echo " 1 +X Solar Panel Failure" - echo " 2 -X Solar Panel Degredation" - echo " 3 -Y Solar Panel Short Circuit" - echo " 4 Failed I2C Bus 1" - echo " 5 Failed I2C Bus 3" - echo " 6 Failed Camera" - echo " 7 Failed Payload" - echo " 8 Failed BME Sensor" - echo " 9 Failed MPU Sensor" - # echo "10 Failed FM Audio" + 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 - 10" # 10 sometimes gets stuck on carrier - echo "Enter the failure number to set: 0 - 9" + echo "Enter the failure number to set: 0 - 11" read MODE echo fi @@ -1569,39 +1580,49 @@ elif [ "$1" = "-M" ]; then 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" ;; - 2) + 3) echo "Setting Simulated -X Solar Panel Degredation" ;; - 3) + 4) echo "Setting Simulated -Y Solar Panel Short Circuit" ;; - 4) + 5) echo "Setting Simulated Failed I2C Bus 1" ;; - 5) + 6) echo "Setting Simulated Failed I2C Bus 3" ;; - 6) + 7) echo "Setting Simulated Failed Camera" ;; - 7) + 8) echo "Setting Simulated Failed Payload" ;; - 8) + 9) echo "Setting Simulated Failed BME Sensor" ;; - 9) + "10") echo "Setting Simulated Failed MPU Sensor" ;; -# "10") -# echo "Setting Failed FM Audio" -# ;; + "11") + echo "Setting Failed FM Audio" + ;; *) echo "Setting No Simulated Failure" MODE=-1 @@ -1613,6 +1634,144 @@ elif [ "$1" = "-M" ]; then 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" = "-h" ]; then echo "config OPTION" @@ -1651,7 +1810,8 @@ elif [ "$1" = "-h" ]; then 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 diff --git a/install b/install index 3de142d4..2e590c3c 100755 --- a/install +++ b/install @@ -2,6 +2,16 @@ 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 if [ -f "$FILE" ]; then echo "$FILE exists." diff --git a/main.c b/main.c index 2c705223..be581eda 100644 --- a/main.c +++ b/main.c @@ -28,7 +28,8 @@ int main(int argc, char * argv[]) { printf("\n\nCubeSatSim v2.2 starting...\n\n"); wiringPiSetup(); - + + strcpy(fail_yes, "no"); // Open configuration file with callsign and reset count FILE * config_file = fopen("/home/pi/CubeSatSim/sim.cfg", "r"); if (config_file == NULL) { @@ -41,11 +42,11 @@ int main(int argc, char * argv[]) { // char * cfg_buf[100]; - fscanf(config_file, "%s %d %f %f %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); + 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, fail_yes, &fail_time); 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", - call, reset_count, lat_file, long_file, sim_yes, squelch, tx, rx, hab_yes, rx_pl, tx_pl); + 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, fail_yes, fail_time); 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; 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"); if (command_file == NULL) { @@ -289,7 +294,8 @@ int main(int argc, char * argv[]) { } 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); fclose(config_file); 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 else if (((mode == FC))) // && !sim_mode) 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 { @@ -553,14 +560,16 @@ int main(int argc, char * argv[]) { // #endif fclose(uptime_file); - if (sim_mode) { - if (loop % 10 == 0) { + if (fail_rnd_mode) { +// if (loop % 10 == 0) { + if ((loopTime - failTime) > fail_time * 1000) { // failureMode = (int) rnd_float(1, FAIL_COUNT); failureMode = (int) rnd_float(1, 9); printf("Sim Mode Random Failure Change\n"); FILE * failure_mode_file = fopen("/home/pi/CubeSatSim/failure_mode.txt", "w"); fprintf(failure_mode_file, "%d", failureMode); - fclose(failure_mode_file); + fclose(failure_mode_file); + failTime = loopTime; } } // else @@ -1254,6 +1263,11 @@ void get_tlm_fox() { // failureMode = (int) rnd_float(1, FAIL_COUNT); // 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) { voltage[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 < frameCnt; frames++) { - if (firstTime != ON) { +// if (firstTime != ON) { + if (TRUE) { // delay for sample period /**/ @@ -1325,7 +1340,7 @@ void get_tlm_fox() { sampleTime = (unsigned int) millis(); } 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); fflush(stdout); diff --git a/main.h b/main.h index 6ce6b86a..0f990ea5 100644 --- a/main.h +++ b/main.h @@ -98,6 +98,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; @@ -121,18 +122,19 @@ FILE *image_file; #define REPEATER 7 #define TXCOMMAND 12 -#define FAIL_COUNT 10 +#define FAIL_COUNT 11 #define FAIL_NONE -1 -#define FAIL_SOLAR 1 -#define FAIL_DEGRADE 2 -#define FAIL_SHORT 3 -#define FAIL_I2C1 4 -#define FAIL_I2C3 5 -#define FAIL_CAMERA 6 -#define FAIL_PAYLOAD 7 +#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 8 -#define FAIL_MPU 9 -#define FAIL_AUDIO 10 +#define FAIL_MPU 10 +#define FAIL_AUDIO 11 int failureMode = FAIL_NONE; int transmitStatus = -1; @@ -159,6 +161,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; @@ -223,8 +227,10 @@ 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 error_count = 0; int groundCommandCount = 0; diff --git a/transmit.py b/transmit.py index fc745f45..44c8a107 100644 --- a/transmit.py +++ b/transmit.py @@ -27,7 +27,7 @@ def sim_failure_check(): elif (fail_mode == 6): cam_fail = True print("Failure mode camera fail") - elif (fail_mode == 0): + elif (fail_mode == -1): print("No failure mode") else: print("Other failure mode") diff --git a/update b/update index 7c38b361..2f72c779 100755 --- a/update +++ b/update @@ -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 @@ -288,24 +288,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 next + +# 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." - -# git checkout master 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